#776 .dat files don't call restore_stls in checkpoint restore

This commit is contained in:
Scott Fennell 2019-06-01 10:48:31 -05:00
parent f85111427f
commit 7f7adca0ac
2 changed files with 11 additions and 6 deletions

View File

@ -370,7 +370,7 @@ namespace Trick {
Restore a checkpoint from the given stream.
@param in_s - input stream.
*/
int read_checkpoint( std::istream* in_s);
int read_checkpoint( std::istream* in_s, bool do_restore_stls=true);
/**
Read a checkpoint from the file of the given name.

View File

@ -7,7 +7,7 @@
#include "trick/MemoryManager.hh"
#include "trick/ClassicCheckPointAgent.hh"
int Trick::MemoryManager::read_checkpoint( std::istream *is) {
int Trick::MemoryManager::read_checkpoint( std::istream *is, bool do_restore_stls /* default is true */) {
ALLOC_INFO_MAP::iterator pos;
ALLOC_INFO* alloc_info;
@ -22,7 +22,7 @@ int Trick::MemoryManager::read_checkpoint( std::istream *is) {
}
// Search for stls and restore them
for ( pos=alloc_info_map.begin() ; pos!=alloc_info_map.end() ; pos++ ) {
for ( pos=alloc_info_map.begin() ; do_restore_stls && pos!=alloc_info_map.end() ; pos++ ) {
restore_stls(pos->second) ;
}
@ -60,12 +60,17 @@ int Trick::MemoryManager::read_checkpoint(const char* filename ) {
// Create a stream from the named file.
std::ifstream infile(filename , std::ios::in);
if (infile.is_open()) {
return ( read_checkpoint( &infile ));
// If the file extention is .dat, we will tell read_checkpoint not to
// restore stls. It is not necessary and time consuming.
bool do_restore_stls =
(std::string(filename).find(".dat") != std::string::npos);
return ( read_checkpoint( &infile, do_restore_stls )) ;
} else {
std::stringstream message;
message << "Couldn't open \"" << filename << "\".";
message << "Couldn't open \"" << filename << "\"." ;
emitError(message.str());
}
return 1;