Merge pull request #800 from nasa/#776

#776 .dat files don't call restore_stls in checkpoint restore
This commit is contained in:
Scott Fennell 2019-06-03 10:42:16 -05:00 committed by GitHub
commit c3d64bc977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 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=false);
/**
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 false */) {
ALLOC_INFO_MAP::iterator pos;
ALLOC_INFO* alloc_info;
@ -22,8 +22,10 @@ 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++ ) {
restore_stls(pos->second) ;
if(do_restore_stls) {
for ( pos=alloc_info_map.begin() ; pos!=alloc_info_map.end() ; pos++ ) {
restore_stls(pos->second) ;
}
}
// Go through all of the allocations that have been created looking
@ -60,12 +62,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 filename is not S_default.dat, we will tell read_checkpoint to
// restore stls.
bool do_restore_stls =
(std::string(filename).find("S_default.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;