mirror of
https://github.com/nasa/trick.git
synced 2025-01-31 00:24:03 +00:00
1093 c str (#1119)
* update checkpoint_map.hh #1093 * #1093 update checkpoint_pair.hh * #1093 update checkpoint_queue.hh * #1093 update MM_write_checkpoint.cc * #1093 update units_attach.i * #1093 update checkpoint_sequence_stl.hh * #1093 update checkpoint_stack.hh * #1093 update swig_extend_str.i * #1093 update swig_int_templates.hh * #1093 update checkpoint_stack.hh and swig_int_typemap.i * #1093 fix c_str issue without adding memory leaks * #1093 fix c_str issue without adding memory leaks * #1093 remove dangling pointers in injector sim object (without causing memory leaks) * #1093 remove dangling pointers in injector sim object (without causing memory leaks) * #1093 remove dangling pointers in Event Manaager sim object (without causing memory leaks) * #1093 fix MonteCarlo_c_intf dangling pointers Co-authored-by: Fennell, Scott P 263712616 <scott.p.fennell@nasa.gov> closes #1093
This commit is contained in:
parent
a5e67ae3a9
commit
6691b14e9e
@ -7,6 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace Trick {
|
||||
|
||||
@ -28,7 +29,7 @@ namespace Trick {
|
||||
ExternalApplication();
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~ExternalApplication() {}
|
||||
virtual ~ExternalApplication();
|
||||
|
||||
/**
|
||||
* Sets #command.
|
||||
@ -44,6 +45,13 @@ namespace Trick {
|
||||
*/
|
||||
virtual std::string get_startup_command();
|
||||
|
||||
/**
|
||||
* Gets #command as c str.
|
||||
*
|
||||
* @return the launch command as c str
|
||||
*/
|
||||
virtual const char * get_startup_command_c_str();
|
||||
|
||||
/**
|
||||
* Appends #arguments.
|
||||
*
|
||||
@ -216,9 +224,6 @@ namespace Trick {
|
||||
/** Designates from which source an option is to be used. */
|
||||
enum OptionSource {AUTO, USER, NONE};
|
||||
|
||||
/** Command to execute when starting this application. */
|
||||
std::string command;
|
||||
|
||||
/** Arguments to be passed after the command. */
|
||||
std::ostringstream arguments;
|
||||
|
||||
@ -284,6 +289,18 @@ namespace Trick {
|
||||
|
||||
/** Creates a string containing the arguements that this application explicitly supports. */
|
||||
virtual std::string create_arguments_string();
|
||||
|
||||
protected:
|
||||
|
||||
/** Command to execute when starting this application. */
|
||||
std::string command;
|
||||
|
||||
/** Pointer to alloc'd command c str for use with external application c_intf */
|
||||
char * command_c_str;
|
||||
|
||||
/** alloc'd addresses to be deallocated during app destruction (currently only
|
||||
used by command_c_str) */
|
||||
std::vector<void*> allocations;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -534,6 +534,11 @@ namespace Trick {
|
||||
*/
|
||||
std::string get_user_cmd_string();
|
||||
|
||||
/**
|
||||
* Gets #user_cmd_string as a char*.
|
||||
*/
|
||||
const char* get_user_cmd_string_c_str();
|
||||
|
||||
/**
|
||||
* Sets #custom_pre_text.
|
||||
*/
|
||||
@ -544,6 +549,11 @@ namespace Trick {
|
||||
*/
|
||||
std::string get_custom_pre_text();
|
||||
|
||||
/**
|
||||
* Gets #custom_pre_text as a char*.
|
||||
*/
|
||||
const char* get_custom_pre_text_c_str();
|
||||
|
||||
/**
|
||||
* Sets #custom_post_text.
|
||||
*/
|
||||
@ -554,6 +564,11 @@ namespace Trick {
|
||||
*/
|
||||
std::string get_custom_post_text();
|
||||
|
||||
/**
|
||||
* Gets #custom_post_text as a char*.
|
||||
*/
|
||||
const char* get_custom_post_text_c_str();
|
||||
|
||||
/**
|
||||
* Sets #verbosity.
|
||||
*/
|
||||
|
@ -44,6 +44,10 @@ int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string va
|
||||
typename STL::iterator iter ;
|
||||
int status ;
|
||||
|
||||
// used for keeping c_str components of std::strings allocated and accessable
|
||||
// while they are being used.
|
||||
std::string temp_str;
|
||||
|
||||
typename STL::key_type * keys = nullptr ;
|
||||
typename STL::mapped_type * items = nullptr ;
|
||||
|
||||
@ -60,9 +64,11 @@ int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string va
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
|
||||
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
keys = (typename STL::key_type *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( keys ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_keys");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
var_declare.str("") ;
|
||||
@ -75,9 +81,11 @@ int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string va
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
|
||||
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
items = (typename STL::mapped_type *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_data");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
/* copy the contents of the map the 2 arrays */
|
||||
@ -115,6 +123,10 @@ int checkpoint_map_ik_sd(STL & in_map , std::string object_name , std::string va
|
||||
typename STL::iterator iter ;
|
||||
int status ;
|
||||
|
||||
// used for keeping c_str components of std::strings allocated and accessable
|
||||
// while they are being used.
|
||||
std::string temp_str;
|
||||
|
||||
typename STL::key_type * keys = nullptr ;
|
||||
std::string * items = nullptr ;
|
||||
|
||||
@ -131,18 +143,22 @@ int checkpoint_map_ik_sd(STL & in_map , std::string object_name , std::string va
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
|
||||
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
keys = (typename STL::key_type *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( keys ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_keys");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
var_declare.str("") ;
|
||||
var_declare.clear() ;
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
|
||||
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_data");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
/* copy the contents of the map the 2 arrays */
|
||||
@ -188,6 +204,10 @@ int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string va
|
||||
typename STL::iterator iter ;
|
||||
int status ;
|
||||
|
||||
// used for keeping c_str components of std::strings allocated and accessable
|
||||
// while they are being used.
|
||||
std::string temp_str;
|
||||
|
||||
std::string * keys = nullptr ;
|
||||
typename STL::mapped_type * items = nullptr ;
|
||||
|
||||
@ -197,9 +217,11 @@ int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string va
|
||||
if ( cont_size > 0 ) {
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
|
||||
keys = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
keys = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( keys ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_keys");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
var_declare.str("") ;
|
||||
@ -213,9 +235,11 @@ int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string va
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
|
||||
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (typename STL::mapped_type *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_data");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
/* copy the contents of the map the 2 arrays */
|
||||
@ -260,6 +284,10 @@ int checkpoint_map_stl_sk_sd(STL & in_map , std::string object_name , std::strin
|
||||
std::ostringstream var_declare ;
|
||||
typename STL::iterator iter ;
|
||||
|
||||
// used for keeping c_str components of std::strings allocated and accessable
|
||||
// while they are being used.
|
||||
std::string temp_str;
|
||||
|
||||
std::string * keys = nullptr ;
|
||||
std::string * items = nullptr ;
|
||||
|
||||
@ -269,18 +297,22 @@ int checkpoint_map_stl_sk_sd(STL & in_map , std::string object_name , std::strin
|
||||
if ( cont_size > 0 ) {
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
|
||||
keys = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
keys = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( keys ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_keys");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
var_declare.str("") ;
|
||||
var_declare.clear() ;
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_data[" << cont_size << "]" ;
|
||||
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_data");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "HERE with %s\n", var_declare) ;
|
||||
|
||||
/* copy the contents of the map the 2 arrays */
|
||||
@ -325,10 +357,14 @@ template <class STL>
|
||||
int delete_map_allocs(STL & in_map __attribute__ ((unused)), std::string object_name , std::string var_name ) {
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
REF2 * items_ref ;
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_keys")).c_str()) ;
|
||||
std::string temp_str;
|
||||
temp_str = object_name + std::string("_") + var_name + std::string("_keys");
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
if ( items_ref != NULL ) {
|
||||
TMM_delete_var_n((object_name + std::string("_") + var_name + std::string("_keys")).c_str() ) ;
|
||||
TMM_delete_var_n((object_name + std::string("_") + var_name + std::string("_data")).c_str() ) ;
|
||||
temp_str = object_name + std::string("_") + var_name + std::string("_keys");
|
||||
TMM_delete_var_n(temp_str.c_str() ) ;
|
||||
temp_str = object_name + std::string("_") + var_name + std::string("_data");
|
||||
TMM_delete_var_n(temp_str.c_str() ) ;
|
||||
free(items_ref) ;
|
||||
}
|
||||
return 0 ;
|
||||
@ -359,15 +395,19 @@ int restore_map_ik_id(STL & in_map , std::string object_name , std::string var_n
|
||||
unsigned int cont_size ;
|
||||
|
||||
REF2 * keys_ref , * items_ref ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
typename STL::key_type * keys ;
|
||||
typename STL::mapped_type * items ;
|
||||
|
||||
//message_publish(1, "in regular map template restore\n") ;
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_keys";
|
||||
keys_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_data";
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( keys_ref != NULL && items_ref != NULL ) {
|
||||
in_map.clear() ;
|
||||
@ -404,6 +444,8 @@ int restore_map_ik_sd(STL & in_map , std::string object_name , std::string var_n
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
REF2 * keys_ref , * items_ref ;
|
||||
typename STL::key_type * keys ;
|
||||
std::string * items ;
|
||||
@ -412,8 +454,10 @@ int restore_map_ik_sd(STL & in_map , std::string object_name , std::string var_n
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_keys";
|
||||
keys_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_data";
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( keys_ref != NULL && items_ref != NULL ) {
|
||||
in_map.clear() ;
|
||||
@ -454,6 +498,8 @@ int restore_map_sk_id(STL & in_map , std::string object_name , std::string var_n
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
REF2 * keys_ref , * items_ref ;
|
||||
std::string * keys ;
|
||||
typename STL::mapped_type * items ;
|
||||
@ -462,8 +508,10 @@ int restore_map_sk_id(STL & in_map , std::string object_name , std::string var_n
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_keys";
|
||||
keys_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_data";
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( keys_ref != NULL && items_ref != NULL ) {
|
||||
in_map.clear() ;
|
||||
@ -504,6 +552,8 @@ int restore_map_sk_sd(STL & in_map , std::string object_name , std::string var_n
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
REF2 * keys_ref , * items_ref ;
|
||||
std::string * keys ;
|
||||
std::string * items ;
|
||||
@ -512,8 +562,10 @@ int restore_map_sk_sd(STL & in_map , std::string object_name , std::string var_n
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_keys";
|
||||
keys_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_data";
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( keys_ref != NULL && items_ref != NULL ) {
|
||||
in_map.clear() ;
|
||||
|
@ -29,6 +29,7 @@ template <class FIRST, class SECOND, typename std::enable_if<!is_stl_container<F
|
||||
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
std::string temp_str;
|
||||
|
||||
FIRST * first = nullptr ;
|
||||
SECOND * second = nullptr ;
|
||||
@ -43,9 +44,11 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_first[1]" ;
|
||||
first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
first = (FIRST *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( first ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_first");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
first[0] = in_pair.first ;
|
||||
|
||||
var_declare.str("") ;
|
||||
@ -58,9 +61,11 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_second[1]" ;
|
||||
second = (SECOND *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
second = (SECOND *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( second ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_second");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
second[0] = in_pair.second ;
|
||||
}
|
||||
}
|
||||
@ -76,6 +81,8 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
FIRST * first = nullptr ;
|
||||
std::string * second = nullptr ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
@ -88,18 +95,22 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_first[1]" ;
|
||||
first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
first = (FIRST *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( first ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_first") ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
first[0] = in_pair.first ;
|
||||
|
||||
var_declare.str("") ;
|
||||
var_declare.clear() ;
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_second[1]" ;
|
||||
second = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
second = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( second ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_second");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
checkpoint_stl( in_pair.second , object_name + "_" + var_name , "second" ) ;
|
||||
}
|
||||
}
|
||||
@ -115,14 +126,18 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
std::string * first = nullptr ;
|
||||
SECOND * second = nullptr ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_first[1]" ;
|
||||
first = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
first = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_first");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
checkpoint_stl( in_pair.first , object_name + "_" + var_name , "first" ) ;
|
||||
|
||||
var_declare.str("") ;
|
||||
@ -136,8 +151,10 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "_second[1]" ;
|
||||
second = (SECOND *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
second = (SECOND *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_second");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
second[0] = in_pair.second ;
|
||||
|
||||
return 0 ;
|
||||
@ -152,20 +169,27 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name
|
||||
|
||||
std::string * first = nullptr ;
|
||||
std::string * second = nullptr ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_first[1]" ;
|
||||
first = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
first = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_first");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
checkpoint_stl( in_pair.first , object_name + "_" + var_name , "first" ) ;
|
||||
|
||||
var_declare.str("") ;
|
||||
var_declare.clear() ;
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "_second[1]" ;
|
||||
second = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = var_declare.str();
|
||||
second = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name + "_second");
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
checkpoint_stl( in_pair.second , object_name + "_" + var_name , "second" ) ;
|
||||
|
||||
return 0 ;
|
||||
@ -177,10 +201,13 @@ template <class FIRST, class SECOND>
|
||||
int delete_stl(std::pair<FIRST, SECOND> & in_stl __attribute__ ((unused)) , std::string object_name , std::string var_name ) {
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
REF2 * items_ref ;
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
std::string temp_str = object_name + "_" + var_name + "_first";
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
if ( items_ref != NULL ) {
|
||||
TMM_delete_var_n((object_name + "_" + var_name + "_first").c_str() ) ;
|
||||
TMM_delete_var_n((object_name + "_" + var_name + "_second").c_str() ) ;
|
||||
temp_str = object_name + "_" + var_name + "_first";
|
||||
TMM_delete_var_n(temp_str.c_str() ) ;
|
||||
temp_str = object_name + "_" + var_name + "_second";
|
||||
TMM_delete_var_n(temp_str.c_str() ) ;
|
||||
free(items_ref) ;
|
||||
}
|
||||
return 0 ;
|
||||
@ -198,11 +225,14 @@ int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name ,
|
||||
|
||||
FIRST * first ;
|
||||
SECOND * second ;
|
||||
|
||||
std::string temp_str;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
first_ref = ref_attributes((char *)(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
second_ref = ref_attributes((char *)(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_first";
|
||||
first_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_second" ;
|
||||
second_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( first_ref != NULL && second_ref != NULL ) {
|
||||
first = (FIRST *)first_ref->address ;
|
||||
@ -228,11 +258,14 @@ int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name ,
|
||||
FIRST * first ;
|
||||
std::string * second ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
first_ref = ref_attributes((char *)(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
second_ref = ref_attributes((char *)(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_first";
|
||||
first_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_second";
|
||||
second_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( first_ref != NULL && second_ref != NULL ) {
|
||||
first = (FIRST *)first_ref->address ;
|
||||
@ -258,11 +291,13 @@ int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name ,
|
||||
std::string * first ;
|
||||
SECOND * second ;
|
||||
|
||||
std::string temp_str;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
first_ref = ref_attributes((char *)(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
second_ref = ref_attributes((char *)(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_first";
|
||||
first_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_second";
|
||||
second_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( first_ref != NULL && second_ref != NULL ) {
|
||||
first = (std::string *)first_ref->address ;
|
||||
@ -287,11 +322,14 @@ int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name ,
|
||||
std::string * first ;
|
||||
std::string * second ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
first_ref = ref_attributes((char *)(object_name + "_" + var_name + "_first").c_str()) ;
|
||||
second_ref = ref_attributes((char *)(object_name + "_" + var_name + "_second").c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_first";
|
||||
first_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
temp_str = object_name + "_" + var_name + "_second" ;
|
||||
second_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( first_ref != NULL && second_ref != NULL ) {
|
||||
first = (std::string *)first_ref->address ;
|
||||
|
@ -35,6 +35,7 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
std::string temp_str ;
|
||||
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
std::queue<ITEM_TYPE,_Sequence> temp_queue(in_stl) ;
|
||||
@ -52,9 +53,11 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
@ -76,6 +79,8 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
|
||||
std::string temp_str;
|
||||
|
||||
std::string * items = nullptr ;
|
||||
std::queue<ITEM_TYPE,_Sequence> temp_queue(in_stl) ;
|
||||
|
||||
@ -85,9 +90,11 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
if ( cont_size > 0 ) {
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
@ -115,6 +122,8 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
std::priority_queue<ITEM_TYPE,_Container,_Compare> temp_queue(in_stl) ;
|
||||
|
||||
@ -131,9 +140,11 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
@ -156,6 +167,8 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
std::string * items = nullptr ;
|
||||
std::priority_queue<ITEM_TYPE,_Container,_Compare> temp_queue(in_stl) ;
|
||||
|
||||
@ -165,9 +178,11 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
|
||||
if ( cont_size > 0 ) {
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
@ -216,13 +231,15 @@ int restore_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_na
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
ITEM_TYPE * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
@ -248,13 +265,15 @@ int restore_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_na
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
std::string * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = object_name + "_" + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
@ -285,13 +304,15 @@ int restore_stl(std::priority_queue<ITEM_TYPE,_Container,_Compare> & in_stl ,
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
ITEM_TYPE * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
@ -318,13 +339,15 @@ int restore_stl(std::priority_queue<ITEM_TYPE,_Container,_Compare> & in_stl ,
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
std::string * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = object_name + "_" + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
|
@ -34,6 +34,7 @@ int checkpoint_sequence_i(STL & in_stl , std::string object_name , std::string v
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
std::string temp_str;
|
||||
int status ;
|
||||
|
||||
typename STL::value_type * items = NULL ;
|
||||
@ -55,9 +56,11 @@ int checkpoint_sequence_i(STL & in_stl , std::string object_name , std::string v
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (typename STL::value_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (typename STL::value_type *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name);
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ;
|
||||
|
||||
/* copy the contents of the stl */
|
||||
@ -77,6 +80,7 @@ int checkpoint_sequence_s(STL & in_stl , std::string object_name , std::string v
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
std::string temp_str ;
|
||||
|
||||
std::string * items ;
|
||||
typename STL::iterator it ;
|
||||
@ -91,10 +95,12 @@ int checkpoint_sequence_s(STL & in_stl , std::string object_name , std::string v
|
||||
if ( cont_size > 0 ) {
|
||||
|
||||
var_declare << "std::string " << object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_SEQUENCE_STL_STL with %s\n", var_declare.str().c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_SEQUENCE_STL_STL with %s\n", temp_str.c_str()) ;
|
||||
|
||||
/* create the names of the sub stl checkpoint names we're going to be using */
|
||||
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) {
|
||||
@ -216,9 +222,11 @@ template <class STL>
|
||||
int delete_sequence_alloc(STL & in_stl __attribute__ ((unused)), std::string object_name , std::string var_name ) {
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
REF2 * items_ref ;
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
std::string temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
if ( items_ref != NULL ) {
|
||||
TMM_delete_var_n((object_name + std::string("_") + var_name).c_str() ) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
TMM_delete_var_n(temp_str.c_str() ) ;
|
||||
free(items_ref) ;
|
||||
}
|
||||
return 0 ;
|
||||
@ -267,14 +275,15 @@ int restore_sequence_i(STL & in_stl , std::string object_name , std::string var_
|
||||
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
typename STL::value_type * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_SEQUENCE_STL %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
in_stl.clear() ;
|
||||
@ -298,11 +307,12 @@ int restore_sequence_s(STL & in_stl , std::string object_name , std::string var_
|
||||
|
||||
REF2 * items_ref ;
|
||||
std::string * items ;
|
||||
std::string temp_str ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "%s\n", __PRETTY_FUNCTION__) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = object_name + "_" + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
in_stl.clear() ;
|
||||
@ -334,11 +344,12 @@ int restore_stl(std::array<ITEM_TYPE,N> & in_stl , std::string object_name , std
|
||||
|
||||
REF2 * items_ref ;
|
||||
std::string * items ;
|
||||
std::string temp_str ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "%s\n", __PRETTY_FUNCTION__) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = object_name + "_" + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
items = (std::string *)items_ref->address ;
|
||||
@ -363,14 +374,15 @@ template <typename ITEM_TYPE, std::size_t N,
|
||||
int restore_stl(std::array<ITEM_TYPE,N> & in_stl , std::string object_name , std::string var_name ) {
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
typename std::array<ITEM_TYPE,N>::value_type * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_SEQUENCE_STL %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
items = (typename std::array<ITEM_TYPE,N>::value_type *)items_ref->address ;
|
||||
|
@ -31,6 +31,7 @@ int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
std::string temp_str ;
|
||||
int status ;
|
||||
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
@ -49,9 +50,11 @@ int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
}
|
||||
var_declare << type_string << " "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
@ -72,6 +75,7 @@ int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::ostringstream var_declare ;
|
||||
std::string temp_str ;
|
||||
|
||||
std::string * items = nullptr ;
|
||||
std::stack<ITEM_TYPE,_Sequence> temp_stack(in_stl) ;
|
||||
@ -82,9 +86,11 @@ int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
if ( cont_size > 0 ) {
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
temp_str = var_declare.str() ;
|
||||
items = (std::string *)TMM_declare_var_s(temp_str.c_str()) ;
|
||||
if ( items ) {
|
||||
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
|
||||
temp_str = std::string(object_name + "_" + var_name) ;
|
||||
TMM_add_checkpoint_alloc_dependency(temp_str.c_str()) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
@ -124,14 +130,15 @@ template <typename ITEM_TYPE, typename _Sequence,
|
||||
int restore_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_STL_STACK %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
@ -155,14 +162,15 @@ template <typename ITEM_TYPE, typename _Sequence,
|
||||
int restore_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
|
||||
unsigned int ii ;
|
||||
unsigned int cont_size ;
|
||||
std::string temp_str ;
|
||||
|
||||
REF2 * items_ref ;
|
||||
std::string * items = nullptr ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), static_cast<int (*)(int)>(std::ispunct), '_');
|
||||
|
||||
//message_publish(1, "RESTORE_STL_STACK %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
temp_str = object_name + std::string("_") + var_name ;
|
||||
items_ref = ref_attributes((char *)temp_str.c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
|
@ -12,6 +12,7 @@
|
||||
extern ATTRIBUTES attr##TYPE[] ;
|
||||
|
||||
std::stringstream os ;
|
||||
std::string temp_str ;
|
||||
Trick::PythonPrint pp ;
|
||||
|
||||
static char * temp = NULL ;
|
||||
@ -26,7 +27,8 @@
|
||||
os << "]" ;
|
||||
|
||||
temp = (char *)realloc( (void *)temp , os.str().length() + 1 ) ;
|
||||
strncpy(temp , os.str().c_str(), os.str().length()) ;
|
||||
temp_str = os.str() ;
|
||||
strncpy(temp , temp_str.c_str(), os.str().length()) ;
|
||||
temp[os.str().length()] = '\0' ;
|
||||
|
||||
return temp ;
|
||||
|
@ -16,12 +16,14 @@ template< class S , typename T > static int convert_and_set( T & output , void *
|
||||
if ( temp_m->units.compare("1") ) {
|
||||
ut_unit * from = ut_parse(Trick::UdUnits::get_u_system(), temp_m->units.c_str(), UT_ASCII) ;
|
||||
if ( !from ) {
|
||||
PyErr_SetString(PyExc_AttributeError,(std::string("could not covert from units "+temp_m->units).c_str()));
|
||||
std::string temp_str = std::string("could not covert from units " + temp_m->units);
|
||||
PyErr_SetString(PyExc_AttributeError,(temp_str.c_str()));
|
||||
return -1 ;
|
||||
}
|
||||
ut_unit * to = ut_parse(Trick::UdUnits::get_u_system(), to_units.c_str(), UT_ASCII) ;
|
||||
if ( !to ) {
|
||||
PyErr_SetString(PyExc_AttributeError,(std::string("could not covert to units "+to_units).c_str()));
|
||||
std::string temp_str = std::string("could not covert to units " + to_units) ;
|
||||
PyErr_SetString(PyExc_AttributeError,(temp_str.c_str()));
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,7 @@
|
||||
enum SWIGTYPE [ANY] , bool [ANY] ,
|
||||
double [ANY] , float [ANY] {
|
||||
std::string temp_name ;
|
||||
std::string temp_str ;
|
||||
|
||||
swig_ref * t = new swig_ref ;
|
||||
|
||||
@ -152,7 +153,8 @@
|
||||
|
||||
temp_name = "$symname" ;
|
||||
temp_name.erase(temp_name.length() - 4) ;
|
||||
t->ref.attr->units = strdup(Trick::UnitsMap::units_map()->get_units(temp_name).c_str()) ;
|
||||
temp_str = Trick::UnitsMap::units_map()->get_units(temp_name) ;
|
||||
t->ref.attr->units = strdup(temp_str.c_str()) ;
|
||||
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIG_TypeQuery("_p_swig_ref"), SWIG_POINTER_OWN);
|
||||
}
|
||||
@ -191,6 +193,7 @@
|
||||
enum SWIGTYPE * , bool * ,
|
||||
double * , float * {
|
||||
std::string temp_name ;
|
||||
std::string temp_str ;
|
||||
|
||||
swig_ref * t = new swig_ref ;
|
||||
|
||||
@ -224,7 +227,8 @@
|
||||
|
||||
temp_name = "$symname" ;
|
||||
temp_name.erase(temp_name.length() - 4) ;
|
||||
t->ref.attr->units = strdup(Trick::UnitsMap::units_map()->get_units(temp_name).c_str()) ;
|
||||
temp_str = Trick::UnitsMap::units_map()->get_units(temp_name) ;
|
||||
t->ref.attr->units = strdup(temp_str.c_str()) ;
|
||||
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIG_TypeQuery("_p_swig_ref"), SWIG_POINTER_OWN);
|
||||
}
|
||||
@ -304,6 +308,7 @@
|
||||
//INT[ANY][ANY] OUT
|
||||
|
||||
std::string temp_name ;
|
||||
std::string temp_str ;
|
||||
|
||||
swig_ref * t = new swig_ref ;
|
||||
|
||||
@ -337,7 +342,8 @@
|
||||
|
||||
temp_name = "$symname" ;
|
||||
temp_name.erase(temp_name.length() - 4) ;
|
||||
t->ref.attr->units = strdup(Trick::UnitsMap::units_map()->get_units(temp_name).c_str()) ;
|
||||
temp_str = Trick::UnitsMap::units_map()->get_units(temp_name) ;
|
||||
t->ref.attr->units = strdup(temp_str.c_str()) ;
|
||||
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIG_TypeQuery("_p_swig_ref"), SWIG_POINTER_OWN);
|
||||
}
|
||||
@ -354,6 +360,7 @@
|
||||
//INT * [ANY] OUT
|
||||
|
||||
std::string temp_name ;
|
||||
std::string temp_str ;
|
||||
$1_basetype dummy ;
|
||||
char * type_name = strdup("$1_basetype") ;
|
||||
|
||||
@ -391,7 +398,8 @@
|
||||
|
||||
temp_name = "$symname" ;
|
||||
temp_name.erase(temp_name.length() - 4) ;
|
||||
t->ref.attr->units = strdup(Trick::UnitsMap::units_map()->get_units(temp_name).c_str()) ;
|
||||
temp_str = Trick::UnitsMap::units_map()->get_units(temp_name) ;
|
||||
t->ref.attr->units = strdup(temp_str.c_str()) ;
|
||||
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIG_TypeQuery("_p_swig_ref"), SWIG_POINTER_OWN);
|
||||
|
||||
@ -441,6 +449,7 @@
|
||||
//INT ** OUT
|
||||
|
||||
std::string temp_name ;
|
||||
std::string temp_str ;
|
||||
|
||||
swig_ref * t = new swig_ref ;
|
||||
|
||||
@ -474,7 +483,8 @@
|
||||
|
||||
temp_name = "$symname" ;
|
||||
temp_name.erase(temp_name.length() - 4) ;
|
||||
t->ref.attr->units = strdup(Trick::UnitsMap::units_map()->get_units(temp_name).c_str()) ;
|
||||
temp_str = Trick::UnitsMap::units_map()->get_units(temp_name) ;
|
||||
t->ref.attr->units = strdup(temp_str.c_str()) ;
|
||||
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIG_TypeQuery("_p_swig_ref"), SWIG_POINTER_OWN);
|
||||
|
||||
@ -495,6 +505,7 @@
|
||||
//DOUBLE[ANY][ANY][ANY] OUT
|
||||
|
||||
std::string temp_name ;
|
||||
std::string temp_str ;
|
||||
|
||||
swig_ref * t = new swig_ref ;
|
||||
|
||||
@ -529,7 +540,8 @@
|
||||
|
||||
temp_name = "$symname" ;
|
||||
temp_name.erase(temp_name.length() - 4) ;
|
||||
t->ref.attr->units = strdup(Trick::UnitsMap::units_map()->get_units(temp_name).c_str()) ;
|
||||
temp_str = Trick::UnitsMap::units_map()->get_units(temp_name) ;
|
||||
t->ref.attr->units = strdup(temp_str.c_str()) ;
|
||||
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIG_TypeQuery("_p_swig_ref"), SWIG_POINTER_OWN);
|
||||
}
|
||||
|
@ -377,6 +377,7 @@ class EventManagerSimObject : public Trick::SimObject {
|
||||
Trick::EventManager em ;
|
||||
Trick::EventProcessor ep ;
|
||||
std::vector< ThreadProcessEventSimObject * > thread_process_event_so ; // ** ignore for checkpointing
|
||||
std::vector<char *> thread_process_event_so_names ;
|
||||
|
||||
void create_thread_process_event() {
|
||||
unsigned int ii ;
|
||||
@ -386,8 +387,10 @@ class EventManagerSimObject : public Trick::SimObject {
|
||||
std::ostringstream oss ;
|
||||
oss << "thread_process_event_" << ii ;
|
||||
thread_process_event_so.push_back(tpeso) ;
|
||||
exec_add_sim_object(tpeso, oss.str().c_str()) ;
|
||||
TMM_declare_ext_var(tpeso, TRICK_STRUCTURED,"ThreadProcessEventSimObject", 0, oss.str().c_str(), 0, NULL) ;
|
||||
char* name = strdup(oss.str().c_str()) ;
|
||||
thread_process_event_so_names.push_back(name) ;
|
||||
exec_add_sim_object(tpeso, name) ;
|
||||
TMM_declare_ext_var(tpeso, TRICK_STRUCTURED,"ThreadProcessEventSimObject", 0, name, 0, NULL) ;
|
||||
// Add the child thread event processor.
|
||||
em.add_event_processor(&(tpeso->ep)) ;
|
||||
}
|
||||
@ -415,6 +418,12 @@ class EventManagerSimObject : public Trick::SimObject {
|
||||
ep.set_process_event_job(get_job("ep.process_event")) ;
|
||||
|
||||
}
|
||||
|
||||
~EventManagerSimObject() {
|
||||
for(std::vector<char*>::iterator it = thread_process_event_so_names.begin(); it != thread_process_event_so_names.end(); ++it) {
|
||||
free(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EventManagerSimObject trick_em ;
|
||||
@ -746,7 +755,9 @@ class InjectorSimObject : public Trick::SimObject {
|
||||
|
||||
public:
|
||||
Trick::RtiStager rtis ;
|
||||
std::vector< InjectorExecSimObject * > injector_executor_so ; // trick_io(**)
|
||||
std::vector< InjectorExecSimObject * > injector_executor_so ;
|
||||
std::vector<char *> injector_executor_so_names ;
|
||||
// trick_io(**)
|
||||
|
||||
void create_injector_executors() {
|
||||
unsigned int ii ;
|
||||
@ -756,8 +767,10 @@ class InjectorSimObject : public Trick::SimObject {
|
||||
std::ostringstream oss ;
|
||||
oss << "trick_injector_executor_" << ii ;
|
||||
injector_executor_so.push_back(ieso) ;
|
||||
exec_add_sim_object(ieso, oss.str().c_str()) ;
|
||||
TMM_declare_ext_var(ieso, TRICK_STRUCTURED,"InjectorExecSimObject", 0, oss.str().c_str(), 0, NULL) ;
|
||||
char* name = strdup(oss.str().c_str()) ;
|
||||
injector_executor_so_names.push_back(name);
|
||||
exec_add_sim_object(ieso, name) ;
|
||||
TMM_declare_ext_var(ieso, TRICK_STRUCTURED,"InjectorExecSimObject", 0, name, 0, NULL) ;
|
||||
// Add the child thread realtime injector.
|
||||
rtis.AddInjectorExecutor(&(ieso->rtie)) ;
|
||||
}
|
||||
@ -766,6 +779,12 @@ class InjectorSimObject : public Trick::SimObject {
|
||||
InjectorSimObject() {
|
||||
{TRK} P0 ("default_data") create_injector_executors() ;
|
||||
}
|
||||
|
||||
~InjectorSimObject() {
|
||||
for(std::vector<char*>::iterator it = injector_executor_so_names.begin(); it != injector_executor_so_names.end(); ++it) {
|
||||
free(*it);
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
InjectorSimObject trick_inject ;
|
||||
|
@ -21,16 +21,33 @@ Trick::ExternalApplication::ExternalApplication() :
|
||||
host_source = port_source = AUTO;
|
||||
cycle_period_set = minimum_cycle_period_set = disconnect_behavior_set = height_set =
|
||||
width_set = x_set = y_set = auto_reconnect_set = false;
|
||||
|
||||
// c_intf uses char *, we manage the memory here in external application
|
||||
command_c_str = strdup(command.c_str());
|
||||
allocations.push_back((void*)command_c_str);
|
||||
}
|
||||
|
||||
Trick::ExternalApplication::~ExternalApplication() {
|
||||
for(std::vector<void*>::iterator it = allocations.begin(); it != allocations.end(); ++it) {
|
||||
free(*it);
|
||||
}
|
||||
allocations.clear();
|
||||
}
|
||||
|
||||
void Trick::ExternalApplication::set_startup_command(std::string in_command) {
|
||||
command = in_command;
|
||||
command_c_str = strdup(in_command.c_str());
|
||||
allocations.push_back((void *) command_c_str);
|
||||
}
|
||||
|
||||
std::string Trick::ExternalApplication::get_startup_command() {
|
||||
return command;
|
||||
}
|
||||
|
||||
const char * Trick::ExternalApplication::get_startup_command_c_str() {
|
||||
return command_c_str;
|
||||
}
|
||||
|
||||
void Trick::ExternalApplication::add_arguments(std::string args) {
|
||||
arguments << " " << args;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ extern "C" const char *sim_control_panel_get_startup_command(void) {
|
||||
Trick::add_external_application(*externalApplication);
|
||||
}
|
||||
|
||||
return externalApplication->get_startup_command().c_str();
|
||||
return externalApplication->get_startup_command_c_str();
|
||||
}
|
||||
|
||||
extern "C" const char *trick_view_get_startup_command(void) {
|
||||
@ -219,7 +219,7 @@ extern "C" const char *trick_view_get_startup_command(void) {
|
||||
Trick::add_external_application(*externalApplication);
|
||||
}
|
||||
|
||||
return externalApplication->get_startup_command().c_str();
|
||||
return externalApplication->get_startup_command_c_str();
|
||||
}
|
||||
|
||||
extern "C" const char *malfunctions_trick_view_get_startup_command(void) {
|
||||
@ -232,7 +232,7 @@ extern "C" const char *malfunctions_trick_view_get_startup_command(void) {
|
||||
Trick::add_external_application(*externalApplication);
|
||||
}
|
||||
|
||||
return externalApplication->get_startup_command().c_str();
|
||||
return externalApplication->get_startup_command_c_str();
|
||||
}
|
||||
|
||||
extern "C" const char *monte_monitor_get_startup_command(void) {
|
||||
@ -245,7 +245,7 @@ extern "C" const char *monte_monitor_get_startup_command(void) {
|
||||
Trick::add_external_application(*externalApplication);
|
||||
}
|
||||
|
||||
return externalApplication->get_startup_command().c_str();
|
||||
return externalApplication->get_startup_command_c_str();
|
||||
}
|
||||
|
||||
extern "C" const char *stripchart_get_startup_command(void) {
|
||||
@ -258,7 +258,7 @@ extern "C" const char *stripchart_get_startup_command(void) {
|
||||
Trick::add_external_application(*externalApplication);
|
||||
}
|
||||
|
||||
return externalApplication->get_startup_command().c_str();
|
||||
return externalApplication->get_startup_command_c_str();
|
||||
}
|
||||
|
||||
extern "C" void sim_control_panel_launch(void) {
|
||||
|
@ -52,12 +52,13 @@ int strcmp_IgnoringWhiteSpace(const char* s1, const char* s2) {
|
||||
TEST_F(MM_write_checkpoint, string_singleton) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
std::string *string_p = (std::string*)memmgr->declare_var("std::string string_singleton");
|
||||
*string_p = "string_singleton_test";
|
||||
|
||||
memmgr->write_checkpoint( ss, "string_singleton");
|
||||
|
||||
s = ss.str();
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
"std::string string_singleton;"
|
||||
@ -65,7 +66,7 @@ TEST_F(MM_write_checkpoint, string_singleton) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"string_singleton = \"string_singleton_test\";"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -74,11 +75,13 @@ TEST_F(MM_write_checkpoint, string_singleton) {
|
||||
TEST_F(MM_write_checkpoint, dbl_singleton) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double *dbl_p = (double*)memmgr->declare_var("double dbl_singleton");
|
||||
*dbl_p = 3.1415;
|
||||
|
||||
memmgr->write_checkpoint( ss, "dbl_singleton");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -87,7 +90,7 @@ TEST_F(MM_write_checkpoint, dbl_singleton) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"dbl_singleton = 3.1415;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -97,12 +100,14 @@ TEST_F(MM_write_checkpoint, dbl_singleton) {
|
||||
TEST_F(MM_write_checkpoint, bool_singleton) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
bool *bool_p = (bool*)memmgr->declare_var("bool bool_singleton");
|
||||
*bool_p = true;
|
||||
|
||||
//memmgr->write_checkpoint( std::cout, "bool_singleton");
|
||||
memmgr->write_checkpoint( ss, "bool_singleton");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -111,7 +116,7 @@ TEST_F(MM_write_checkpoint, bool_singleton) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"bool_singleton = true;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -120,6 +125,7 @@ TEST_F(MM_write_checkpoint, bool_singleton) {
|
||||
TEST_F(MM_write_checkpoint, dbl_pointer) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double **dbl_pp = (double**)memmgr->declare_var("double *dbl_pointer");
|
||||
double *dbl_p = (double*)memmgr->declare_var("double dbl_array[2]");
|
||||
@ -129,6 +135,7 @@ TEST_F(MM_write_checkpoint, dbl_pointer) {
|
||||
dbl_p[1] = 2.0;
|
||||
|
||||
memmgr->write_checkpoint( ss, "dbl_pointer");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -139,7 +146,7 @@ TEST_F(MM_write_checkpoint, dbl_pointer) {
|
||||
"// Variable Assignments."
|
||||
"dbl_pointer = &dbl_array[0];"
|
||||
"dbl_array = {1, 2};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -148,6 +155,7 @@ TEST_F(MM_write_checkpoint, dbl_pointer) {
|
||||
TEST_F(MM_write_checkpoint, bool_pointer) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
bool **bool_pp = (bool**)memmgr->declare_var("bool *bool_pointer");
|
||||
bool *bool_p = (bool*)memmgr->declare_var("bool bool_array[2]");
|
||||
@ -157,6 +165,7 @@ TEST_F(MM_write_checkpoint, bool_pointer) {
|
||||
bool_p[1] = false;
|
||||
|
||||
memmgr->write_checkpoint( ss, "bool_pointer");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -167,7 +176,7 @@ TEST_F(MM_write_checkpoint, bool_pointer) {
|
||||
"// Variable Assignments."
|
||||
"bool_pointer = &bool_array[0];"
|
||||
"bool_array = {true, false};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -176,6 +185,7 @@ TEST_F(MM_write_checkpoint, bool_pointer) {
|
||||
TEST_F(MM_write_checkpoint, dbl_array) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double *dbl_p = (double*)memmgr->declare_var("double dbl_array[3]");
|
||||
|
||||
@ -184,6 +194,7 @@ TEST_F(MM_write_checkpoint, dbl_array) {
|
||||
dbl_p[2] = 3.3;
|
||||
|
||||
memmgr->write_checkpoint( ss, "dbl_array");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -193,7 +204,7 @@ TEST_F(MM_write_checkpoint, dbl_array) {
|
||||
"// Variable Assignments."
|
||||
"dbl_array = "
|
||||
" {1.1, 2.2, 3.3};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -202,6 +213,7 @@ TEST_F(MM_write_checkpoint, dbl_array) {
|
||||
TEST_F(MM_write_checkpoint, dbl_array_expanded) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double *dbl_p = (double*)memmgr->declare_var("double dbl_array[3]");
|
||||
|
||||
@ -211,6 +223,7 @@ TEST_F(MM_write_checkpoint, dbl_array_expanded) {
|
||||
|
||||
memmgr->set_expanded_arrays(true);
|
||||
memmgr->write_checkpoint( ss, "dbl_array");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -222,7 +235,7 @@ TEST_F(MM_write_checkpoint, dbl_array_expanded) {
|
||||
"dbl_array[1] = 2.2;"
|
||||
"dbl_array[2] = 3.3;"
|
||||
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -231,6 +244,7 @@ TEST_F(MM_write_checkpoint, dbl_array_expanded) {
|
||||
TEST_F(MM_write_checkpoint, dbl_array_pointers) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double **dbl_pa = (double**)memmgr->declare_var("double *dbl_array_ptrs[3]");
|
||||
|
||||
@ -244,6 +258,8 @@ TEST_F(MM_write_checkpoint, dbl_array_pointers) {
|
||||
|
||||
memmgr->write_checkpoint( ss, "dbl_array_ptrs");
|
||||
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
"double* dbl_array_ptrs[3];"
|
||||
@ -255,7 +271,7 @@ TEST_F(MM_write_checkpoint, dbl_array_pointers) {
|
||||
"// Variable Assignments."
|
||||
"dbl_array_ptrs = "
|
||||
" {&dbl1, &dbl2, &dbl3};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -264,6 +280,7 @@ TEST_F(MM_write_checkpoint, dbl_array_pointers) {
|
||||
TEST_F(MM_write_checkpoint, dbl_array_pointers_expanded) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double **dbl_pa = (double**)memmgr->declare_var("double *dbl_array_ptrs[3]");
|
||||
|
||||
@ -277,6 +294,7 @@ TEST_F(MM_write_checkpoint, dbl_array_pointers_expanded) {
|
||||
|
||||
memmgr->set_expanded_arrays(true);
|
||||
memmgr->write_checkpoint( ss, "dbl_array_ptrs");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -290,7 +308,7 @@ TEST_F(MM_write_checkpoint, dbl_array_pointers_expanded) {
|
||||
"dbl_array_ptrs[0] = &dbl1;"
|
||||
"dbl_array_ptrs[1] = &dbl2;"
|
||||
"dbl_array_ptrs[2] = &dbl3;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -299,6 +317,7 @@ TEST_F(MM_write_checkpoint, dbl_array_pointers_expanded) {
|
||||
TEST_F(MM_write_checkpoint, dbl_2d_constrained_array) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double (*A)[3][4] = (double(*)[3][4])memmgr->declare_var("double A[3][4]");
|
||||
|
||||
@ -316,6 +335,7 @@ TEST_F(MM_write_checkpoint, dbl_2d_constrained_array) {
|
||||
(*A)[2][3] = 23.0;
|
||||
|
||||
memmgr->write_checkpoint( ss, "A");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -329,7 +349,7 @@ TEST_F(MM_write_checkpoint, dbl_2d_constrained_array) {
|
||||
" {10, 11, 12, 13},"
|
||||
" {20, 21, 22, 23}"
|
||||
" };"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -338,6 +358,7 @@ TEST_F(MM_write_checkpoint, dbl_2d_constrained_array) {
|
||||
TEST_F(MM_write_checkpoint, dbl_2d_constrained_array_expanded) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
double (*A)[3][4] = (double(*)[3][4])memmgr->declare_var("double A[3][4]");
|
||||
|
||||
@ -356,6 +377,7 @@ TEST_F(MM_write_checkpoint, dbl_2d_constrained_array_expanded) {
|
||||
|
||||
memmgr->set_expanded_arrays(true);
|
||||
memmgr->write_checkpoint( ss, "A");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -374,7 +396,7 @@ TEST_F(MM_write_checkpoint, dbl_2d_constrained_array_expanded) {
|
||||
"A[2][1] = 21;"
|
||||
"A[2][2] = 22;"
|
||||
"A[2][3] = 23;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -383,6 +405,7 @@ TEST_F(MM_write_checkpoint, dbl_2d_constrained_array_expanded) {
|
||||
TEST_F(MM_write_checkpoint, enum_singleton) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
// memmgr->set_debug_level(2);
|
||||
|
||||
@ -390,6 +413,7 @@ TEST_F(MM_write_checkpoint, enum_singleton) {
|
||||
*enum_p = FEBRUARY;
|
||||
|
||||
memmgr->write_checkpoint( ss, "enum_singleton");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -398,7 +422,7 @@ TEST_F(MM_write_checkpoint, enum_singleton) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"enum_singleton = FEBRUARY;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -407,6 +431,7 @@ TEST_F(MM_write_checkpoint, enum_singleton) {
|
||||
TEST_F(MM_write_checkpoint, enum_pointer) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
MONTH **enum_pp = (MONTH**)memmgr->declare_var("MONTH *enum_pointer");
|
||||
MONTH *enum_p = (MONTH*)memmgr->declare_var("MONTH enum_array[2]");
|
||||
@ -416,6 +441,7 @@ TEST_F(MM_write_checkpoint, enum_pointer) {
|
||||
enum_p[1] = APRIL;
|
||||
|
||||
memmgr->write_checkpoint( ss, "enum_pointer");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -427,7 +453,7 @@ TEST_F(MM_write_checkpoint, enum_pointer) {
|
||||
"enum_pointer = &enum_array[0];"
|
||||
"enum_array = "
|
||||
" {MARCH, APRIL};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -436,6 +462,7 @@ TEST_F(MM_write_checkpoint, enum_pointer) {
|
||||
TEST_F(MM_write_checkpoint, enum_array) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
MONTH *enum_p = (MONTH*)memmgr->declare_var("MONTH enum_array[3]");
|
||||
|
||||
@ -444,6 +471,7 @@ TEST_F(MM_write_checkpoint, enum_array) {
|
||||
enum_p[2] = AUGUST;
|
||||
|
||||
memmgr->write_checkpoint( ss, "enum_array");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -453,7 +481,7 @@ TEST_F(MM_write_checkpoint, enum_array) {
|
||||
"// Variable Assignments."
|
||||
"enum_array = "
|
||||
" {JUNE, JULY, AUGUST};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -462,6 +490,7 @@ TEST_F(MM_write_checkpoint, enum_array) {
|
||||
TEST_F(MM_write_checkpoint, enum_array_pointers) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
MONTH **enum_pa = (MONTH**)memmgr->declare_var("MONTH *enum_array_ptrs[3]");
|
||||
|
||||
@ -474,6 +503,7 @@ TEST_F(MM_write_checkpoint, enum_array_pointers) {
|
||||
enum_pa[2] = enum_p3;
|
||||
|
||||
memmgr->write_checkpoint( ss, "enum_array_ptrs");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -486,7 +516,7 @@ TEST_F(MM_write_checkpoint, enum_array_pointers) {
|
||||
"// Variable Assignments."
|
||||
"enum_array_ptrs = "
|
||||
" {&enum1, &enum2, &enum3};"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -495,6 +525,7 @@ TEST_F(MM_write_checkpoint, enum_array_pointers) {
|
||||
TEST_F(MM_write_checkpoint, udt_singleton_no_deps) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *udt_p = (UDT1*)memmgr->declare_var("UDT1 udt_singleton");
|
||||
|
||||
@ -503,6 +534,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_no_deps) {
|
||||
udt_p->dbl_p = NULL;
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt_singleton");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -511,7 +543,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_no_deps) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"udt_singleton.x = 3.1415;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -520,6 +552,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_no_deps) {
|
||||
TEST_F(MM_write_checkpoint, udt_singleton_self_referential) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *udt_p = (UDT1*)memmgr->declare_var("UDT1 udt_singleton");
|
||||
|
||||
@ -528,6 +561,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_self_referential) {
|
||||
udt_p->dbl_p = NULL;
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt_singleton");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -537,7 +571,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_self_referential) {
|
||||
"// Variable Assignments."
|
||||
"udt_singleton.x = 3.1415;"
|
||||
"udt_singleton.udt_p = &udt_singleton.x;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -546,6 +580,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_self_referential) {
|
||||
TEST_F(MM_write_checkpoint, udt_singleton_deps) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *udt1_p = (UDT1*)memmgr->declare_var("UDT1 udt1");
|
||||
UDT1 *udt2_p = (UDT1*)memmgr->declare_var("UDT1 udt2");
|
||||
@ -556,6 +591,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_deps) {
|
||||
udt1_p->dbl_p = dbl1_p;
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt1");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
""
|
||||
@ -569,7 +605,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_deps) {
|
||||
"udt1.x = 3.1415;"
|
||||
"udt1.udt_p = &udt2.x;"
|
||||
"udt1.dbl_p = &dbl1;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -578,6 +614,7 @@ TEST_F(MM_write_checkpoint, udt_singleton_deps) {
|
||||
TEST_F(MM_write_checkpoint, udt_pointer) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 **udt1_p = (UDT1**)memmgr->declare_var("UDT1 *udt_p");
|
||||
UDT1 *a1 = (UDT1 *)memmgr->declare_var("UDT1 bbb");
|
||||
@ -588,6 +625,7 @@ TEST_F(MM_write_checkpoint, udt_pointer) {
|
||||
*udt1_p = a1;
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt_p");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -598,7 +636,7 @@ TEST_F(MM_write_checkpoint, udt_pointer) {
|
||||
"// Variable Assignments."
|
||||
"udt_p = &bbb;"
|
||||
"bbb.x = 3.1415;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -607,6 +645,7 @@ TEST_F(MM_write_checkpoint, udt_pointer) {
|
||||
TEST_F(MM_write_checkpoint, udt_array_no_deps) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *udt_p = (UDT1*)memmgr->declare_var("UDT1 udt_array[3]");
|
||||
|
||||
@ -623,6 +662,7 @@ TEST_F(MM_write_checkpoint, udt_array_no_deps) {
|
||||
udt_p[2].dbl_p = NULL;
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt_array");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -633,7 +673,7 @@ TEST_F(MM_write_checkpoint, udt_array_no_deps) {
|
||||
"udt_array[0].x = 3.1415;"
|
||||
"udt_array[1].x = 3.1415;"
|
||||
"udt_array[2].x = 3.1415;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -642,6 +682,7 @@ TEST_F(MM_write_checkpoint, udt_array_no_deps) {
|
||||
TEST_F(MM_write_checkpoint, udt_array_deps) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *udt_p = (UDT1*)memmgr->declare_var("UDT1 udt_array[3]");
|
||||
UDT1 *udt1_p = (UDT1*)memmgr->declare_var("UDT1 udt1");
|
||||
@ -664,6 +705,7 @@ TEST_F(MM_write_checkpoint, udt_array_deps) {
|
||||
udt_p[2].dbl_p = dbl3_p;
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt_array");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -686,7 +728,7 @@ TEST_F(MM_write_checkpoint, udt_array_deps) {
|
||||
"udt_array[2].x = 3.1415;"
|
||||
"udt_array[2].udt_p = &udt3.x;"
|
||||
"udt_array[2].dbl_p = &dbl3;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -695,6 +737,7 @@ TEST_F(MM_write_checkpoint, udt_array_deps) {
|
||||
TEST_F(MM_write_checkpoint, vector_of_named_vars) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
std::vector<const char*> name_list;
|
||||
|
||||
UDT1 *a1 = (UDT1 *)memmgr->declare_var("UDT1 A1");
|
||||
@ -718,6 +761,7 @@ TEST_F(MM_write_checkpoint, vector_of_named_vars) {
|
||||
name_list.push_back("A2");
|
||||
|
||||
memmgr->write_checkpoint( ss, name_list);
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -738,13 +782,14 @@ TEST_F(MM_write_checkpoint, vector_of_named_vars) {
|
||||
"A2.udt_p = &A4.x;"
|
||||
"A2.dbl_p = &dbl_2;"
|
||||
"dbl_2 = 3.1415;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
|
||||
TEST_F(MM_write_checkpoint, reference_to_unknown_member) {
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *a1 = (UDT1 *)memmgr->declare_var("UDT1 A1");
|
||||
UDT2 *a2 = (UDT2 *)memmgr->declare_var("UDT2 A2");
|
||||
@ -752,6 +797,7 @@ TEST_F(MM_write_checkpoint, reference_to_unknown_member) {
|
||||
a1->dbl_p = &(a2->starStarDbl);
|
||||
|
||||
memmgr->write_checkpoint(ss,"A1");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -761,13 +807,14 @@ TEST_F(MM_write_checkpoint, reference_to_unknown_member) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"A1.dbl_p = &A2 + 8;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
|
||||
TEST_F(MM_write_checkpoint, reference_to_unknown_member_in_array) {
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT1 *a1 = (UDT1 *)memmgr->declare_var("UDT1 A1");
|
||||
UDT2 *a2 = (UDT2 *)memmgr->declare_var("UDT2 A2[2]");
|
||||
@ -775,6 +822,7 @@ TEST_F(MM_write_checkpoint, reference_to_unknown_member_in_array) {
|
||||
a1->dbl_p = &(a2[1].starStarDbl);
|
||||
|
||||
memmgr->write_checkpoint(ss, "A1");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -784,13 +832,14 @@ TEST_F(MM_write_checkpoint, reference_to_unknown_member_in_array) {
|
||||
"clear_all_vars();"
|
||||
"// Variable Assignments."
|
||||
"A1.dbl_p = &A2[1] + 8;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
|
||||
TEST_F(MM_write_checkpoint, 1d_array_of_structures) {
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT3 (*a)[3] = (UDT3(*)[3])memmgr->declare_var("UDT3 A[3]");
|
||||
|
||||
@ -802,6 +851,7 @@ TEST_F(MM_write_checkpoint, 1d_array_of_structures) {
|
||||
(*a)[2].b = 6 ;
|
||||
|
||||
memmgr->write_checkpoint(ss, "A");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -815,13 +865,14 @@ TEST_F(MM_write_checkpoint, 1d_array_of_structures) {
|
||||
"A[1].b = 4;"
|
||||
"A[2].a = 5;"
|
||||
"A[2].b = 6;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
|
||||
TEST_F(MM_write_checkpoint, 2d_array_of_structures) {
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT3 (*a)[2][3] = (UDT3(*)[2][3])memmgr->declare_var("UDT3 A[2][3]");
|
||||
|
||||
@ -839,6 +890,7 @@ TEST_F(MM_write_checkpoint, 2d_array_of_structures) {
|
||||
(*a)[1][2].b = 12 ;
|
||||
|
||||
memmgr->write_checkpoint(ss, "A");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -858,7 +910,7 @@ TEST_F(MM_write_checkpoint, 2d_array_of_structures) {
|
||||
"A[1][1].b = 10;"
|
||||
"A[1][2].a = 11;"
|
||||
"A[1][2].b = 12;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -866,6 +918,7 @@ TEST_F(MM_write_checkpoint, 2d_array_of_structures) {
|
||||
TEST_F(MM_write_checkpoint, io_test ) {
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT5 *udt5_p = (UDT5*)memmgr->declare_var("UDT5 udt5");
|
||||
udt5_p->star_star = 3.0;
|
||||
@ -875,6 +928,7 @@ TEST_F(MM_write_checkpoint, io_test ) {
|
||||
|
||||
memmgr->write_checkpoint( ss, "udt5");
|
||||
memmgr->write_checkpoint( std::cout, "udt5");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -884,7 +938,7 @@ TEST_F(MM_write_checkpoint, io_test ) {
|
||||
"// Variable Assignments."
|
||||
"/*OUTPUT-ONLY: udt5.star_eau = 8;*/"
|
||||
"udt5.star_aye_eau = 13;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -897,6 +951,7 @@ TEST_F(MM_write_checkpoint, Compressed_2d_char_arrays ) {
|
||||
// it can be written as a quoted string.
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
UDT6 *udt6_p = (UDT6*)memmgr->declare_var("UDT6 udt6");
|
||||
|
||||
@ -913,6 +968,7 @@ TEST_F(MM_write_checkpoint, Compressed_2d_char_arrays ) {
|
||||
}
|
||||
memmgr->set_expanded_arrays(false);
|
||||
memmgr->write_checkpoint( ss, "udt6");
|
||||
s = ss.str();
|
||||
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
"// Variable Declarations."
|
||||
@ -954,7 +1010,7 @@ TEST_F(MM_write_checkpoint, Compressed_2d_char_arrays ) {
|
||||
"\"BGI\",\"BGJ\",\"BGK\",\"BGL\",\"BGM\",\"BGN\",\"BGO\",\"BGP\","
|
||||
"\"BHA\",\"BHB\",\"BHC\",\"BHD\",\"BHE\",\"BHF\",\"BHG\",\"BHH\","
|
||||
"\"BHI\",\"BHJ\",\"BHK\",\"BHL\",\"BHM\",\"BHN\",\"BHO\",\"BHP\" };"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -969,6 +1025,7 @@ TEST_F(MM_write_checkpoint, ptr_to_array_of_ptrs_to_objects ) {
|
||||
// check-pointed.
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
|
||||
// Allocate object with a double ptr member, that is
|
||||
// a pointer to an array of pointers to some (3 in this case) objects.
|
||||
@ -991,6 +1048,7 @@ TEST_F(MM_write_checkpoint, ptr_to_array_of_ptrs_to_objects ) {
|
||||
memmgr->set_expanded_arrays(false);
|
||||
// Write the checkpoint.
|
||||
memmgr->write_checkpoint( ss, "udt7");
|
||||
s = ss.str();
|
||||
|
||||
// Verify it's what we expected.
|
||||
int result = strcmp_IgnoringWhiteSpace(
|
||||
@ -1014,7 +1072,7 @@ TEST_F(MM_write_checkpoint, ptr_to_array_of_ptrs_to_objects ) {
|
||||
"udt3B.b = 5;"
|
||||
"udt3C.a = 7;"
|
||||
"udt3C.b = 8;"
|
||||
, ss.str().c_str());
|
||||
, s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
|
||||
@ -1028,7 +1086,7 @@ TEST_F(MM_write_checkpoint, ptr_to_array_of_ptrs_to_objects ) {
|
||||
pp = (UDT3**)NULL;
|
||||
|
||||
// Re-create the objects from a checkpoint.
|
||||
memmgr->read_checkpoint_from_string(ss.str().c_str());
|
||||
memmgr->read_checkpoint_from_string(s.c_str());
|
||||
|
||||
EXPECT_EQ(result, 0);
|
||||
|
||||
|
@ -99,7 +99,7 @@ extern "C" void mc_set_user_cmd_string(const char *user_cmd_string) {
|
||||
|
||||
extern "C" const char *mc_get_user_cmd_string(void) {
|
||||
if ( the_mc != NULL ) {
|
||||
return the_mc->get_user_cmd_string().c_str();
|
||||
return the_mc->get_user_cmd_string_c_str();
|
||||
}
|
||||
return NULL ;
|
||||
}
|
||||
@ -131,7 +131,7 @@ extern "C" void mc_set_custom_pre_text(const char *custom_pre_text) {
|
||||
|
||||
extern "C" const char *mc_get_custom_pre_text(void) {
|
||||
if ( the_mc != NULL ) {
|
||||
return the_mc->get_custom_pre_text().c_str();
|
||||
return the_mc->get_custom_pre_text_c_str();
|
||||
}
|
||||
return NULL ;
|
||||
}
|
||||
@ -144,7 +144,7 @@ extern "C" void mc_set_custom_post_text(const char *custom_post_text) {
|
||||
|
||||
extern "C" const char *mc_get_custom_post_text(void) {
|
||||
if ( the_mc != NULL ) {
|
||||
return the_mc->get_custom_post_text().c_str();
|
||||
return the_mc->get_custom_post_text_c_str();
|
||||
}
|
||||
return NULL ;
|
||||
}
|
||||
|
@ -81,6 +81,10 @@ std::string Trick::MonteCarlo::get_user_cmd_string() {
|
||||
return user_cmd_string;
|
||||
}
|
||||
|
||||
const char* Trick::MonteCarlo::get_user_cmd_string_c_str() {
|
||||
return user_cmd_string.c_str();
|
||||
}
|
||||
|
||||
void Trick::MonteCarlo::set_custom_pre_text(std::string in_custom_pre_text) {
|
||||
this->custom_pre_text = in_custom_pre_text;
|
||||
}
|
||||
@ -89,6 +93,10 @@ std::string Trick::MonteCarlo::get_custom_pre_text() {
|
||||
return custom_pre_text;
|
||||
}
|
||||
|
||||
const char* Trick::MonteCarlo::get_custom_pre_text_c_str() {
|
||||
return custom_pre_text.c_str();
|
||||
}
|
||||
|
||||
void Trick::MonteCarlo::set_custom_post_text(std::string in_custom_post_text) {
|
||||
this->custom_post_text = in_custom_post_text;
|
||||
}
|
||||
@ -97,6 +105,10 @@ std::string Trick::MonteCarlo::get_custom_post_text() {
|
||||
return custom_post_text;
|
||||
}
|
||||
|
||||
const char* Trick::MonteCarlo::get_custom_post_text_c_str() {
|
||||
return custom_post_text.c_str();
|
||||
}
|
||||
|
||||
void Trick::MonteCarlo::set_verbosity(Trick::MonteCarlo::Verbosity in_verbosity) {
|
||||
this->verbosity = in_verbosity;
|
||||
}
|
||||
|
@ -71,12 +71,14 @@ PyObject * attach_units(PyObject * in_units_obj , PyObject * in_object) {
|
||||
if ( temp_m->units.compare("1") ) {
|
||||
ut_unit * from = ut_parse(Trick::UdUnits::get_u_system(), temp_m->units.c_str(), UT_ASCII) ;
|
||||
if ( !from ) {
|
||||
PyErr_SetString(PyExc_AttributeError,(std::string("could not covert from units "+temp_m->units).c_str()));
|
||||
std::string temp_str = std::string("could not covert from units "+temp_m->units);
|
||||
PyErr_SetString(PyExc_AttributeError,(temp_str.c_str()));
|
||||
return NULL ;
|
||||
}
|
||||
ut_unit * to = ut_parse(Trick::UdUnits::get_u_system(), in_units.c_str(), UT_ASCII) ;
|
||||
if ( !to ) {
|
||||
PyErr_SetString(PyExc_AttributeError,(std::string("could not covert to units "+in_units).c_str()));
|
||||
std::string temp_str = std::string("could not covert to units " + in_units);
|
||||
PyErr_SetString(PyExc_AttributeError,(temp_str.c_str()));
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
@ -100,12 +102,14 @@ PyObject * attach_units(PyObject * in_units_obj , PyObject * in_object) {
|
||||
if ( temp_m->units.compare("1") ) {
|
||||
ut_unit * from = ut_parse(Trick::UdUnits::get_u_system(), temp_m->units.c_str(), UT_ASCII) ;
|
||||
if ( !from ) {
|
||||
PyErr_SetString(PyExc_AttributeError,(std::string("could not covert from units "+temp_m->units).c_str()));
|
||||
std::string temp_str = std::string("could not covert from units "+temp_m->units);
|
||||
PyErr_SetString(PyExc_AttributeError,(temp_str.c_str())) ;
|
||||
return NULL ;
|
||||
}
|
||||
ut_unit * to = ut_parse(Trick::UdUnits::get_u_system(), in_units.c_str(), UT_ASCII) ;
|
||||
if ( !to ) {
|
||||
PyErr_SetString(PyExc_AttributeError,(std::string("could not covert to units "+in_units).c_str()));
|
||||
std::string temp_str = std::string("could not covert to units "+in_units);
|
||||
PyErr_SetString(PyExc_AttributeError,(temp_str.c_str()));
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user