Merge pull request #210 from alexlin0/master

Merge STL checkpoint work
This commit is contained in:
Alex Lin 2016-04-01 08:18:37 -05:00
commit 617efa3a52
97 changed files with 2877 additions and 6447 deletions

View File

@ -332,24 +332,6 @@ namespace Trick {
*/
virtual int load_default_data() ;
/**
* Our own pre_checkpoint job to save off our STLs
* @return always 0
*/
virtual int pre_checkpoint() ;
/**
* Our own pre_checkpoint job to remove extra memory when checkpoining STLs
* @return always 0
*/
virtual int post_checkpoint() ;
/**
* Our own restart job to restore STLs
* @return always 0
*/
virtual int restart() ;
// Removed all doxygen documents for functions that have documents in the parent class since
// Doxygen inherits the documents from the parent class automatically.

View File

@ -43,7 +43,7 @@ namespace Trick {
std::string splitFilename( const std::string& str );
unsigned int dmtcp_ckpt_complete;
std::priority_queue<std::string> dmtcp_checkpoint_jobs_queue ;
std::priority_queue<std::string> dmtcp_checkpoint_jobs_queue ; // ** ignore this for checkpointing
virtual int write_s_job_execution( FILE * fp ) ;
virtual int instrument_job_before(Trick::JobData * instrument_job) ;

View File

@ -94,7 +94,7 @@ namespace Trick {
char ** variable_alias ; /** trick_units(--) */
/** Vector of buffers - one for every variable added with Trick::DataRecordGroup::add_variable.\n */
std::vector <Trick::DataRecordBuffer *> rec_buffer; /**< trick_io(*io) trick_units(--) */
std::vector <Trick::DataRecordBuffer *> rec_buffer; /**< trick_io(**) trick_units(--) */
/** Number of change variable names to save in a checkpoint.\n */
unsigned int num_change_variable_names ; /** trick_units(--) */
@ -104,7 +104,7 @@ namespace Trick {
char ** change_variable_alias ; /** trick_units(--) */
/** Vector of buffers - one for every change variable added with Trick::DataRecordGroup::add_change_variable.\n */
std::vector <Trick::DataRecordBuffer *> change_buffer; /**< trick_io(*io) trick_units(--) */
std::vector <Trick::DataRecordBuffer *> change_buffer; /**< trick_io(**) trick_units(--) */
/** Maximum records to hold in memory before writing.\n */
unsigned int max_num; /**< trick_io(*io) trick_units(--) */

View File

@ -149,10 +149,10 @@ namespace Trick {
unsigned int num_active_events ; /**< trick_io(*io) trick_units(--) */
/** All of the event processors, one per thread. */
std::vector< Trick::EventProcessor * > event_processors ;
std::vector< Trick::EventProcessor * > event_processors ; /**< trick_io(**) */
/** All of the events that have been attached to jobs */
std::vector< Trick::EventInstrument * > events_instrumented ;
std::vector< Trick::EventInstrument * > events_instrumented ; /**< trick_io(**) */
/**
@brief Add user's event to manager's list of events; don't add it if it's already in list.

View File

@ -244,13 +244,7 @@ namespace Trick {
int num_sim_objects ; /**< trick_units(--) */
/** List of all sim_objects that have been added to scheduler through add_sim_object().\n */
std::vector <Trick::SimObject *> sim_objects ; /**< trick_io(**) */
/** Count of how many sim_objects are written to the checkpoint.\n */
int num_sim_objects_in_checkpoint ; /**< trick_units(--) */
/** Contains same info as the sim_objects vector but in a checkpointable form\n */
Trick::SimObject ** sim_objects_for_checkpoint ; /**< trick_units(--) */
std::vector <Trick::SimObject *> sim_objects ; /**< trick_io(*io) trick_units(--) */
/** List of other schedulers in thes sim.\n */
std::vector <Trick::Scheduler *> other_schedulers ; /**< trick_io(**) */

View File

@ -56,7 +56,7 @@ namespace Trick {
unsigned int thread_id ;
/** Jobs this group is recording */
std::vector< Trick::JobData *> rec_jobs ;
std::vector< Trick::JobData *> rec_jobs ; // trick_io(**)
/** Time value to record with main frame. The main frame has already incremented time by the time
data record is called. We need to record the time of the previous frame. */

View File

@ -37,7 +37,7 @@ namespace Trick {
bool frame_log_flag ; /**< trick_io(*io) trick_units(--) */
/** Data recording groups for logging user jobs.\n */
std::vector< Trick::FrameDataRecordGroup *> drg_users ; /**< trick_io(*io) trick_units(--) */
std::vector< Trick::FrameDataRecordGroup *> drg_users ; /**< trick_io(**) trick_units(--) */
/** Data recording group for logging trick jobs.\n */
Trick::FrameDataRecordGroup * drg_trick; /**< trick_io(*io) trick_units(--) */
/** Data recording group for logging frame/overrun time.\n trick_units(--) */

View File

@ -107,7 +107,7 @@ namespace Trick {
* The sim objects integrated by this IntegLoopScheduler.
* This is public so it can be checkpointed and restored.
*/
SimObjectVector sim_objects; //!< trick_io(**)
SimObjectVector sim_objects; //!< trick_io(*io) trick_units(--)
// Member functions

View File

@ -1,3 +1,7 @@
/*
PURPOSE:
(Trick Integration sim object)
*/
#ifndef INTEG_LOOP_SIMOBJECT_HH
#define INTEG_LOOP_SIMOBJECT_HH
@ -15,7 +19,7 @@
class IntegLoopSimObject : public Trick::SimObject {
public:
Trick::IntegLoopScheduler integ_sched ;
Trick::IntegLoopScheduler integ_sched ; // trick_io(*io)
IntegLoopSimObject() : integ_sched(0.01, this) {
add_jobs(0.01, 0) ;
@ -41,7 +45,6 @@ class IntegLoopSimObject : public Trick::SimObject {
virtual int call_function( Trick::JobData * curr_job ) ;
virtual double call_function_double( Trick::JobData * curr_job ) ;
Trick::Integrator * getIntegrator( Integrator_type Alg, unsigned int State_size ) {
return integ_sched.getIntegrator(Alg , State_size) ;
}

View File

@ -203,7 +203,7 @@ namespace Trick {
int num_slaves ; /**< trick_units(--) */
/** Vector of slaves tracked by the master.\n */
std::vector< Trick::SlaveInfo * > slaves ; /**< trick_units(--) */
std::vector< Trick::SlaveInfo * > slaves ; /**< trick_io(**) trick_units(--) */
/**
@brief @userdesc Command to enable the master/slave synchronization.

View File

@ -1,3 +1,8 @@
/*
PURPOSE:
(Memory Manager.)
*/
#ifndef MEMORYMANAGEMENT_HH
#define MEMORYMANAGEMENT_HH
@ -547,6 +552,14 @@ namespace Trick {
*/
int set_name_at( void* addr, const char * name);
/**
Adds a name of an allocation to the dependency list of allocations that are to be checkpointed.
This call is used by standard template library functions that create new allocations and
dependencies during the checkpoint process.
@param name The name of the allocation.
*/
void add_checkpoint_alloc_dependency(const char * name);
/**
Opens a handle to the shared library file. The handles are used to look for io_src functions.
@param name The name of the file to open.
@ -654,37 +667,61 @@ namespace Trick {
bool hexfloat_checkpoint; /**< -- true = Represent floating point values as hexidecimal to preserve precision. false= Normal. */
bool expanded_arrays; /**< -- true = array element values are set in separate assignments. */
ALLOC_INFO_MAP alloc_info_map; /**< -- Map of <address, ALLOC_INFO*> key-value pairs for each of the managed allocations. */
VARIABLE_MAP variable_map; /**< -- Map of <name, ALLOC_INFO*> key-value pairs for each named-allocations. */
ENUMERATION_MAP enumeration_map; /**< -- Enumeration map. */
pthread_mutex_t mm_mutex; /**< -- Mutex to control access to memory manager maps */
ALLOC_INFO_MAP alloc_info_map; /**< ** Map of <address, ALLOC_INFO*> key-value pairs for each of the managed allocations. */
VARIABLE_MAP variable_map; /**< ** Map of <name, ALLOC_INFO*> key-value pairs for each named-allocations. */
ENUMERATION_MAP enumeration_map; /**< ** Enumeration map. */
pthread_mutex_t mm_mutex; /**< ** Mutex to control access to memory manager maps */
int alloc_info_map_counter ; /**< ** counter to assign unique ids to allocations as they are added to map */
int extern_alloc_info_map_counter ; /**< ** counter to assign unique ids to allocations as they are added to map */
std::vector<ALLOC_INFO*> dependencies; /**< ** list of allocations used in a checkpoint. */
std::vector<ALLOC_INFO*> stl_dependencies; /**< ** list of allocations known to be STL checkpoint allocations */
void write_checkpoint( std::ostream& out_s, std::vector<ALLOC_INFO*>& dependencies);
void execute_checkpoint( std::ostream& out_s );
/**
Walks through allocation and allocates space for STLs
FIXME: I NEED DOCUMENTATION!
*/
void get_stl_dependencies( ALLOC_INFO* alloc_info );
void get_stl_dependencies_in_class( std::string name, char* address, ATTRIBUTES* attr) ;
void get_stl_dependencies_in_arrayed_class( std::string name,
char* address, ATTRIBUTES* attr, int curr_dim, int offset) ;
void get_stl_dependencies_in_intrinsic( std::string name,
void* address, ATTRIBUTES* attr, int curr_dim, int offset) ;
/**
Walks through allocations and restores STLs
FIXME: I NEED DOCUMENTATION!
*/
void restore_stls( ALLOC_INFO* alloc_info );
void restore_stls_in_class( std::string name, char* address, ATTRIBUTES* attr) ;
void restore_stls_in_arrayed_class( std::string name,
char* address, ATTRIBUTES* attr, int curr_dim, int offset) ;
void restore_stls_in_intrinsic( std::string name,
void* address, ATTRIBUTES* attr, int curr_dim, int offset) ;
/**
FIXME: I NEED DOCUMENTATION!
*/
void get_alloc_deps_in_allocation(std::vector<ALLOC_INFO*>& dependencies, ALLOC_INFO* alloc_info );
void get_alloc_deps_in_allocation( ALLOC_INFO* alloc_info );
/**
FIXME: I NEED DOCUMENTATION!
*/
void get_alloc_deps_in_allocation( std::vector<ALLOC_INFO*>& dependencies, const char* var_name );
void get_alloc_deps_in_allocation( const char* var_name );
/**
FIXME: I NEED DOCUMENTATION!
*/
void get_alloc_deps_in_class( std::vector<ALLOC_INFO*>& dependencies, char* address, ATTRIBUTES* attr);
void get_alloc_deps_in_class( char* address, ATTRIBUTES* attr);
/**
FIXME: I NEED DOCUMENTATION!
*/
void get_alloc_deps_in_arrayed_class( std::vector<ALLOC_INFO*>& dependencies, char* address, ATTRIBUTES* attr, int curr_dim, int offset);
void get_alloc_deps_in_arrayed_class( char* address, ATTRIBUTES* attr, int curr_dim, int offset);
/**
FIXME: I NEED DOCUMENTATION!
*/
void get_alloc_deps_in_intrinsic( std::vector<ALLOC_INFO*>& dependencies, void* address, ATTRIBUTES* attr, int curr_dim, int offset);
void get_alloc_deps_in_intrinsic( void* address, ATTRIBUTES* attr, int curr_dim, int offset);
std::set< std::string > primitive_types ; /**< ** Names of primitive types. Used in add_attr_info */
std::map< std::string , std::string > template_name_map ; /**< ** Templates names => mangled attr names */

View File

@ -339,19 +339,19 @@ namespace Trick {
TCDevice data_connection_device; /**< \n trick_units(--) */
/** Runs to be dispatched. */
std::deque <Trick::MonteRun *> runs; /**< \n trick_units(--) */
std::deque <Trick::MonteRun *> runs; /**< \n trick_io(**) trick_units(--) */
/** Failed runs. */
std::deque <Trick::MonteRun *> failed_runs; /**< \n trick_units(--) */
std::deque <Trick::MonteRun *> failed_runs; /**< \n trick_io(**) trick_units(--) */
/** Valid ranges. */
std::vector <Trick::MonteRange *> run_ranges; /**< \n trick_units(--) */
std::vector <Trick::MonteRange *> run_ranges; /**< \n trick_io(**) trick_units(--) */
/** Variables. */
std::vector <Trick::MonteVar *> variables; /**< \n trick_units(--) */
std::vector <Trick::MonteVar *> variables; /**< \n trick_io(**) trick_units(--) */
/** Slaves. */
std::vector <Trick::MonteSlave *> slaves; /**< \n trick_units(--) */
std::vector <Trick::MonteSlave *> slaves; /**< \n trick_io(**) trick_units(--) */
/** Number of slaves. Exists for Variable Server access. */
int num_slaves; /**< \n trick_units(--) */

View File

@ -60,7 +60,7 @@ namespace Trick {
std::string file_name ; /**< trick_units(--) trick_io(*i) */
/** Keeps lists of test results keyed by test_suite name.\n*/
std::map< std::string , TestSuite > test_suites ;
std::map< std::string , TestSuite > test_suites ; // ** ignore
/**
@brief The constructor.

View File

@ -276,16 +276,16 @@ namespace Trick {
to this map by suspendPreCheckpointReload(). resumePostCheckpointReload() restores
the pause state from this map.
*/
std::map<pthread_t, bool> thread_pause_state_store;
std::map<pthread_t, bool> thread_pause_state_store; // ** ignore this
/** Map thread id to the VariableServerThread object.\n */
std::map < pthread_t , VariableServerThread * > var_server_threads ;
std::map < pthread_t , VariableServerThread * > var_server_threads ; /**< trick_io(**) */
/** Mutex to ensure only one thread manipulates the map of var_server_threads\n */
pthread_mutex_t map_mutex ; /**< trick_io(**) */
/** Map of additional listen threads created by create_tcp_socket.\n */
std::map < pthread_t , VariableServerListenThread * > additional_listen_threads ;
std::map < pthread_t , VariableServerListenThread * > additional_listen_threads ; /**< trick_io(**) */
} ;

View File

@ -119,6 +119,11 @@ typedef struct ATTRIBUTES_tag {
INDEX index[TRICK_MAX_INDEX]; /**< -- An array of array-index information or bit-field information.
Is only meaningful if num_index > 0 or if type is a bit field type. */
void (*checkpoint_stl)(void * start_address, const char * obj_name , const char * var_name) ;
void (*post_checkpoint_stl)(void * start_address, const char * obj_name , const char * var_name) ;
void (*restore_stl)(void * start_address, const char * obj_name , const char * var_name) ;
void (*clear_stl)(void * start_address) ;
} ATTRIBUTES;
typedef struct {

View File

@ -0,0 +1,305 @@
/*
PURPOSE: (Foward declare all the checkpoint_stl routines that are used in other template routines.)
*/
#ifndef CHECKPOINT_FWD_DECLARE
#define CHECKPOINT_FWD_DECLARE
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <utility>
#include <string>
#include <type_traits>
#include "checkpoint_is_stl_container.hh"
// This file declares all of the variants of the checkpoint_stl function.
// Many of the checkpoint_stl templates are recursive, calling cechkpoint_stl again with their
// template argument type. This header makes all of the variants available
// to the recursive templates.
// Checkpoint routines
// vector
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// list
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// deque
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// set
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// multiset
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// map
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
// multimap
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
// pair
template <class FIRST, class SECOND,
typename std::enable_if<!is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* = nullptr >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
template <class FIRST, class SECOND,
typename std::enable_if<!is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* = nullptr >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
template <class FIRST, class SECOND,
typename std::enable_if< is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* = nullptr >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
template <class FIRST, class SECOND,
typename std::enable_if< is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* = nullptr >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
// queue
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::queue<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::queue<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
// priority queue
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl ,
std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl ,
std::string object_name , std::string var_name ) ;
// stack
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::stack<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int checkpoint_stl(std::stack<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
/* ===================================================================================================== */
// Restore routines
// vector
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// list
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// deque
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// set
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// multiset
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) ;
// map
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
// multimap
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* = nullptr >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) ;
// pair
template <class FIRST, class SECOND,
typename std::enable_if<!is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* = nullptr >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
template <class FIRST, class SECOND,
typename std::enable_if<!is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* = nullptr >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
template <class FIRST, class SECOND,
typename std::enable_if< is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* = nullptr >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
template <class FIRST, class SECOND,
typename std::enable_if< is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* = nullptr >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) ;
// queue
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::queue<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::queue<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
// priority queue
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl ,
std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl ,
std::string object_name , std::string var_name ) ;
// stack
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::stack<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* = nullptr >
int restore_stl(std::stack<ITEM_TYPE, _Sequence> & in_stl , std::string object_name , std::string var_name ) ;
#endif

View File

@ -0,0 +1,78 @@
/*
PURPOSE: (Test if item is an STL)
*/
#ifndef CHECKPOINT_IS_STL_CONTAINER
#define CHECKPOINT_IS_STL_CONTAINER
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <utility>
template <typename T>
struct is_stl_container {
static const bool value = false;
};
template <typename T,typename _Alloc>
struct is_stl_container<std::vector<T,_Alloc> > {
static const bool value = true;
};
template <typename T,typename _Alloc>
struct is_stl_container<std::list<T,_Alloc> > {
static const bool value = true;
};
template <typename T,typename _Alloc>
struct is_stl_container<std::deque<T,_Alloc> > {
static const bool value = true;
};
template <typename T,typename _Compare,typename _Alloc>
struct is_stl_container<std::set<T,_Compare,_Alloc> > {
static const bool value = true;
};
template <typename T,typename _Compare,typename _Alloc>
struct is_stl_container<std::multiset<T,_Compare,_Alloc> > {
static const bool value = true;
};
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc>
struct is_stl_container<std::map<_Key,_Tp ,_Compare,_Alloc> > {
static const bool value = true;
};
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc>
struct is_stl_container<std::multimap<_Key,_Tp ,_Compare,_Alloc> > {
static const bool value = true;
};
template <typename _T1,typename _T2>
struct is_stl_container<std::pair<_T1,_T2> > {
static const bool value = true;
};
template <typename _Tp, typename _Sequence>
struct is_stl_container<std::queue<_Tp,_Sequence> > {
static const bool value = true;
};
template <typename _Tp, typename _Container, typename _Compare>
struct is_stl_container<std::priority_queue<_Tp,_Container,_Compare> > {
static const bool value = true;
};
template <typename _Tp, typename _Sequence>
struct is_stl_container<std::stack<_Tp,_Sequence> > {
static const bool value = true;
};
#endif

View File

@ -11,15 +11,20 @@
#include <map>
#include <string>
#include <algorithm>
#include <sstream>
#include <typeinfo>
#include <type_traits>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
#ifndef TRICK_ICG
/* =================================================================================================*/
/* For all of the checkpoint_map_stl variations. Declare 2 memory manager arrays to hold
the contents of the map. No simulation variable actually points to these arrays. Only the
@ -28,30 +33,38 @@
the STL requires a unique name to be saved correctly. The incoming "object_name" and "var_name"
gives that unique name.
*/
// intrinsic key, intrinsic data
template <class STL>
int checkpoint_map_stl(STL & in_map , std::string object_name , std::string var_name ) {
int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
typename STL::key_type * keys ;
typename STL::mapped_type * items ;
typename STL::key_type * keys = nullptr ;
typename STL::mapped_type * items = nullptr ;
cont_size = in_map.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s_keys[%d]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare) ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status )) ;
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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
sprintf(var_declare, "%s %s_%s_data[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare) ;
var_declare.str("") ;
var_declare.clear() ;
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
@ -63,143 +76,214 @@ int checkpoint_map_stl(STL & in_map , std::string object_name , std::string var_
return 0 ;
}
template <class MAP_KEY, class MAP_ITEM>
int checkpoint_stl(std::map<MAP_KEY , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl( in_map , object_name , var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_id( in_map , object_name , var_name ) ;
}
template <class MAP_KEY, class MAP_ITEM>
int checkpoint_stl(std::multimap<MAP_KEY , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl( in_map , object_name , var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_id( in_map , object_name , var_name ) ;
}
// intrinsic key, STL data
template <class STL>
int checkpoint_map_stl_key_string(STL & in_map , std::string object_name , std::string var_name ) {
int checkpoint_map_ik_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
char ** keys ;
typename STL::mapped_type * items ;
typename STL::key_type * keys = nullptr ;
std::string * items = nullptr ;
cont_size = in_map.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%s_keys[%d]" , object_name.c_str(), var_name.c_str() , cont_size) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "STRING KEY HERE with %s\n", var_declare) ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status )) ;
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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
sprintf(var_declare, "%s %s_%s_data[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str() , cont_size) ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare) ;
//message_publish(1, "STRING KEY 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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (char *)((iter->first).c_str()) ;
keys[ii] = iter->first ;
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_data_" << ii ;
items[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
//message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ;
checkpoint_stl( iter->second , object_name + "_" + var_name + "_data" , index_string.str() ) ;
}
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_sd( in_map , object_name , var_name ) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_ik_sd( in_map , object_name , var_name ) ;
}
// STL key, intrinsic data
template <class STL>
int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
std::string * keys = nullptr ;
typename STL::mapped_type * items = nullptr ;
cont_size = in_map.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
var_declare.str("") ;
var_declare.clear() ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_keys_" << ii ;
keys[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
checkpoint_stl( const_cast<typename STL::key_type &>(iter->first) ,
object_name + "_" + var_name + "_keys", index_string.str() ) ;
items[ii] = iter->second ;
}
}
return 0 ;
}
template <class MAP_ITEM>
int checkpoint_stl(std::map<std::string , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_key_string( in_map , object_name , var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_sk_id( in_map , object_name , var_name ) ;
}
template <class MAP_ITEM>
int checkpoint_stl(std::multimap<std::string , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_key_string( in_map , object_name , var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_sk_id( in_map , object_name , var_name ) ;
}
// STL key, STL data
template <class STL>
int checkpoint_map_stl_data_string(STL & in_map , std::string object_name , std::string var_name ) {
int checkpoint_map_stl_sk_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
typename STL::iterator iter ;
int status ;
typename STL::key_type * keys ;
char ** items ;
std::string * keys = nullptr ;
std::string * items = nullptr ;
cont_size = in_map.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s_keys[%d]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str() , cont_size) ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare) ;
//message_publish(1, "STRING KEY HERE with %s\n", var_declare) ;
var_declare << "std::string "
<< object_name << "_" << var_name << "_keys[" << cont_size << "]" ;
keys = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
sprintf(var_declare, "char * %s_%s_data[%d]" , object_name.c_str(), var_name.c_str() , cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "STRING KEY 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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ;
//message_publish(1, "HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = iter->first ;
items[ii] = (char *)((iter->second).c_str()) ;
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_keys_" << ii ;
keys[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
checkpoint_stl( const_cast<typename STL::key_type &>(iter->first) ,
object_name + "_" + var_name + "_keys", index_string.str() ) ;
sub_elements << object_name << "_" << var_name << "_data_" << ii ;
items[ii] = sub_elements.str() ;
checkpoint_stl( iter->second ,
object_name + "_" + var_name + "_data", index_string.str() ) ;
}
}
return 0 ;
}
template <class MAP_KEYS>
int checkpoint_stl(std::map<MAP_KEYS, std::string> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_data_string( in_map , object_name , var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int checkpoint_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_sk_sd( in_map , object_name , var_name ) ;
}
template <class MAP_KEYS>
int checkpoint_stl(std::multimap<MAP_KEYS, std::string> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_data_string( in_map , object_name , var_name ) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type*>
int checkpoint_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_sk_sd( in_map , object_name , var_name ) ;
}
/* =================================================================================================*/
template <class STL>
int checkpoint_map_stl_strings(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
char ** keys ;
char ** items ;
cont_size = in_map.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%s_keys[%d]" , object_name.c_str(), var_name.c_str() , cont_size) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "STRING KEY HERE with %s\n", var_declare) ;
sprintf(var_declare, "char * %s_%s_data[%d]" , object_name.c_str(), var_name.c_str() , cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "STRING KEY HERE with %s\n", var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (char *)((iter->first).c_str()) ;
items[ii] = (char *)((iter->second).c_str()) ;
}
}
return 0 ;
}
int checkpoint_stl(std::map<std::string , std::string> & in_map , std::string object_name , std::string var_name ) ;
int checkpoint_stl(std::multimap<std::string , std::string> & in_map , std::string object_name , std::string var_name ) ;
template <class STL>
int delete_map_stl(STL & in_map __attribute__ ((unused)), std::string object_name , std::string var_name ) {
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(), std::ptr_fun<int,int>(&std::ispunct), '_');
REF2 * items_ref ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_keys")).c_str()) ;
@ -211,16 +295,18 @@ int delete_map_stl(STL & in_map __attribute__ ((unused)), std::string object_nam
return 0 ;
}
template <class MAP_KEY, class MAP_ITEM>
int delete_stl(std::map<MAP_KEY , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return delete_map_stl(in_map , object_name , var_name) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc>
int delete_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return delete_map_allocs(in_map , object_name , var_name) ;
}
template <class MAP_KEY, class MAP_ITEM>
int delete_stl(std::multimap<MAP_KEY , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return delete_map_stl(in_map , object_name , var_name) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc>
int delete_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return delete_map_allocs(in_map , object_name , var_name) ;
}
/* =================================================================================================*/
/* For all restore_map_stl varieties.
Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number
@ -228,7 +314,7 @@ int delete_stl(std::multimap<MAP_KEY , MAP_ITEM> & in_map , std::string object_n
the map from the 2 arrays.
*/
template <class STL>
int restore_map_stl(STL & in_map , std::string object_name , std::string var_name ) {
int restore_map_ik_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
@ -239,13 +325,13 @@ int restore_map_stl(STL & in_map , std::string object_name , std::string var_nam
//message_publish(1, "in regular map template restore\n") ;
in_map.clear() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
keys_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_keys")).c_str()) ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_data")).c_str()) ;
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (typename STL::key_type *)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
@ -259,139 +345,172 @@ int restore_map_stl(STL & in_map , std::string object_name , std::string var_nam
return 0 ;
}
template <class MAP_KEY, class MAP_ITEM>
int restore_stl(std::map<MAP_KEY , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl(in_map , object_name , var_name) ;
return 0 ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_id(in_map , object_name , var_name) ;
}
template <class MAP_KEY, class MAP_ITEM>
int restore_stl(std::multimap<MAP_KEY , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl(in_map , object_name , var_name) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_id(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_stl_key_string( STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
typename STL::mapped_type * items ;
in_map.clear() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
keys_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_keys")).c_str()) ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_data")).c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<std::string , typename STL::mapped_type>(std::string(keys[ii]), items[ii])) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class MAP_ITEM>
int restore_stl(std::map<std::string , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl_key_string(in_map , object_name , var_name) ;
}
template <class MAP_ITEM>
int restore_stl(std::multimap<std::string , MAP_ITEM> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl_key_string(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_stl_data_string(STL & in_map , std::string object_name , std::string var_name ) {
int restore_map_ik_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * keys_ref , * items_ref ;
typename STL::key_type * keys ;
char ** items ;
std::string * items ;
//message_publish(1, "in specialized map template restore\n") ;
//message_publish(1, "in regular map template restore\n") ;
in_map.clear() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
keys_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_keys")).c_str()) ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_data")).c_str()) ;
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (typename STL::key_type *)keys_ref->address ;
items = (char **)items_ref->address ;
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<typename STL::key_type, std::string>(keys[ii] , std::string(items[ii]))) ;
}
std::ostringstream index_string ;
index_string << ii ;
typename STL::mapped_type mt ;
restore_stl(mt, object_name + "_" + var_name + "_data", index_string.str()) ;
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(keys[ii], mt)) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class MAP_KEY>
int restore_stl(std::map<MAP_KEY , std::string> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl_data_string(in_map , object_name , var_name) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_sd(in_map , object_name , var_name) ;
}
template <class MAP_KEY>
int restore_stl(std::multimap<MAP_KEY , std::string> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl_data_string(in_map , object_name , var_name) ;
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if<!is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_ik_sd(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_stl_strings(STL & in_map , std::string object_name , std::string var_name ) {
int restore_map_sk_id(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
char ** items ;
std::string * keys ;
typename STL::mapped_type * items ;
//message_publish(1, "in specialized map template restore\n") ;
//message_publish(1, "in regular map template restore\n") ;
/* Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number
of items that were stored in the checkpoint. Knowing the size, we can restore
the map from the 2 arrays. This template only works for string map keys.
*/
in_map.clear() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
keys_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_keys")).c_str()) ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_data")).c_str()) ;
keys_ref = ref_attributes((char *)(object_name + "_" + var_name + "_keys").c_str()) ;
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_data").c_str()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (char **)items_ref->address ;
in_map.clear() ;
keys = (std::string *)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<std::string, std::string>(std::string(keys[ii]) , std::string(items[ii]))) ;
}
std::ostringstream index_string ;
index_string << ii ;
typename STL::key_type kt ;
restore_stl(kt, object_name + "_" + var_name + "_keys", index_string.str()) ;
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(kt, items[ii])) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
int restore_stl(std::map<std::string, std::string> & in_map , std::string object_name , std::string var_name ) ;
int restore_stl(std::multimap<std::string, std::string> & in_map , std::string object_name , std::string var_name ) ;
#endif
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_id(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
!is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_id(in_map , object_name , var_name) ;
}
template <class STL>
int restore_map_sk_sd(STL & in_map , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * keys_ref , * items_ref ;
std::string * keys ;
std::string * items ;
//message_publish(1, "in regular map template restore\n") ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( keys_ref != NULL && items_ref != NULL ) {
in_map.clear() ;
keys = (std::string *)keys_ref->address ;
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
std::ostringstream index_string ;
index_string << ii ;
typename STL::key_type kt ;
restore_stl(kt, object_name + "_" + var_name + "_keys", index_string.str()) ;
typename STL::mapped_type mt ;
restore_stl(mt, object_name + "_" + var_name + "_data", index_string.str()) ;
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(kt, mt)) ;
}
delete_stl( in_map , object_name , var_name ) ;
}
return 0 ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::map<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_sd(in_map , object_name , var_name) ;
}
template <class KEY, class DATA, typename _Compare, typename _Alloc,
typename std::enable_if< is_stl_container<KEY>::value &&
is_stl_container<DATA>::value >::type* >
int restore_stl(std::multimap<KEY,DATA,_Compare,_Alloc> & in_map , std::string object_name , std::string var_name ) {
return restore_map_sk_sd(in_map , object_name , var_name) ;
}
#endif

View File

@ -7,187 +7,273 @@
#define CHECKPOINT_PAIR_HH
#include <utility>
#include <sstream>
#include <algorithm>
#include <typeinfo>
#include <functional>
#include <string>
#include <type_traits>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
#ifndef TRICK_ICG
template <class FIRST_TYPE, class SECOND_TYPE>
int delete_stl(std::pair<FIRST_TYPE, SECOND_TYPE> & in_stl __attribute__ ((unused)) , std::string object_name , std::string var_name ) {
// intrinsic first , intrinsic second
template <class FIRST, class SECOND, typename std::enable_if<!is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
std::ostringstream var_declare ;
int status ;
FIRST * first = nullptr ;
SECOND * second = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_first[1]" ;
first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ;
first[0] = in_pair.first ;
var_declare.str("") ;
var_declare.clear() ;
type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status )) ;
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()) ;
second[0] = in_pair.second ;
return 0 ;
}
// intrinsic first , STL second
template <class FIRST, class SECOND, typename std::enable_if<!is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
std::ostringstream var_declare ;
int status ;
FIRST * first = nullptr ;
std::string * second = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "_first[1]" ;
first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ;
checkpoint_stl( in_pair.second , object_name + "_" + var_name , "second" ) ;
return 0 ;
}
// STL first , intrinsic second
template <class FIRST, class SECOND, typename std::enable_if< is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* >
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 * first = nullptr ;
SECOND * second = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
checkpoint_stl( in_pair.first , object_name + "_" + var_name , "first" ) ;
var_declare.str("") ;
var_declare.clear() ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status )) ;
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()) ;
second[0] = in_pair.second ;
return 0 ;
}
// STL first , STL second
template <class FIRST, class SECOND, typename std::enable_if< is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* >
int checkpoint_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
std::ostringstream var_declare ;
std::string * first = nullptr ;
std::string * second = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
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()) ;
checkpoint_stl( in_pair.second , object_name + "_" + var_name , "second" ) ;
return 0 ;
}
/* =================================================================================================*/
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(), std::ptr_fun<int,int>(&std::ispunct), '_');
REF2 * items_ref ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_first")).c_str()) ;
items_ref = ref_attributes((char *)(object_name + "_" + var_name + "_first").c_str()) ;
if ( items_ref != NULL ) {
TMM_delete_var_n((object_name + std::string("_") + var_name + std::string("_first")).c_str() ) ;
TMM_delete_var_n((object_name + std::string("_") + var_name + std::string("_second")).c_str() ) ;
TMM_delete_var_n((object_name + "_" + var_name + "_first").c_str() ) ;
TMM_delete_var_n((object_name + "_" + var_name + "_second").c_str() ) ;
free(items_ref) ;
}
return 0 ;
}
template <class FIRST_TYPE, class SECOND_TYPE>
int checkpoint_stl(std::pair<FIRST_TYPE, SECOND_TYPE> & in_stl , std::string object_name , std::string var_name ) {
char var_declare[128] ;
int status ;
FIRST_TYPE * first ;
SECOND_TYPE * second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
sprintf(var_declare, "%s %s_%s_first[1]" ,
abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str()) ;
first = (FIRST_TYPE *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%s_second[1]" ,
abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str()) ;
second = (SECOND_TYPE *)TMM_declare_var_s(var_declare) ;
first[0] = in_stl.first ;
second[0] = in_stl.second ;
return 0 ;
}
template <class FIRST_TYPE>
int checkpoint_stl(std::pair<FIRST_TYPE, std::string> & in_stl , std::string object_name , std::string var_name ) {
char var_declare[128] ;
int status ;
FIRST_TYPE * first ;
char ** second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
sprintf(var_declare, "%s %s_%s_first[1]" ,
abi::__cxa_demangle(typeid(*first).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str()) ;
first = (FIRST_TYPE *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%s_second[1]" , object_name.c_str(), var_name.c_str()) ;
second = (char **)TMM_declare_var_s(var_declare) ;
first[0] = in_stl.first ;
second[0] = (char *)(in_stl.second.c_str()) ;
return 0 ;
}
template <class SECOND_TYPE>
int checkpoint_stl(std::pair<std::string, SECOND_TYPE> & in_stl , std::string object_name , std::string var_name ) {
char var_declare[128] ;
int status ;
char ** first ;
SECOND_TYPE * second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
sprintf(var_declare, "char * %s_%s_first[1]", object_name.c_str(), var_name.c_str()) ;
first = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%s_second[1]" ,
abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str()) ;
second = (SECOND_TYPE *)TMM_declare_var_s(var_declare) ;
first[0] = (char *)(in_stl.first.c_str()) ;
second[0] = in_stl.second ;
return 0 ;
}
template <class FIRST_TYPE, class SECOND_TYPE>
int restore_stl(std::pair<FIRST_TYPE, SECOND_TYPE> & in_stl , std::string object_name , std::string var_name ) {
/* =================================================================================================*/
// intrinsic first, intrinsic second
template <class FIRST, class SECOND, typename std::enable_if<!is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
REF2 * first_ref ;
REF2 * second_ref ;
FIRST_TYPE * first ;
SECOND_TYPE * second ;
FIRST * first ;
SECOND * second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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 + std::string("_") + var_name + std::string("_first")).c_str()) ;
second_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_second")).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()) ;
if ( first_ref != NULL && second_ref != NULL ) {
first = (FIRST_TYPE *)first_ref->address ;
second = (SECOND_TYPE *)second_ref->address ;
first = (FIRST *)first_ref->address ;
second = (SECOND *)second_ref->address ;
in_stl.first = first[0] ;
in_stl.second = second[0] ;
in_pair.first = first[0] ;
in_pair.second = second[0] ;
delete_stl( in_stl , object_name , var_name ) ;
delete_stl( in_pair , object_name , var_name ) ;
}
return 0 ;
}
template <class FIRST_TYPE>
int restore_stl(std::pair<FIRST_TYPE, std::string > & in_stl , std::string object_name , std::string var_name ) {
// intrinsic first, STL second
template <class FIRST, class SECOND, typename std::enable_if<!is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
REF2 * first_ref ;
REF2 * second_ref ;
FIRST_TYPE * first ;
char ** second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
FIRST * first ;
std::string * second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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 + std::string("_") + var_name + std::string("_first")).c_str()) ;
second_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_second")).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()) ;
if ( first_ref != NULL && second_ref != NULL ) {
first = (FIRST_TYPE *)first_ref->address ;
second = (char **)second_ref->address ;
first = (FIRST *)first_ref->address ;
second = (std::string *)second_ref->address ;
in_stl.first = first[0] ;
in_stl.second = std::string(second[0]) ;
in_pair.first = first[0] ;
restore_stl( in_pair.second , object_name + "_" + var_name , "second" ) ;
delete_stl( in_stl , object_name , var_name ) ;
delete_stl( in_pair , object_name , var_name ) ;
}
return 0 ;
}
template <class SECOND_TYPE>
int restore_stl(std::pair<std::string, SECOND_TYPE> & in_stl , std::string object_name , std::string var_name ) {
// STL first, intrinsic second
template <class FIRST, class SECOND, typename std::enable_if< is_stl_container<FIRST>::value &&
!is_stl_container<SECOND>::value >::type* >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
REF2 * first_ref ;
REF2 * second_ref ;
char ** first ;
SECOND_TYPE * second ;
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
std::string * first ;
SECOND * second ;
first_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_first")).c_str()) ;
second_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_second")).c_str()) ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( first_ref != NULL && second_ref != NULL ) {
first = (char **)first_ref->address ;
second = (SECOND_TYPE *)second_ref->address ;
first = (std::string *)first_ref->address ;
second = (SECOND *)second_ref->address ;
in_stl.first = std::string(first[0]) ;
in_stl.second = second[0] ;
restore_stl( in_pair.first , object_name + "_" + var_name , "first" ) ;
in_pair.second = second[0] ;
delete_stl( in_stl , object_name , var_name ) ;
delete_stl( in_pair , object_name , var_name ) ;
}
return 0 ;
}
// Specialized routines for strings.
int checkpoint_stl(std::pair<std::string, std::string> & in_stl , std::string object_name , std::string var_name ) ;
int restore_stl(std::pair<std::string, std::string> & in_stl , std::string object_name , std::string var_name ) ;
#endif
// STL first, STL second
template <class FIRST, class SECOND, typename std::enable_if< is_stl_container<FIRST>::value &&
is_stl_container<SECOND>::value >::type* >
int restore_stl(std::pair<FIRST , SECOND> & in_pair , std::string object_name , std::string var_name ) {
REF2 * first_ref ;
REF2 * second_ref ;
std::string * first ;
std::string * second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( first_ref != NULL && second_ref != NULL ) {
first = (std::string *)first_ref->address ;
second = (std::string *)second_ref->address ;
restore_stl( in_pair.first , object_name + "_" + var_name , "first" ) ;
restore_stl( in_pair.second , object_name + "_" + var_name , "second" ) ;
delete_stl( in_pair , object_name , var_name ) ;
}
return 0 ;
}
#endif

View File

@ -8,54 +8,48 @@
#include <queue>
#include <algorithm>
#include <typeinfo>
#include <sstream>
#include <type_traits>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "trick/checkpoint_sequence_stl.hh"
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "checkpoint_sequence_stl.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
#ifndef TRICK_ICG
template <class ITEM_TYPE>
int delete_stl(std::queue<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
/* =================================================================================================*/
template <class ITEM_TYPE>
int delete_stl(std::priority_queue<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int delete_stl(std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::greater<ITEM_TYPE> > & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int checkpoint_stl(std::queue<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
// queue: intrinsic
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
int status ;
ITEM_TYPE * items ;
std::queue<ITEM_TYPE> temp_queue ;
ITEM_TYPE * items = nullptr ;
std::queue<ITEM_TYPE,_Sequence> temp_queue(in_stl) ;
cont_size = in_stl.size() ;
cont_size = temp_queue.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare) ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_queue = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = temp_queue.front() ;
temp_queue.pop() ;
@ -65,28 +59,65 @@ int checkpoint_stl(std::queue<ITEM_TYPE> & in_stl , std::string object_name , st
return 0 ;
}
template <class ITEM_TYPE>
int checkpoint_stl(std::priority_queue<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
// queue: STL
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
int status ;
std::ostringstream var_declare ;
ITEM_TYPE * items ;
std::priority_queue<ITEM_TYPE> temp_queue ;
std::string * items = nullptr ;
std::queue<ITEM_TYPE,_Sequence> temp_queue(in_stl) ;
cont_size = in_stl.size() ;
cont_size = temp_queue.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare) ;
var_declare << "std::string "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_queue = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_" << ii ;
items[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
checkpoint_stl (temp_queue.front(), object_name + "_" + var_name, index_string.str()) ;
temp_queue.pop() ;
}
}
return 0 ;
}
// priority queue: intrinsic
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl ,
std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
int status ;
ITEM_TYPE * items = nullptr ;
std::priority_queue<ITEM_TYPE,_Container,_Compare> temp_queue(in_stl) ;
cont_size = temp_queue.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = temp_queue.top() ;
@ -97,32 +128,37 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE> & in_stl , std::string object_
return 0 ;
}
// template for priority queues using greater comparator
template <class ITEM_TYPE>
int checkpoint_stl(std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::greater<ITEM_TYPE> > & in_stl , std::string object_name , std::string var_name ) {
// priority queue: STL
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl ,
std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
int status ;
std::ostringstream var_declare ;
ITEM_TYPE * items = NULL ;
std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::greater<ITEM_TYPE> > temp_queue ;
std::string * items = nullptr ;
std::priority_queue<ITEM_TYPE,_Container,_Compare> temp_queue(in_stl) ;
cont_size = in_stl.size() ;
cont_size = temp_queue.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare) ;
var_declare << "std::string "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_queue = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = temp_queue.top() ;
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_" << ii ;
items[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
checkpoint_stl (const_cast< ITEM_TYPE &>(temp_queue.top()), object_name + "_" + var_name, index_string.str()) ;
temp_queue.pop() ;
}
}
@ -130,32 +166,51 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::g
return 0 ;
}
/* =================================================================================================*/
// The delete routines use the same method as the sequence types
template <typename ITEM_TYPE, typename _Sequence>
int delete_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
template <typename ITEM_TYPE, typename _Container, typename _Compare>
int delete_stl(std::priority_queue<ITEM_TYPE,_Container,_Compare> & in_stl ,
std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
/* =================================================================================================*/
/* Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number of
items that were stored in the checkpoint. Knowing the size, we can restore
the map from the 2 arrays.
*/
template <class STL>
int restore_queue_stl(STL & in_stl , std::string object_name , std::string var_name ) {
// queue: intrinsic
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * items_ref ;
typename STL::value_type * items ;
ITEM_TYPE * items ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( items_ref != NULL ) {
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
if ( items_ref != NULL ) {
items = (typename STL::value_type *)items_ref->address ;
items = (ITEM_TYPE *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
@ -163,31 +218,68 @@ int restore_queue_stl(STL & in_stl , std::string object_name , std::string var_n
}
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}
template <class STL>
int restore_queue_stl_string(STL & in_stl , std::string object_name , std::string var_name ) {
// queue: STL
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * items_ref ;
char ** items ;
std::string * items ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( items_ref != NULL ) {
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
ITEM_TYPE vt ;
std::ostringstream index_string ;
index_string << ii ;
restore_stl( vt , object_name + "_" + var_name , index_string.str()) ;
in_stl.push( vt ) ;
}
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}
// priority_queue: intrinsic
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::priority_queue<ITEM_TYPE,_Container,_Compare> & in_stl ,
std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * items_ref ;
ITEM_TYPE * items ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( items_ref != NULL ) {
items = (char **)items_ref->address ;
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
items = (ITEM_TYPE *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
@ -195,31 +287,44 @@ int restore_queue_stl_string(STL & in_stl , std::string object_name , std::strin
}
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}
template <class ITEM_TYPE>
int restore_stl(std::queue<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_queue_stl( in_stl , object_name , var_name ) ;
// priority_queue: STL
template <typename ITEM_TYPE, typename _Container, typename _Compare,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::priority_queue<ITEM_TYPE,_Container,_Compare> & in_stl ,
std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * items_ref ;
std::string * items ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( items_ref != NULL ) {
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
template <class ITEM_TYPE>
int restore_stl(std::priority_queue<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_queue_stl( in_stl , object_name , var_name ) ;
}
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)items) ;
template <class ITEM_TYPE>
int restore_stl(std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::greater<ITEM_TYPE> > & in_stl , std::string object_name , std::string var_name ) {
return restore_queue_stl( in_stl , object_name , var_name ) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
ITEM_TYPE vt ;
std::ostringstream index_string ;
index_string << ii ;
restore_stl( vt , object_name + "_" + var_name , index_string.str()) ;
in_stl.push( vt ) ;
}
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}
// Specialized routines for strings.
int checkpoint_stl(std::queue<std::string> & in_stl , std::string object_name , std::string var_name ) ;
int checkpoint_stl(std::priority_queue<std::string> & in_stl , std::string object_name , std::string var_name ) ;
int restore_stl(std::queue<std::string> & in_stl , std::string object_name , std::string var_name ) ;
int restore_stl(std::priority_queue<std::string> & in_stl , std::string object_name , std::string var_name ) ;
#endif
#endif

View File

@ -13,73 +13,43 @@
#include <set>
#include <algorithm>
#include <typeinfo>
#include <sstream>
#include <type_traits>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "checkpoint_is_stl_container.hh"
#include "checkpoint_stl_protos.hh"
#include "checkpoint_fwd_declare.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
#ifndef TRICK_ICG
/* =================================================================================================*/
template <class STL>
int delete_sequence_stl(STL & in_stl __attribute__ ((unused)), std::string object_name , std::string var_name ) {
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
REF2 * items_ref ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
if ( items_ref != NULL ) {
TMM_delete_var_n((object_name + std::string("_") + var_name).c_str() ) ;
free(items_ref) ;
}
return 0 ;
}
template <class ITEM_TYPE>
int delete_stl(std::vector<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int delete_stl(std::list<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int delete_stl(std::deque<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int delete_stl(std::set<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int delete_stl(std::multiset<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
template <class STL>
int checkpoint_sequence_stl(STL & in_stl , std::string object_name , std::string var_name ) {
int checkpoint_sequence_i(STL & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
int status ;
typename STL::value_type * items = NULL ;
typename STL::iterator it ;
typename STL::iterator end ;
//message_publish(1, "%s\n", __PRETTY_FUNCTION__) ;
cont_size = in_stl.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (typename STL::value_type *)TMM_declare_var_s(var_declare) ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (typename STL::value_type *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ;
/* copy the contents of the stl */
@ -93,13 +63,13 @@ int checkpoint_sequence_stl(STL & in_stl , std::string object_name , std::string
}
template <class STL>
int checkpoint_sequence_stl_string(STL & in_stl , std::string object_name , std::string var_name ) {
int checkpoint_sequence_s(STL & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
const char ** items ;
std::string * items ;
typename STL::iterator it ;
typename STL::iterator end ;
@ -107,28 +77,160 @@ int checkpoint_sequence_stl_string(STL & in_stl , std::string object_name , std:
cont_size = in_stl.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
//message_publish(1, "%s\n", __PRETTY_FUNCTION__) ;
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%s[%d]" , object_name.c_str(), var_name.c_str() , cont_size) ;
items = (const char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_SEQUENCE_STL_STRING with %s\n", var_declare) ;
var_declare << "std::string " << object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ;
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()) ;
/* copy the contents of the vector */
/* 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++ ) {
items[ii] = it->c_str() ;
}
}
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_" << ii ;
items[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
//message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ;
checkpoint_stl( (*it) , object_name + "_" + var_name , index_string.str() ) ;
}
}
return 0 ;
}
// -----------
// std::vector
// This template is only enabled if the items in the vector are an STL
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_s( in_stl , object_name , var_name ) ;
}
// This template is only enabled if the items in the vector are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_i( in_stl , object_name , var_name ) ;
}
// -----------
// std::list
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_s( in_stl , object_name , var_name ) ;
}
// This template is only enabled if the items in the list are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_i( in_stl , object_name , var_name ) ;
}
// -----------
// std::deque
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_s( in_stl , object_name , var_name ) ;
}
// This template is only enabled if the items in the deque are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_i( in_stl , object_name , var_name ) ;
}
// -----------
// std::set
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_s( in_stl , object_name , var_name ) ;
}
// This template is only enabled if the items in the set are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_i( in_stl , object_name , var_name ) ;
}
// -----------
// std::multiset
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_s( in_stl , object_name , var_name ) ;
}
// This template is only enabled if the items in the multiset are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_i( in_stl , object_name , var_name ) ;
}
/* =================================================================================================*/
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(), std::ptr_fun<int,int>(&std::ispunct), '_');
REF2 * items_ref ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
if ( items_ref != NULL ) {
TMM_delete_var_n((object_name + std::string("_") + var_name).c_str() ) ;
free(items_ref) ;
}
return 0 ;
}
template <class ITEM_TYPE, typename _Alloc>
int delete_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE, typename _Alloc>
int delete_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE, typename _Alloc>
int delete_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE, typename _Alloc>
int delete_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE, typename _Alloc>
int delete_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
/* =================================================================================================*/
/* Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number of
items that were stored in the checkpoint. Knowing the size, we can restore
the map from the 2 arrays.
*/
template <class STL>
int restore_sequence_stl(STL & in_stl , std::string object_name , std::string var_name ) {
int restore_sequence_i(STL & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
@ -139,11 +241,10 @@ int restore_sequence_stl(STL & in_stl , std::string object_name , std::string va
//message_publish(1, "RESTORE_SEQUENCE_STL %s_%s\n", object_name.c_str() , var_name.c_str()) ;
in_stl.clear() ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
if ( items_ref != NULL ) {
in_stl.clear() ;
items = (typename STL::value_type *)items_ref->address ;
cont_size = get_size((char *)items) ;
@ -157,27 +258,30 @@ int restore_sequence_stl(STL & in_stl , std::string object_name , std::string va
}
template <class STL>
int restore_sequence_stl_string(STL & in_stl , std::string object_name , std::string var_name ) {
int restore_sequence_s(STL & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * items_ref ;
char ** items ;
std::string * items ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
//message_publish(1, "in specialized vector template restore\n") ;
//message_publish(1, "%s\n", __PRETTY_FUNCTION__) ;
in_stl.clear() ;
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
items_ref = ref_attributes((char *)(object_name + "_" + var_name).c_str()) ;
if ( items_ref != NULL ) {
items = (char **)items_ref->address ;
in_stl.clear() ;
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.insert( in_stl.end(), items[ii] ) ;
typename STL::value_type vt ;
std::ostringstream index_string ;
index_string << ii ;
restore_stl(vt, object_name + "_" + var_name , index_string.str()) ;
in_stl.insert( in_stl.end(), vt ) ;
}
delete_stl( in_stl , object_name , var_name ) ;
}
@ -185,67 +289,89 @@ int restore_sequence_stl_string(STL & in_stl , std::string object_name , std::st
return 0 ;
}
// General routines for all types but strings
template <class ITEM_TYPE>
int checkpoint_stl(std::vector<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl( in_stl , object_name , var_name ) ;
// -----------
// std::vector
// This template is only enabled if the items in the vector are an STL
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_s( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int checkpoint_stl(std::list<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl( in_stl , object_name , var_name ) ;
// This template is only enabled if the items in the vector are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::vector<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_i( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int checkpoint_stl(std::deque<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl( in_stl , object_name , var_name ) ;
// -----------
// std::list
// This template is only enabled if the items in the list are an STL
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_s( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int checkpoint_stl(std::set<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl( in_stl , object_name , var_name ) ;
// This template is only enabled if the items in the list are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::list<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_i( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int checkpoint_stl(std::multiset<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl( in_stl , object_name , var_name ) ;
// -----------
// std::deque
// This template is only enabled if the items in the deque are an STL
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_s( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int restore_stl(std::vector<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl( in_stl , object_name , var_name ) ;
// This template is only enabled if the items in the deque are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::deque<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_i( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int restore_stl(std::list<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl( in_stl , object_name , var_name ) ;
// -----------
// std::set
// This template is only enabled if the items in the set are an STL
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_s( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int restore_stl(std::deque<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl( in_stl , object_name , var_name ) ;
// This template is only enabled if the items in the set are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::set<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_i( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int restore_stl(std::set<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl( in_stl , object_name , var_name ) ;
// -----------
// std::multiset
// This template is only enabled if the items in the multiset are an STL
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_s( in_stl , object_name , var_name ) ;
}
template <class ITEM_TYPE>
int restore_stl(std::multiset<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl( in_stl , object_name , var_name ) ;
// This template is only enabled if the items in the multiset are NOT an STL, except for std::string
template <typename ITEM_TYPE, typename _Alloc,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int restore_stl(std::multiset<ITEM_TYPE,_Alloc> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_i( in_stl , object_name , var_name ) ;
}
// Specialized routines for strings.
int checkpoint_stl(std::vector<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int checkpoint_stl(std::list<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int checkpoint_stl(std::deque<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int checkpoint_stl(std::set<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int checkpoint_stl(std::multiset<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int restore_stl(std::vector<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int restore_stl(std::list<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int restore_stl(std::deque<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int restore_stl(std::set<std::string> & in_vector , std::string object_name , std::string var_name ) ;
int restore_stl(std::multiset<std::string> & in_vector , std::string object_name , std::string var_name ) ;
#endif
#endif

View File

@ -8,44 +8,45 @@
#include <stack>
#include <algorithm>
#include <typeinfo>
#include <sstream>
#include <type_traits>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "trick/checkpoint_sequence_stl.hh"
#include "checkpoint_stl_protos.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
#ifndef TRICK_ICG
template <class ITEM_TYPE>
int delete_stl(std::stack<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_stl( in_stl , object_name , var_name ) ;
}
/* =================================================================================================*/
template <class ITEM_TYPE>
int checkpoint_stl(std::stack<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
// stack: intrinsic
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
std::ostringstream var_declare ;
int status ;
ITEM_TYPE * items ;
std::stack<ITEM_TYPE> temp_stack ;
ITEM_TYPE * items = nullptr ;
std::stack<ITEM_TYPE,_Sequence> temp_stack(in_stl) ;
cont_size = in_stl.size() ;
cont_size = temp_stack.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare) ;
std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ;
var_declare << type_string << " "
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_stack = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = temp_stack.top() ;
temp_stack.pop() ;
@ -55,31 +56,78 @@ int checkpoint_stl(std::stack<ITEM_TYPE> & in_stl , std::string object_name , st
return 0 ;
}
// stack: STL
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* >
int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
std::ostringstream var_declare ;
std::string * items = nullptr ;
std::stack<ITEM_TYPE,_Sequence> temp_stack(in_stl) ;
cont_size = temp_stack.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
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()) ;
TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
std::ostringstream sub_elements ;
sub_elements << object_name << "_" << var_name << "_" << ii ;
items[ii] = sub_elements.str() ;
std::ostringstream index_string ;
index_string << ii ;
checkpoint_stl (temp_stack.top(), object_name + "_" + var_name, index_string.str()) ;
temp_stack.pop() ;
}
}
return 0 ;
}
/* =================================================================================================*/
// The delete routine uses the same method as the sequence types
template <typename ITEM_TYPE, typename _Sequence>
int delete_stl(std::stack<ITEM_TYPE,_Sequence> & in_stl , std::string object_name , std::string var_name ) {
return delete_sequence_alloc( in_stl , object_name , var_name ) ;
}
/* =================================================================================================*/
/* Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number of
items that were stored in the checkpoint. Knowing the size, we can restore
the map from the 2 arrays.
*/
template <class ITEM_TYPE>
int restore_stl(std::stack<ITEM_TYPE> & in_stl , std::string object_name , std::string var_name ) {
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if<!is_stl_container<ITEM_TYPE>::value>::type* >
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 ;
REF2 * items_ref ;
ITEM_TYPE * items ;
ITEM_TYPE * items = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( items_ref != NULL ) {
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
if ( items_ref != NULL ) {
items = (ITEM_TYPE *)items_ref->address ;
cont_size = get_size((char *)items) ;
@ -92,10 +140,39 @@ int restore_stl(std::stack<ITEM_TYPE> & in_stl , std::string object_name , std::
return 0 ;
}
// Specialized routines for strings.
int checkpoint_stl(std::stack<std::string> & in_stl , std::string object_name , std::string var_name ) ;
int restore_stl(std::stack<std::string> & in_stl , std::string object_name , std::string var_name ) ;
#endif
template <typename ITEM_TYPE, typename _Sequence,
typename std::enable_if< is_stl_container<ITEM_TYPE>::value>::type* >
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 ;
REF2 * items_ref ;
std::string * items = nullptr ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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()) ;
if ( items_ref != NULL ) {
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
items = (std::string *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = cont_size - 1 ; ii < cont_size ; ii-- ) {
ITEM_TYPE vt ;
std::ostringstream index_string ;
index_string << ii ;
restore_stl( vt , object_name + "_" + var_name , index_string.str()) ;
in_stl.push( vt ) ;
}
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}
#endif

View File

@ -0,0 +1,7 @@
#include <string>
// prototype of functions used in checkpoint_stl templates
std::string stl_type_name_convert(std::string in_type) ;

View File

@ -1,594 +0,0 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
*/
#ifndef CHECKPOINT_TRICK_MAP_HH
#define CHECKPOINT_TRICK_MAP_HH
#include <string>
#include <algorithm>
#include <typeinfo>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "trick/STLInterface.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
/* For all of the checkpoint_map_stl variations. Declare 2 memory manager arrays to hold
the contents of the map. No simulation variable actually points to these arrays. Only the
user knows they are there and how they are stored. The restart function knows how to
"retrieve" and restore the data. The name of the declaration is important. Each instance of
the STL requires a unique name to be saved correctly. The incoming "object_name" and "var_name"
gives that unique name.
*/
template <class STL>
int checkpoint_trick_map_nkey_ndata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
int status ;
typename STL::key_type * keys ;
typename STL::mapped_type * items ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%06d_keys[%d]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), id, cont_size) ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%06d_data[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id, cont_size) ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = iter->first ;
items[ii] = iter->second ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_nkey_sdata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
int status ;
typename STL::key_type * keys ;
char ** items ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%06d_keys[%d]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), id , cont_size) ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%06d_data[%d]" , object_name.c_str(), id , cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = iter->first ;
items[ii] = (char *)((iter->second).c_str()) ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_nkey_stldata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
int status ;
typename STL::key_type * keys ;
unsigned int * items = NULL ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%06d_keys[%d]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), id , cont_size) ;
keys = (typename STL::key_type *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "unsigned int %s_%06d_data[%d]" , object_name.c_str(), id , cont_size) ;
items = (unsigned int*)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = iter->first ;
items[ii] = (iter->second).stl_id ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_skey_ndata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
int status ;
char ** keys ;
typename STL::mapped_type * items ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%06d_keys[%d]" , object_name.c_str(), id , cont_size) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%06d_data[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id , cont_size) ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (char *)((iter->first).c_str()) ;
items[ii] = iter->second ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_skey_sdata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
char ** keys ;
char ** items ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%06d_keys[%d]" , object_name.c_str(), id , cont_size) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%06d_data[%d]" , object_name.c_str(), id , cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (char *)((iter->first).c_str()) ;
items[ii] = (char *)((iter->second).c_str()) ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_skey_stldata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
char ** keys ;
unsigned int * items = NULL ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%06d_keys[%d]" , object_name.c_str(), id , cont_size) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "unsigned int %s_%06d_data[%d]" , object_name.c_str(), id , cont_size) ;
items = (unsigned int*)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (char *)((iter->first).c_str()) ;
items[ii] = (iter->second).stl_id ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_stlkey_ndata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
int status ;
unsigned int * keys = NULL ;
typename STL::mapped_type * items ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "unsigned int %s_%06d_keys[%d]" , object_name.c_str(), id , cont_size) ;
keys = (unsigned int*)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%06d_data[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id , cont_size) ;
items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (iter->first).stl_id ;
items[ii] = iter->second ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_stlkey_sdata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
unsigned int * keys = NULL ;
char ** items ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "unsigned int %s_%06d_keys[%d]" , object_name.c_str(), id , cont_size) ;
keys = (unsigned int*)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%06d_data[%d]" , object_name.c_str(), id , cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (iter->first).stl_id ;
items[ii] = (char *)((iter->second).c_str()) ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_map_stlkey_stldata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
typename STL::iterator iter ;
unsigned int * keys = NULL ;
unsigned int * items = NULL ;
cont_size = in_map.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "unsigned int %s_%06d_keys[%d]" , object_name.c_str(), id , cont_size) ;
keys = (unsigned int*)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "unsigned int %s_%06d_data[%d]" , object_name.c_str(), id , cont_size) ;
items = (unsigned int*)TMM_declare_var_s(var_declare) ;
/* copy the contents of the map the 2 arrays */
for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) {
keys[ii] = (iter->first).stl_id ;
items[ii] = (iter->second).stl_id ;
}
}
return 0 ;
}
/* For all restore_map_stl varieties.
Find the arrays the map data was stored in the checkpoint using ref_attributes
From the address of the resulting ref_attributes, we can figure out the number
of items that were stored in the checkpoint. Knowing the size, we can restore
the map from the 2 arrays.
*/
template <class STL>
int restore_trick_map_nkey_ndata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
typename STL::key_type * keys ;
typename STL::mapped_type * items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (typename STL::key_type *)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<typename STL::key_type , typename STL::mapped_type>(keys[ii], items[ii])) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_nkey_sdata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
typename STL::key_type * keys ;
char ** items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (typename STL::key_type *)keys_ref->address ;
items = (char **)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<typename STL::key_type, std::string>(keys[ii] , std::string(items[ii]))) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_nkey_stldata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
typename STL::key_type * keys ;
unsigned int * items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (typename STL::key_type *)keys_ref->address ;
items = (unsigned int *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
typename STL::mapped_type mt ;
mt.stl_id = items[ii] ;
mt.restart( object_name ) ;
in_map.insert( std::pair<typename STL::key_type, typename STL::mapped_type>(keys[ii] , mt)) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_skey_ndata( STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
typename STL::mapped_type * items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<std::string , typename STL::mapped_type>(std::string(keys[ii]), items[ii])) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_skey_sdata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
char ** items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (char **)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_map.insert( std::pair<std::string, std::string>(std::string(keys[ii]) , std::string(items[ii]))) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_skey_stldata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
unsigned int * items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (unsigned int *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
typename STL::mapped_type mt ;
mt.stl_id = items[ii] ;
mt.restart( object_name ) ;
in_map.insert( std::pair<std::string, typename STL::mapped_type>(std::string(keys[ii]) , mt)) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_stlkey_ndata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
unsigned int * keys ;
typename STL::mapped_type * items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (unsigned int *)keys_ref->address ;
items = (typename STL::mapped_type *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
typename STL::key_type kt ;
kt.stl_id = keys[ii] ;
kt.restart( object_name ) ;
in_map.insert( std::pair<typename STL::key_type, typename STL::mapped_type>(kt , items[ii])) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_stlkey_sdata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
unsigned int * keys ;
char ** items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (unsigned int *)keys_ref->address ;
items = (char **)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
typename STL::key_type kt ;
kt.stl_id = keys[ii] ;
kt.restart( object_name ) ;
in_map.insert( std::pair<typename STL::key_type, typename STL::mapped_type>(kt , std::string(items[ii]))) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_map_stlkey_stldata(STL & in_map , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
unsigned int * keys ;
unsigned int * items ;
in_map.clear() ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (unsigned int *)keys_ref->address ;
items = (unsigned int *)items_ref->address ;
cont_size = get_size((char *)keys) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
typename STL::key_type kt ;
kt.stl_id = keys[ii] ;
kt.restart( object_name ) ;
typename STL::mapped_type mt ;
mt.stl_id = items[ii] ;
mt.restart( object_name ) ;
in_map.insert( std::pair<typename STL::key_type, typename STL::mapped_type>(kt , mt)) ;
}
}
return 0 ;
}
#endif

View File

@ -1,459 +0,0 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
*/
#ifndef CHECKPOINT_TRICK_PAIR_HH
#define CHECKPOINT_TRICK_PAIR_HH
#include <string>
#include <algorithm>
#include <typeinfo>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "trick/STLInterface.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
template <class STL>
int checkpoint_trick_pair_nkey_ndata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
int status ;
typename STL::first_type * keys ;
typename STL::second_type * items ;
sprintf(var_declare, "%s %s_%06d_keys[1]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), id) ;
keys = (typename STL::first_type *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%06d_data[1]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id) ;
items = (typename STL::second_type *)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = in_pair.first ;
items[0] = in_pair.second ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_nkey_sdata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
int status ;
typename STL::first_type * keys ;
char ** items ;
sprintf(var_declare, "%s %s_%06d_keys[1]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), id ) ;
keys = (typename STL::first_type *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%06d_data[1]" , object_name.c_str(), id ) ;
items = (char **)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = in_pair.first ;
items[0] = (char *)((in_pair.second).c_str()) ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_nkey_stldata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
int status ;
typename STL::first_type * keys ;
unsigned int * items = NULL ;
sprintf(var_declare, "%s %s_%06d_keys[1]" ,
abi::__cxa_demangle(typeid(*keys).name(), 0, 0, &status ), object_name.c_str(), id ) ;
keys = (typename STL::first_type *)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "unsigned int %s_%06d_data[1]" , object_name.c_str(), id ) ;
items = (unsigned int*)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = in_pair.first ;
items[0] = (in_pair.second).stl_id ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_skey_ndata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
int status ;
char ** keys ;
typename STL::second_type * items ;
sprintf(var_declare, "char * %s_%06d_keys[1]" , object_name.c_str(), id ) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%06d_data[1]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id ) ;
items = (typename STL::second_type *)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = (char *)((in_pair.first).c_str()) ;
items[0] = in_pair.second ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_skey_sdata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
char ** keys ;
char ** items ;
sprintf(var_declare, "char * %s_%06d_keys[1]" , object_name.c_str(), id ) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%06d_data[1]" , object_name.c_str(), id ) ;
items = (char **)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = (char *)((in_pair.first).c_str()) ;
items[0] = (char *)((in_pair.second).c_str()) ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_skey_stldata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
char ** keys ;
unsigned int * items = NULL ;
sprintf(var_declare, "char * %s_%06d_keys[1]" , object_name.c_str(), id ) ;
keys = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "unsigned int %s_%06d_data[1]" , object_name.c_str(), id ) ;
items = (unsigned int*)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = (char *)((in_pair.first).c_str()) ;
items[0] = (in_pair.second).stl_id ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_stlkey_ndata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
int status ;
unsigned int * keys = NULL ;
typename STL::second_type * items ;
sprintf(var_declare, "unsigned int %s_%06d_keys[1]" , object_name.c_str(), id ) ;
keys = (unsigned int*)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "%s %s_%06d_data[1]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id ) ;
items = (typename STL::second_type *)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = (in_pair.first).stl_id ;
items[0] = in_pair.second ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_stlkey_sdata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
unsigned int * keys = NULL ;
char ** items ;
sprintf(var_declare, "unsigned int %s_%06d_keys[1]" , object_name.c_str(), id ) ;
keys = (unsigned int*)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%06d_data[1]" , object_name.c_str(), id ) ;
items = (char **)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = (in_pair.first).stl_id ;
items[0] = (char *)((in_pair.second).c_str()) ;
return 0 ;
}
template <class STL>
int checkpoint_trick_pair_stlkey_stldata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
unsigned int * keys = NULL ;
unsigned int * items = NULL ;
sprintf(var_declare, "unsigned int %s_%06d_keys[1]" , object_name.c_str(), id ) ;
keys = (unsigned int*)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "unsigned int %s_%06d_data[1]" , object_name.c_str(), id ) ;
items = (unsigned int*)TMM_declare_var_s(var_declare) ;
/* copy the contents of the pair the 2 arrays */
keys[0] = (in_pair.first).stl_id ;
items[0] = (in_pair.second).stl_id ;
return 0 ;
}
/* RESTORE */
template <class STL>
int restore_trick_pair_nkey_ndata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
typename STL::first_type * keys ;
typename STL::second_type * items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (typename STL::first_type *)keys_ref->address ;
items = (typename STL::second_type *)items_ref->address ;
in_pair.first = keys[0] ;
in_pair.second = items[0] ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_nkey_sdata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
typename STL::first_type * keys ;
char ** items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (typename STL::first_type *)keys_ref->address ;
items = (char **)items_ref->address ;
in_pair.first = keys[0] ;
in_pair.second = items[0] ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_nkey_stldata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
typename STL::first_type * keys ;
unsigned int * items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (typename STL::first_type *)keys_ref->address ;
items = (unsigned int *)items_ref->address ;
typename STL::second_type mt ;
mt.stl_id = items[0] ;
mt.restart( object_name ) ;
in_pair.first = keys[0] ;
in_pair.second = mt ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_skey_ndata( STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
typename STL::second_type * items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (typename STL::second_type *)items_ref->address ;
in_pair.first = keys[0] ;
in_pair.second = items[0] ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_skey_sdata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
char ** items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (char **)items_ref->address ;
in_pair.first = keys[0] ;
in_pair.second = items[0] ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_skey_stldata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
char ** keys ;
unsigned int * items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (char **)keys_ref->address ;
items = (unsigned int *)items_ref->address ;
typename STL::second_type mt ;
mt.stl_id = items[0] ;
mt.restart( object_name ) ;
in_pair.first = keys[0] ;
in_pair.second = mt ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_stlkey_ndata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
unsigned int * keys ;
typename STL::second_type * items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (unsigned int *)keys_ref->address ;
items = (typename STL::second_type *)items_ref->address ;
typename STL::first_type kt ;
kt.stl_id = keys[0] ;
kt.restart( object_name ) ;
in_pair.first = kt ;
in_pair.second = items[0] ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_stlkey_sdata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
unsigned int * keys ;
char ** items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (unsigned int *)keys_ref->address ;
items = (char **)items_ref->address ;
typename STL::first_type kt ;
kt.stl_id = keys[0] ;
kt.restart( object_name ) ;
in_pair.first = kt ;
in_pair.second = items[0] ;
}
return 0 ;
}
template <class STL>
int restore_trick_pair_stlkey_stldata(STL & in_pair , std::string object_name , unsigned int id ) {
char var_declare[128] ;
REF2 * keys_ref , * items_ref ;
unsigned int * keys ;
unsigned int * items ;
sprintf(var_declare, "%s_%06d_keys" , object_name.c_str(), id ) ;
keys_ref = ref_attributes(var_declare) ;
sprintf(var_declare, "%s_%06d_data" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( keys_ref != NULL && items_ref != NULL ) {
keys = (unsigned int *)keys_ref->address ;
items = (unsigned int *)items_ref->address ;
typename STL::first_type kt ;
kt.stl_id = keys[0] ;
kt.restart( object_name ) ;
typename STL::second_type mt ;
mt.stl_id = items[0] ;
mt.restart( object_name ) ;
in_pair.first = kt ;
in_pair.second = mt ;
}
return 0 ;
}
#endif

View File

@ -1,201 +0,0 @@
/*
PURPOSE: (Helpers to checkpoint STLs)
*/
#ifndef CHECKPOINT_TRICK_SEQUENCE_STL_HH
#define CHECKPOINT_TRICK_SEQUENCE_STL_HH
#include <string>
#include <iostream>
#include <algorithm>
#include <typeinfo>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include "trick/STLInterface.hh"
#include "trick/memorymanager_c_intf.h"
#include "trick/message_proto.h"
/*
These template routines perform the checkpoint and restore work for sequence STL types.
The sequence STL types include vectors, lists, deques, sets, and multisets.
There are 3 checkpoint and restore versions depending on the contained type.
*/
template <class STL>
int checkpoint_trick_sequence_stl(STL & in_stl , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
int status ;
typename STL::value_type * items = NULL ;
typename STL::iterator it ;
typename STL::iterator end ;
cont_size = in_stl.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%06d[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), id, cont_size) ;
items = (typename STL::value_type *)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ;
/* copy the contents of the stl */
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) {
items[ii] = *it ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_sequence_stl_string(STL & in_stl , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
const char ** items ;
typename STL::iterator it ;
typename STL::iterator end ;
cont_size = in_stl.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "char * %s_%06d[%d]" , object_name.c_str(), id , cont_size) ;
items = (const char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_SEQUENCE_STL_STRING with %s\n", var_declare) ;
/* copy the contents of the vector */
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) {
items[ii] = it->c_str() ;
}
}
return 0 ;
}
template <class STL>
int checkpoint_trick_sequence_stl_STLInterface(STL & in_stl , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
unsigned int * items = NULL ;
typename STL::iterator it ;
typename STL::iterator end ;
typename STL::value_type vt ;
cont_size = in_stl.size() ;
if ( cont_size > 0 ) {
sprintf(var_declare, "unsigned int %s_%06d[%d]" , object_name.c_str(), id, cont_size) ;
items = (unsigned int *)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ;
/* copy the contents of the stl */
for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) {
items[ii] = (*it).stl_id ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_sequence_stl(STL & in_stl , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * items_ref ;
typename STL::value_type * items ;
//message_publish(1, "RESTORE_SEQUENCE_STL %s_%s\n", object_name.c_str() , var_name.c_str()) ;
in_stl.clear() ;
sprintf(var_declare, "%s_%06d" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( items_ref != NULL ) {
items = (typename STL::value_type *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.insert( in_stl.end(), items[ii] ) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_sequence_stl_string(STL & in_stl , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * items_ref ;
char ** items ;
//message_publish(1, "in specialized vector template restore\n") ;
in_stl.clear() ;
sprintf(var_declare, "%s_%06d" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( items_ref != NULL ) {
items = (char **)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.insert( in_stl.end(), items[ii] ) ;
}
}
return 0 ;
}
template <class STL>
int restore_trick_sequence_stl_STLInterface(STL & in_stl , std::string object_name , unsigned int id ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
REF2 * items_ref ;
unsigned int * items ;
//message_publish(1, "RESTORE_SEQUENCE_STL %s_%s\n", object_name.c_str() , var_name.c_str()) ;
in_stl.clear() ;
sprintf(var_declare, "%s_%06d" , object_name.c_str(), id ) ;
items_ref = ref_attributes(var_declare) ;
if ( items_ref != NULL ) {
items = (unsigned int *)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
typename STL::value_type vt ;
vt.stl_id = items[ii] ;
vt.restart( object_name ) ;
in_stl.insert( in_stl.end(), vt ) ;
}
}
return 0 ;
}
#endif

View File

@ -76,6 +76,7 @@ void ref_free( REF2 *R ) ;
int get_enumerated(const char* name, V_DATA* v_data) ;
void TMM_add_checkpoint_alloc_dependency(const char * name) ;
#ifdef __cplusplus
}
#endif

View File

@ -34,6 +34,7 @@ extern "C" {
TRICK_ENUMERATED = 21, /* User defined type (enumeration) */
TRICK_STRUCTURED = 22, /* User defined type (struct/class) */
TRICK_OPAQUE_TYPE = 23, /* User defined type (where type details are as yet unknown) */
TRICK_STL = 24, /* Standard template library type */
TRICK_NUMBER_OF_TYPES
} TRICK_TYPE ;

View File

@ -1,131 +0,0 @@
#ifndef TRICK_DEQUE_HH
#define TRICK_DEQUE_HH
#include <string>
#include <deque>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_sequence_stl.hh"
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Tp, typename _Alloc = std::allocator<_Tp> , class dummy = void >
class deque {} ;
// Template use for everything except strings and other STL types.
template <typename _Tp , typename _Alloc >
class deque<_Tp, _Alloc,
typename std::enable_if< !std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::deque<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
deque() {} ;
// fill constructor
explicit deque(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::deque<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::deque<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
deque(const deque & __x) : std::deque<_Tp,_Alloc>(__x) {}
// assignment operator
deque& operator=(const deque & __x) {
std::deque<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
} ;
// Specialized deque for other Trick STL types.
template <typename _Tp , typename _Alloc >
class deque<_Tp, _Alloc, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Tp>::value>::type > : public std::deque<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
deque() {} ;
// fill constructor
explicit deque(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::deque<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::deque<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
deque(const deque & __x) : std::deque<_Tp,_Alloc>(__x) {}
// assignment operator
deque& operator=(const deque & __x) {
std::deque<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
} ;
// Specialized deque for strings
template <typename _Tp , typename _Alloc >
class deque<_Tp, _Alloc, typename std::enable_if<std::is_same<_Tp,std::string>::value>::type > : public std::deque<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
deque() {} ;
// fill constructor
explicit deque(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::deque<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::deque<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
deque(const deque & __x) : std::deque<_Tp,_Alloc>(__x) {}
// assignment operator
deque& operator=(const deque & __x) {
std::deque<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -1,131 +0,0 @@
#ifndef TRICK_LIST_HH
#define TRICK_LIST_HH
#include <string>
#include <list>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_sequence_stl.hh"
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Tp, typename _Alloc = std::allocator<_Tp> , class dummy = void >
class list {} ;
// Template use for everything except strings and other STL types.
template <typename _Tp , typename _Alloc >
class list<_Tp, _Alloc,
typename std::enable_if< !std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::list<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
list() {} ;
// fill constructor
explicit list(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::list<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
list(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::list<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
list(const list & __x) : std::list<_Tp,_Alloc>(__x) {}
// assignment operator
list& operator=(const list & __x) {
std::list<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
} ;
// Specialized list for other Trick STL types.
template <typename _Tp , typename _Alloc >
class list<_Tp, _Alloc, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Tp>::value>::type > : public std::list<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
list() {} ;
// fill constructor
explicit list(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::list<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
list(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::list<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
list(const list & __x) : std::list<_Tp,_Alloc>(__x) {}
// assignment operator
list& operator=(const list & __x) {
std::list<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
} ;
// Specialized list for strings
template <typename _Tp , typename _Alloc >
class list<_Tp, _Alloc, typename std::enable_if<std::is_same<_Tp,std::string>::value>::type > : public std::list<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
list() {} ;
// fill constructor
explicit list(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::list<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
list(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::list<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
list(const list & __x) : std::list<_Tp,_Alloc>(__x) {}
// assignment operator
list& operator=(const list & __x) {
std::list<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -1,851 +0,0 @@
#ifndef TRICK_MAP_HH
#define TRICK_MAP_HH
#include <string>
#include <map>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_map_stl.hh"
#include "trick/STLUtilities.hh"
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<_Tp> , class dummy = void >
class map {} ;
// Template used when both key and data are not strings or other STLs
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value &&
!std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_nkey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_nkey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map normal key, string data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_same<_Tp,std::string>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_nkey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_nkey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map normal key, STL data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_nkey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_nkey_stldata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map string key, normal data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_same<_Key,std::string>::value &&
!std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_skey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_skey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map string key, string data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_same<_Key,std::string>::value &&
std::is_same<_Tp,std::string>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_skey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_skey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map string key, STL data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_same<_Key,std::string>::value &&
std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_skey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_skey_stldata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map STL key, normal data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_Key>::value &&
!std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_stlkey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_stlkey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map STL key, string data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_same<_Tp,std::string>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_stlkey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_stlkey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized map STL key, STL data. (Really? Who in their right mind would do this?)
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class map<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::map<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
map() {} ;
// iterator range constructor
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::map<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
map(const map & __x) : std::map<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
map& operator=(const map & __x) {
std::map<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_stlkey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_stlkey_stldata( *this , obj_name , stl_id ) ;
}
} ;
/* MULTIMAP */
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<_Tp> , class dummy = void >
class multimap {} ;
// Template used when both key and data are not strings or other STLs
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value &&
!std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_nkey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_nkey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap normal key, string data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_same<_Tp,std::string>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_nkey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_nkey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap normal key, STL data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_nkey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_nkey_stldata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap string key, normal data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_same<_Key,std::string>::value &&
!std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_skey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_skey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap string key, string data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_same<_Key,std::string>::value &&
std::is_same<_Tp,std::string>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_skey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_skey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap string key, STL data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_same<_Key,std::string>::value &&
std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_skey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_skey_stldata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap STL key, normal data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_Key>::value &&
!std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_stlkey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_stlkey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap STL key, string data.
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_same<_Tp,std::string>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_stlkey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_stlkey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multimap STL key, STL data. (Really? Who in their right mind would do this?)
template <typename _Key, typename _Tp , typename _Compare, typename _Alloc >
class multimap<_Key, _Tp, _Compare, _Alloc,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_Key>::value &&
std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::multimap<_Key,_Tp,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multimap() {} ;
// iterator range constructor
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multimap(const multimap & __x) : std::multimap<_Key,_Tp,_Compare,_Alloc>(__x) {}
// assignment operator
multimap& operator=(const multimap & __x) {
std::multimap<_Key,_Tp,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_map_stlkey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_map_stlkey_stldata( *this , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -1,382 +0,0 @@
#ifndef TRICK_PAIR_HH
#define TRICK_PAIR_HH
#include <string>
#include <utility>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_pair_stl.hh"
#include "trick/STLUtilities.hh"
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _T1, typename _T2, class dummy = void >
class pair {} ;
// Template used when both key and data are not strings or other STLs
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< !std::is_same<_T1,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_T1>::value &&
!std::is_same<_T2,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_T2>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {}
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_nkey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_nkey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair normal key, string data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< !std::is_same<_T1,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_T1>::value &&
std::is_same<_T2,std::string>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_nkey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_nkey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair normal key, STL data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< !std::is_same<_T1,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_T1>::value &&
std::is_base_of<Trick::STLInterface,_T2>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_nkey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_nkey_stldata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair string key, normal data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< std::is_same<_T1,std::string>::value &&
!std::is_same<_T2,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_T2>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_skey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_skey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair string key, string data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< std::is_same<_T1,std::string>::value &&
std::is_same<_T2,std::string>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_skey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_skey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair string key, STL data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< std::is_same<_T1,std::string>::value &&
std::is_base_of<Trick::STLInterface,_T2>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_skey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_skey_stldata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair STL key, normal data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_T1>::value &&
!std::is_same<_T2,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_T2>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_stlkey_ndata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_stlkey_ndata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair STL key, string data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_T1>::value &&
std::is_same<_T2,std::string>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_stlkey_sdata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_stlkey_sdata( *this , obj_name , stl_id ) ;
}
} ;
// Specialized pair STL key, STL data.
template <typename _T1, typename _T2 >
class pair<_T1, _T2,
typename std::enable_if< std::is_base_of<Trick::STLInterface,_T1>::value &&
std::is_base_of<Trick::STLInterface,_T2>::value
>::type > : public std::pair<_T1,_T2> , public STLInterface {
public:
// default constructor
pair() {} ;
// incoming data constructor
pair(const _T1& __a, const _T2& __b) : std::pair<_T1,_T2>(__a,__b) {}
// templated copy constructor
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : std::pair<_T1,_T2>(__p) {}
// assignment operator
pair& operator=(const pair & __x) {
std::pair<_T1,_T2>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_pair_stlkey_stldata( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::checkpoint
virtual void post_checkpoint( std::string obj_name ) {
delete_trick_map_stl( obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_pair_stlkey_stldata( *this , obj_name , stl_id ) ;
}
} ;
template<class _T1, class _T2>
inline pair<_T1, _T2> make_pair(_T1 __x, _T2 __y) { return pair<_T1, _T2>(__x, __y); }
} ;
#endif

View File

@ -1,160 +0,0 @@
#ifndef TRICK_QUEUE_HH
#define TRICK_QUEUE_HH
#include <string>
#include <queue>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_sequence_stl.hh"
/*
This algorithm depends on the queue container type is called "c" and is
a protected variable. There are no guarantees this works with anything but
the current gcc versions we are using.
*/
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Tp, typename _Sequence = std::deque<_Tp>, class dummy = void >
class queue {} ;
// Template use for everything except strings and other STL types.
template <typename _Tp , typename _Sequence >
class queue<_Tp, _Sequence,
typename std::enable_if< !std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::queue<_Tp, _Sequence> , public STLInterface {
public:
// default constructor
explicit queue(const _Sequence& __c = _Sequence()) : std::queue<_Tp, _Sequence>(__c) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( std::queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( std::queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
// Specialized queue for strings
template <typename _Tp , typename _Sequence >
class queue<_Tp, _Sequence, typename std::enable_if<std::is_same<_Tp,std::string>::value>::type >
: public std::queue<_Tp, _Sequence> , public STLInterface {
public:
// default constructor
explicit queue(const _Sequence& __c = _Sequence()) : std::queue<_Tp, _Sequence>(__c) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( std::queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( std::queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
// Specialized queue for other Trick STL types.
template <typename _Tp , typename _Sequence >
class queue<_Tp, _Sequence, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Tp>::value>::type >
: public std::queue<_Tp, _Sequence> , public STLInterface {
public:
// default constructor
explicit queue(const _Sequence& __s = _Sequence()) : std::queue<_Tp, _Sequence>(__s) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( std::queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( std::queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
/* PRIORITY QUEUE */
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Tp, typename _Sequence = std::vector<_Tp>,
typename _Compare = std::less<typename _Sequence::value_type> , class dummy = void >
class priority_queue {} ;
// Template use for everything except strings and other STL types.
template <typename _Tp , typename _Sequence , typename _Compare >
class priority_queue<_Tp, _Sequence, _Compare,
typename std::enable_if< !std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::priority_queue<_Tp, _Sequence, _Compare> , public STLInterface {
public:
// default constructor
explicit priority_queue(const _Compare& __x = _Compare(), const _Sequence& __s = _Sequence())
: std::priority_queue<_Tp, _Sequence, _Compare>(__x, __s) { }
// iterator constructor
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: std::priority_queue<_Tp, _Sequence, _Compare>(__first, __last, __x, __s) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( std::priority_queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( std::priority_queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
// Specialized priority_queue for strings
template <typename _Tp , typename _Sequence , typename _Compare >
class priority_queue<_Tp, _Sequence, _Compare, typename std::enable_if<std::is_same<_Tp,std::string>::value>::type >
: public std::priority_queue<_Tp, _Sequence, _Compare> , public STLInterface {
public:
// default constructor
explicit priority_queue(const _Compare& __x = _Compare(), const _Sequence& __s = _Sequence())
: std::priority_queue<_Tp, _Sequence, _Compare>(__x, __s) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( std::priority_queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( std::priority_queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
// Specialized priority_queue for other Trick STL types.
template <typename _Tp , typename _Sequence , typename _Compare >
class priority_queue<_Tp, _Sequence, _Compare, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Tp>::value>::type >
: public std::priority_queue<_Tp, _Sequence, _Compare> , public STLInterface {
public:
// default constructor
explicit priority_queue(const _Compare& __x = _Compare(), const _Sequence& __s = _Sequence())
: std::priority_queue<_Tp, _Sequence, _Compare>(__x, __s) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( std::priority_queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( std::priority_queue<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -1,256 +0,0 @@
#ifndef TRICK_SET_HH
#define TRICK_SET_HH
#include <string>
#include <set>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_sequence_stl.hh"
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Key, typename _Compare = std::less<_Key>, typename _Alloc = std::allocator<_Key>, class dummy = void >
class set {} ;
// Template use for everything except strings and other STL types.
template <typename _Key , typename _Compare , typename _Alloc >
class set<_Key, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value
>::type > : public std::set<_Key,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
set() {} ;
// iterator range constructor
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last) : std::set<_Key,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::set<_Key,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
set(const set & __x) : std::set<_Key,_Compare,_Alloc>(__x) {}
// assignment operator
set& operator=(const set & __x) {
std::set<_Key,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
} ;
// Specialized set for other Trick STL types.
template <typename _Key , typename _Compare , typename _Alloc >
class set<_Key, _Compare, _Alloc, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Key>::value>::type >
: public std::set<_Key,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
set() {} ;
// iterator range constructor
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last) : std::set<_Key,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::set<_Key,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
set(const set & __x) : std::set<_Key,_Compare,_Alloc>(__x) {}
// assignment operator
set& operator=(const set & __x) {
std::set<_Key,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
} ;
// Specialized set for strings
template <typename _Key , typename _Compare , typename _Alloc >
class set<_Key, _Compare, _Alloc, typename std::enable_if<std::is_same<_Key,std::string>::value>::type >
: public std::set<_Key,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
set() {} ;
// iterator range constructor
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last) : std::set<_Key,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::set<_Key,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
set(const set & __x) : std::set<_Key,_Compare,_Alloc>(__x) {}
// assignment operator
set& operator=(const set & __x) {
std::set<_Key,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
} ;
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Key, typename _Compare = std::less<_Key>, typename _Alloc = std::allocator<_Key>, class dummy = void >
class multiset {} ;
// Template use for everything except strings and other STL types.
template <typename _Key , typename _Compare , typename _Alloc >
class multiset<_Key, _Compare, _Alloc,
typename std::enable_if< !std::is_same<_Key,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Key>::value
>::type > : public std::multiset<_Key,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multiset() {} ;
// iterator range constructor
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last) : std::multiset<_Key,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multiset<_Key,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multiset(const multiset & __x) : std::multiset<_Key,_Compare,_Alloc>(__x) {}
// assignment operator
multiset& operator=(const multiset & __x) {
std::multiset<_Key,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multiset for other Trick STL types.
template <typename _Key , typename _Compare , typename _Alloc >
class multiset<_Key, _Compare, _Alloc, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Key>::value>::type >
: public std::multiset<_Key,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multiset() {} ;
// iterator range constructor
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last) : std::multiset<_Key,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multiset<_Key,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multiset(const multiset & __x) : std::multiset<_Key,_Compare,_Alloc>(__x) {}
// assignment operator
multiset& operator=(const multiset & __x) {
std::multiset<_Key,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
} ;
// Specialized multiset for strings
template <typename _Key , typename _Compare , typename _Alloc >
class multiset<_Key, _Compare, _Alloc, typename std::enable_if<std::is_same<_Key,std::string>::value>::type >
: public std::multiset<_Key,_Compare,_Alloc> , public STLInterface {
public:
// default constructor
multiset() {} ;
// iterator range constructor
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last) : std::multiset<_Key,_Compare,_Alloc>(__first, __last) {}
// iterator range constructor with compare function
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const _Alloc& __a = _Alloc()) : std::multiset<_Key,_Compare,_Alloc>(__first, __last,__comp,__a) {}
// copy constructor
multiset(const multiset & __x) : std::multiset<_Key,_Compare,_Alloc>(__x) {}
// assignment operator
multiset& operator=(const multiset & __x) {
std::multiset<_Key,_Compare,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -1,83 +0,0 @@
#ifndef TRICK_STACK_HH
#define TRICK_STACK_HH
#include <string>
#include <stack>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_sequence_stl.hh"
/*
This algorithm depends on the stack container type is called "c" and is
a protected variable. There are no guarantees this works with anything but
the current gcc versions we are using.
*/
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Tp, typename _Sequence = std::deque<_Tp>, class dummy = void >
class stack {} ;
// Template use for everything except strings and other STL types.
template <typename _Tp , typename _Sequence >
class stack<_Tp, _Sequence, typename std::enable_if< !std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::stack<_Tp, _Sequence> , public STLInterface {
public:
// default constructor
explicit stack(const _Sequence& __c = _Sequence()) : std::stack<_Tp, _Sequence>(__c) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( std::stack<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( std::stack<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
// Specialized stack for strings
template <typename _Tp , typename _Sequence >
class stack<_Tp, _Sequence, typename std::enable_if<std::is_same<_Tp,std::string>::value>::type >
: public std::stack<_Tp, _Sequence> , public STLInterface {
public:
// default constructor
explicit stack(const _Sequence& __c = _Sequence()) : std::stack<_Tp, _Sequence>(__c) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( std::stack<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( std::stack<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
// Specialized stack for other Trick STL types.
template <typename _Tp, typename _Sequence >
class stack<_Tp, _Sequence, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Tp>::value>::type >
: public std::stack<_Tp, _Sequence> , public STLInterface {
public:
// default constructor
explicit stack(const _Sequence& __c = _Sequence()) : std::stack<_Tp, _Sequence>(__c) { }
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( std::stack<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( std::stack<_Tp, _Sequence>::c , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -1,133 +0,0 @@
#ifndef TRICK_VECTOR_HH
#define TRICK_VECTOR_HH
#include <string>
#include <vector>
#ifndef SWIG
#include <type_traits>
#endif
#include "trick/checkpoint_trick_sequence_stl.hh"
namespace Trick {
// Empty template. This version is not used, it allows us to specialize below.
template <typename _Tp, typename _Alloc = std::allocator<_Tp> , class dummy = void >
class vector {} ;
// Template use for everything except strings and other STL types.
template <typename _Tp , typename _Alloc >
class vector<_Tp, _Alloc,
typename std::enable_if< !std::is_same<_Tp,std::string>::value &&
!std::is_base_of<Trick::STLInterface,_Tp>::value
>::type > : public std::vector<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
vector() {} ;
// fill constructor
explicit vector(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::vector<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::vector<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
vector(const vector & __x) : std::vector<_Tp,_Alloc>(__x) {}
// assignment operator
vector& operator=(const vector & __x) {
std::vector<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl( *this , obj_name , stl_id ) ;
}
} ;
// Specialized vector for other Trick STL types.
template <typename _Tp , typename _Alloc >
class vector<_Tp, _Alloc, typename std::enable_if<std::is_base_of<Trick::STLInterface,_Tp>::value>::type >
: public std::vector<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
vector() {} ;
// fill constructor
explicit vector(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::vector<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::vector<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
vector(const vector & __x) : std::vector<_Tp,_Alloc>(__x) {}
// assignment operator
vector& operator=(const vector & __x) {
std::vector<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_STLInterface( *this , obj_name , stl_id ) ;
}
} ;
// Specialized vector for strings
template <typename _Tp , typename _Alloc >
class vector<_Tp, _Alloc, typename std::enable_if<std::is_same<_Tp,std::string>::value>::type >
: public std::vector<_Tp,_Alloc> , public STLInterface {
public:
// default constructor
vector() {} ;
// fill constructor
explicit vector(size_t __n, const _Tp & __value = _Tp(),
const _Alloc & __a = _Alloc()) : std::vector<_Tp,_Alloc>(__n, __value, __a) {}
// iterator range constructor
template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
const _Alloc& __a = _Alloc()) : std::vector<_Tp,_Alloc>(__first, __last, __a) {}
// copy constructor
vector(const vector & __x) : std::vector<_Tp,_Alloc>(__x) {}
// assignment operator
vector& operator=(const vector & __x) {
std::vector<_Tp,_Alloc>::operator = (__x) ;
return *this ;
}
// inherited STLInterface::checkpoint
virtual void checkpoint( std::string obj_name ) {
checkpoint_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
// inherited STLInterface::restart
virtual void restart( std::string obj_name ) {
restore_trick_sequence_stl_string( *this , obj_name , stl_id ) ;
}
} ;
} ;
#endif

View File

@ -87,9 +87,10 @@ sub read_files_to_process() {
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
push @defines , "-DTRICK_VER=$year" ;
push @defines , "-DSWIG" ;
push @defines , "-std=c++11" ;
# Get the list header files from the compiler to compare to what get_headers processed.
open FILE_LIST, "$cc -MM -DSWIG @include_paths @defines S_source.hh |" ;
open FILE_LIST, "$cc -MM @include_paths @defines S_source.hh |" ;
my $dir ;
$dir = dirname($s_source_full_path) ;
while ( <FILE_LIST> ) {
@ -172,7 +173,7 @@ sub make_swig_makefile() {
SWIG_FLAGS ?=
SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers
ifeq (\$(IS_CC_CLANG), 1)
SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized
SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized -Wno-deprecated-register
endif
ifdef TRICK_VERBOSE_BUILD

View File

@ -96,7 +96,8 @@ $(TRICK_LIB_DIR):
$(IO_C_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.c | $(OBJ_DIR)
$(TRICK_CC) $(TRICK_CFLAGS) $(TRICK_SYSTEM_CFLAGS) -c $< -o $@
$(IO_CPP_OBJS): TRICK_CXXFLAGS += -Wno-invalid-offsetof
$(IO_CPP_OBJS): TRICK_SYSTEM_CXXFLAGS += -std=c++11
$(IO_CPP_OBJS): TRICK_SYSTEM_CXXFLAGS += -Wno-invalid-offsetof
ifeq ($(IS_CC_CLANG), 0)
# cannot get an "expr" command to work on all platforms. Falling back to reliable perl. :)
GCCVERSIONGTEQ48 := $(shell perl -e 'printf "%d\n", ($(GCC_MAJOR)>4)||(($(GCC_MAJOR)==4)&&($(GCC_MINOR)>=8)) ;' )
@ -105,7 +106,6 @@ ifeq ($(IS_CC_CLANG), 0)
endif
endif
$(IO_CPP_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.cpp | $(OBJ_DIR)
$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) -c $< -o $@

View File

@ -93,12 +93,6 @@ a replacement SimObject will create an uncompilable sim.
##include "trick/RtiStager.hh"
##include "trick/RtiExec.hh"
// TODO: move users away from this STL checkpoint method
##include "trick/checkpoint_stl.hh"
// TODO: move users away from this STL checkpoint method
#include "trick/stl_s_define_macro.hh"
// This is a user header block. Code here is copied without processing to S_source.hh
%header{
@ -230,11 +224,6 @@ class CheckPointRestartSimObject : public Trick::SimObject {
{TRK} P0 ("freeze") cpr.load_checkpoint_job() ;
{TRK} P0 ("end_of_frame") cpr.load_checkpoint_job() ;
{TRK} P0 ("checkpoint") cpr.pre_checkpoint() ;
{TRK} P0 ("post_checkpoint") cpr.post_checkpoint() ;
{TRK} P0 ("restart") cpr.restart() ;
}
}
CheckPointRestartSimObject trick_cpr ;
@ -382,7 +371,7 @@ class EventManagerSimObject : public Trick::SimObject {
public:
Trick::EventManager em ;
Trick::EventProcessor ep ;
std::vector< ThreadProcessEventSimObject * > thread_process_event_so ;
std::vector< ThreadProcessEventSimObject * > thread_process_event_so ; // ** ignore for checkpointing
void create_thread_process_event() {
unsigned int ii ;
@ -748,7 +737,7 @@ class InjectorSimObject : public Trick::SimObject {
public:
Trick::RtiStager rtis ;
std::vector< InjectorExecSimObject * > injector_executor_so ;
std::vector< InjectorExecSimObject * > injector_executor_so ; // trick_io(**)
void create_injector_executors() {
unsigned int ii ;
@ -801,6 +790,5 @@ UnitTestSimObject trick_utest ;
// Include optional external clocks
#include "sim_objects/TPROClock.sm"
#include "sim_objects/BC635Clock.sm"
#include "sim_objects/STL.sm"
#endif

View File

@ -2,21 +2,18 @@
def main():
#trick.echo_jobs_on()
simControlPanel = trick.SimControlPanel()
simControlPanel.thisown = 0
trick.add_external_application(simControlPanel)
trick.real_time_enable()
#trick.sim_control_panel_set_enabled(True)
#trick.real_time_enable()
#trick.itimer_enable()
trick.checkpoint_post_init(True)
trick.checkpoint_end(True)
trick.checkpoint_pre_init(True)
#trick.checkpoint_post_init(True)
#trick.checkpoint_end(True)
trick.freeze(2.0)
#trick.freeze(2.0)
the_object.stlc2.name = "Daisy"
# Data recording HDF5 test
trick.exec_set_software_frame(0.10)
trick.exec_set_freeze_frame(0.10)
trick.stop(5.0)

View File

@ -4,8 +4,6 @@ def main():
trick.checkpoint_post_init(True)
trick.checkpoint_end(True)
the_object.stlc2.name = "Daisy"
# Data recording HDF5 test
trick.exec_set_freeze_frame(0.10)
trick.stop(5.0)

View File

@ -1,46 +1,18 @@
#include "sim_objects/default_trick_sys.sm"
##include "stl_checkpoint/include/STLCheckpoint.hh"
##include "stl_checkpoint/include/STLCompanion.hh"
/* This object tests having 2 of the same type of object containing STLs in the same sim_object.
The checkpoints use the name of the objects to give the STLs unique and identifiable names
in the checkpoint. */
##include "STLCheckpoint.hh"
class theSimObject : public Trick::SimObject {
public:
STLCheckpoint stlc ;
STLCheckpoint stlc2 ;
STLCompanion gc ;
/** Constructor to add the jobs */
theSimObject() : stlc(std::string("Petunia")) , stlc2() {
theSimObject() : stlc("Petunia") {
(1.0, "scheduled") stlc.speak() ;
("checkpoint") gc.checkpoint(&stlc, name + std::string("_stlc")) ;
("checkpoint") gc.checkpoint(&stlc2, name + std::string("_stlc2")) ;
("post_checkpoint") gc.post_checkpoint(&stlc, name + std::string("_stlc")) ;
("post_checkpoint") gc.post_checkpoint(&stlc2, name + std::string("_stlc2")) ;
("restart") gc.restart(&stlc, name + std::string("_stlc")) ;
("restart") gc.restart(&stlc2, name + std::string("_stlc2")) ;
}
} ;
// Multiple simobjects
theSimObject the_object ;
theSimObject the_object2 ;
// Connect objects
void create_connections() {
// Set the default termination time
trick_sys.sched.set_terminate_time(10.0) ;
trick_sys.sched.set_freeze_frame(0.10) ;
}

View File

@ -2,3 +2,4 @@
TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I./models
#TRICK_CXXFLAGS += -std=c++11

View File

@ -0,0 +1,304 @@
#include "sim_services/Message/include/message_proto.h"
#include "STLCheckpoint.hh"
/* These 2 constructors add different data to an STLCheckpoint. */
STLCheckpoint::STLCheckpoint() {
return ;
}
STLCheckpoint::STLCheckpoint(std::string in_name) :
vector_vector_double(4, std::vector<double>(3)) ,
vector_vector_vector_double(5, std::vector<std::vector<double> >(4, std::vector<double>(3)))
{
name = in_name ;
double_map[44.4] = 444.4 ;
double_map[55.5] = 555.5 ;
double_map[66.6] = 666.6 ;
string_key_map[std::string("four")] = 4 ;
string_key_map[std::string("five")] = 5 ;
string_key_map[std::string("six")] = 6 ;
string_data_map[7] = std::string("seiben") ;
string_data_map[8] = std::string("acht") ;
string_data_map[9] = std::string("neun") ;
std::vector< int > v ;
v.push_back(2) ;
v.push_back(4) ;
v.push_back(6) ;
v.push_back(8) ;
map_int_vector_int[1] = v ;
std::pair< int , int > p ;
p.first = 24 ;
p.second = 30 ;
gcd[p] = 6 ;
p.first = 50 ;
p.second = 60 ;
std::pair< int , int > q ;
q.first = 70 ;
q.second = 80 ;
map_pair_pair[p] = q ;
p.first = 3 ;
p.second = 5 ;
v.clear() ;
v.push_back(15) ;
v.push_back(30) ;
v.push_back(45) ;
v.push_back(60) ;
common_multiples.insert(std::pair< std::pair< int, int >, std::vector< int > >(p,v)) ;
string_map[std::string("sister")] = std::string("Lisa") ;
string_map[std::string("dog")] = std::string("Santa's Little Helper") ;
int_multimap.insert(std::pair<int, int>(44,444)) ;
int_multimap.insert(std::pair<int, int>(55,555)) ;
int_multimap.insert(std::pair<int, int>(66,666)) ;
int_multimap.insert(std::pair<int, int>(44,444)) ;
int_multimap.insert(std::pair<int, int>(55,555)) ;
int_multimap.insert(std::pair<int, int>(66,666)) ;
string_key_multimap.insert(std::pair<std::string, int>("four", 4)) ;
string_key_multimap.insert(std::pair<std::string, int>("five", 5)) ;
string_key_multimap.insert(std::pair<std::string, int>("six", 6)) ;
string_key_multimap.insert(std::pair<std::string, int>("four", 44)) ;
string_key_multimap.insert(std::pair<std::string, int>("five", 55)) ;
string_key_multimap.insert(std::pair<std::string, int>("six", 66)) ;
string_data_multimap.insert(std::pair<int, std::string>(7, "seiben")) ;
string_data_multimap.insert(std::pair<int, std::string>(8, "acht")) ;
string_data_multimap.insert(std::pair<int, std::string>(9, "neun")) ;
string_data_multimap.insert(std::pair<int, std::string>(7, "seven")) ;
string_data_multimap.insert(std::pair<int, std::string>(8, "eight")) ;
string_data_multimap.insert(std::pair<int, std::string>(9, "nine")) ;
string_multimap.insert(std::pair<std::string, std::string>("sister","Lisa")) ;
string_multimap.insert(std::pair<std::string, std::string>("dog","Santa's Little Helper")) ;
string_multimap.insert(std::pair<std::string, std::string>("sister","Meg")) ;
string_multimap.insert(std::pair<std::string, std::string>("dog","Brian")) ;
double_vector.push_back(4.0) ;
double_vector.push_back(5.0) ;
double_vector.push_back(6.0) ;
string_vector.push_back("It") ;
string_vector.push_back("has") ;
string_vector.push_back("the") ;
string_vector.push_back("Wi-Fies") ;
short_list.push_back(400) ;
short_list.push_back(401) ;
short_list.push_back(402) ;
string_list.push_back("I") ;
string_list.push_back("don't") ;
string_list.push_back("care") ;
float_deque.push_back(98.7) ;
float_deque.push_back(65.4) ;
float_deque.push_back(32.1) ;
string_deque.push_back("Welcome") ;
string_deque.push_back("to") ;
string_deque.push_back("PhoneMart") ;
int_set.insert(8000) ;
int_set.insert(4000) ;
int_set.insert(2000) ;
int_set.insert(1000) ;
string_set.insert("efg") ;
string_set.insert("abc") ;
string_set.insert("def") ;
long_multiset.insert(8000) ;
long_multiset.insert(4000) ;
long_multiset.insert(4000) ;
long_multiset.insert(2000) ;
long_multiset.insert(1000) ;
string_multiset.insert("efg") ;
string_multiset.insert("abc") ;
string_multiset.insert("def") ;
string_multiset.insert("efg") ;
string_multiset.insert("abc") ;
string_multiset.insert("def") ;
uint_stack.push(1) ;
uint_stack.push(2) ;
uint_stack.push(3) ;
uint_stack.push(4) ;
string_stack.push("I") ;
string_stack.push("want the one") ;
string_stack.push("with the bigger") ;
string_stack.push("Gee Bees") ;
stack_vector_int.push(v) ;
stack_vector_int.push(v) ;
int_queue.push(1) ;
int_queue.push(2) ;
int_queue.push(3) ;
int_queue.push(4) ;
string_queue.push("I") ;
string_queue.push("want") ;
string_queue.push("an") ;
string_queue.push("iPhone 4") ;
int_priority_queue.push(3) ;
int_priority_queue.push(2) ;
int_priority_queue.push(4) ;
int_priority_queue.push(1) ;
string_priority_queue.push("I") ;
string_priority_queue.push("want") ;
string_priority_queue.push("an") ;
string_priority_queue.push("iPhone 4") ;
queue_vector_int.push(v) ;
queue_vector_int.push(v) ;
priority_queue_vector_int.push(v) ;
priority_queue_vector_int.push(v) ;
int_pair.first = 10 ;
int_pair.second = 20 ;
string_first_pair.first = "string first" ;
string_first_pair.second = 25 ;
string_second_pair.first = 25 ;
string_second_pair.second = "string second" ;
string_pair.first = "pair first string" ;
string_pair.second = "pair second string" ;
int_pair_int_int.first = 200 ;
p.first = 10 ;
p.second = 20 ;
int_pair_int_int.second = p ;
p.first = 15 ;
p.second = 12 ;
pair_int_int_int.first = p ;
pair_int_int_int.second = 180 ;
pair_pair_pair.first.first = 51 ;
pair_pair_pair.first.second = 52 ;
pair_pair_pair.second.first = 53 ;
pair_pair_pair.second.second = 54 ;
vector_vector_double[0][0] = 100 ;
vector_vector_double[0][1] = 101 ;
vector_vector_double[0][2] = 102 ;
vector_vector_double[1][0] = 103 ;
vector_vector_double[1][1] = 104 ;
vector_vector_double[1][2] = 105 ;
vector_vector_double[2][0] = 106 ;
vector_vector_double[2][1] = 107 ;
vector_vector_double[2][2] = 108 ;
vector_vector_double[3][0] = 109 ;
vector_vector_double[3][1] = 110 ;
vector_vector_double[3][2] = 111 ;
vector_vector_vector_double[0][0][0] = 0 ;
vector_vector_vector_double[0][0][1] = 1 ;
vector_vector_vector_double[0][0][2] = 2 ;
vector_vector_vector_double[0][1][0] = 3 ;
vector_vector_vector_double[0][1][1] = 4 ;
vector_vector_vector_double[0][1][2] = 5 ;
vector_vector_vector_double[0][2][0] = 6 ;
vector_vector_vector_double[0][2][1] = 7 ;
vector_vector_vector_double[0][2][2] = 8 ;
vector_vector_vector_double[0][3][0] = 9 ;
vector_vector_vector_double[0][3][1] = 10 ;
vector_vector_vector_double[0][3][2] = 11 ;
vector_vector_vector_double[1][0][0] = 1000 ;
vector_vector_vector_double[1][0][1] = 1001 ;
vector_vector_vector_double[1][0][2] = 1002 ;
vector_vector_vector_double[1][1][0] = 1003 ;
vector_vector_vector_double[1][1][1] = 1004 ;
vector_vector_vector_double[1][1][2] = 1005 ;
vector_vector_vector_double[1][2][0] = 1006 ;
vector_vector_vector_double[1][2][1] = 1007 ;
vector_vector_vector_double[1][2][2] = 1008 ;
vector_vector_vector_double[1][3][0] = 1009 ;
vector_vector_vector_double[1][3][1] = 1010 ;
vector_vector_vector_double[1][3][2] = 1011 ;
vector_vector_vector_double[2][0][0] = 2000 ;
vector_vector_vector_double[2][0][1] = 2001 ;
vector_vector_vector_double[2][0][2] = 2002 ;
vector_vector_vector_double[2][1][0] = 2003 ;
vector_vector_vector_double[2][1][1] = 2004 ;
vector_vector_vector_double[2][1][2] = 2005 ;
vector_vector_vector_double[2][2][0] = 2006 ;
vector_vector_vector_double[2][2][1] = 2007 ;
vector_vector_vector_double[2][2][2] = 2008 ;
vector_vector_vector_double[2][3][0] = 2009 ;
vector_vector_vector_double[2][3][1] = 2010 ;
vector_vector_vector_double[2][3][2] = 2011 ;
vector_vector_vector_double[3][0][0] = 3000 ;
vector_vector_vector_double[3][0][1] = 3001 ;
vector_vector_vector_double[3][0][2] = 3002 ;
vector_vector_vector_double[3][1][0] = 3003 ;
vector_vector_vector_double[3][1][1] = 3004 ;
vector_vector_vector_double[3][1][2] = 3005 ;
vector_vector_vector_double[3][2][0] = 3006 ;
vector_vector_vector_double[3][2][1] = 3007 ;
vector_vector_vector_double[3][2][2] = 3008 ;
vector_vector_vector_double[3][3][0] = 3009 ;
vector_vector_vector_double[3][3][1] = 3010 ;
vector_vector_vector_double[3][3][2] = 3011 ;
vector_vector_vector_double[4][0][0] = 4000 ;
vector_vector_vector_double[4][0][1] = 4001 ;
vector_vector_vector_double[4][0][2] = 4002 ;
vector_vector_vector_double[4][1][0] = 4003 ;
vector_vector_vector_double[4][1][1] = 4004 ;
vector_vector_vector_double[4][1][2] = 4005 ;
vector_vector_vector_double[4][2][0] = 4006 ;
vector_vector_vector_double[4][2][1] = 4007 ;
vector_vector_vector_double[4][2][2] = 4008 ;
vector_vector_vector_double[4][3][0] = 4009 ;
vector_vector_vector_double[4][3][1] = 4010 ;
vector_vector_vector_double[4][3][2] = 4011 ;
return ;
}
int STLCheckpoint::speak() {
//message_publish(1,"Quack!\n") ;
//message_publish(1,"double_vector: %f %f %f\n", double_vector[0], double_vector[1], double_vector[2]) ;
//message_publish(1,"vector_vector_double[1]: %f %f %f\n",
// vector_vector_double[1][0], vector_vector_double[1][1], vector_vector_double[1][2]) ;
//message_publish(1,"vector_vector_vector_double[4][2]: %f %f %f\n",
// vector_vector_vector_double[4][2][0], vector_vector_vector_double[4][2][1], vector_vector_vector_double[4][2][2]) ;
//message_publish(1,"string_vector[0]: %s\n", string_vector[0].c_str()) ;
//message_publish(1,"map_int_vector_int[1][1] = %d\n", map_int_vector_int[1][1]) ;
//message_publish(1,"gcd = %d\n", gcd[std::pair<int, int >(24,30)]) ;
//message_publish(1,"common_multiples = %d\n", common_multiples[std::pair<int, int >(3,5)][1]) ;
//message_publish(1,"common_multiples = %d\n", common_multiples[std::pair<int, int >(3,5)][1]) ;
//message_publish(1,"int_pair_int_int.second.second = %d\n", int_pair_int_int.second.second) ;
//message_publish(1,"pair_int_int_int.first.second = %d\n", pair_int_int_int.first.second) ;
//message_publish(1,"pair_pair_pair.second.first = %d\n", pair_pair_pair.second.first) ;
//message_publish(1,"int_queue.front = %d\n", int_queue.front()) ;
//message_publish(1,"int_priority_queue.top = %d\n", int_priority_queue.top()) ;
//message_publish(1,"uint_stack.top = %d\n", uint_stack.top()) ;
//message_publish(1,"queue_vector_int.front()[3] = %d\n", queue_vector_int.front()[3]) ;
//message_publish(1,"priority_queue_vector_int.top()[2] = %d\n", priority_queue_vector_int.top()[2]) ;
message_publish(1,"stack_vector_int.top()[1] = %d\n", stack_vector_int.top()[1]) ;
return 0 ;
}

View File

@ -0,0 +1,90 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
LIBRARY_DEPENDENCIES: (
(STLCheckpoint.o)
)
*/
#ifndef STLCHECKPOINT_HH
#define STLCHECKPOINT_HH
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <string>
#include <stack>
#include <queue>
#include <utility>
class STLCheckpoint {
public:
STLCheckpoint() ;
STLCheckpoint(std::string in_name) ;
int speak() ;
std::string name ;
std::map< double , double > double_map ;
std::map< std::string , int > string_key_map ;
std::map< int , std::string > string_data_map ;
std::map< std::string , std::string > string_map ;
std::map< int , std::vector< int > > map_int_vector_int ;
std::map< std::pair< int , int > , int > gcd ;
std::map< std::pair< int , int > , std::pair< int , int > > map_pair_pair ;
std::map< std::pair< int , int > , std::vector< int > > common_multiples ;
std::multimap< int , int > int_multimap ;
std::multimap< std::string , int > string_key_multimap ;
std::multimap< int , std::string > string_data_multimap ;
std::multimap< std::string , std::string > string_multimap ;
std::vector< double > double_vector ;
std::vector< std::string > string_vector ;
std::list< short > short_list ;
std::list< std::string > string_list ;
std::deque< float > float_deque ;
std::deque< std::string > string_deque ;
std::set< int > int_set ;
std::set< std::string > string_set ;
std::multiset< long > long_multiset ;
std::multiset< std::string > string_multiset ;
std::stack< unsigned int > uint_stack ;
std::stack< std::string > string_stack ;
std::stack< std::vector<int> > stack_vector_int ;
std::queue< int > int_queue ;
std::queue< std::string > string_queue ;
std::queue< std::vector<int> > queue_vector_int ;
std::priority_queue< int > int_priority_queue ;
std::priority_queue< std::string > string_priority_queue ;
std::priority_queue< int , std::vector< int > , std::greater< int > > int_greater_priority_queue ;
std::priority_queue< std::vector<int> > priority_queue_vector_int ;
std::pair< int , int > int_pair ;
std::pair< std::string , int > string_first_pair ;
std::pair< int , std::string > string_second_pair ;
std::pair< std::string , std::string > string_pair ;
std::pair< int , std::pair< int, int > > int_pair_int_int ;
std::pair< std::pair< int, int > , int > pair_int_int_int ;
std::pair< std::pair< int, int > , std::pair< int, int > > pair_pair_pair ;
std::vector< std::vector< double > > vector_vector_double ;
std::vector< std::vector< std::vector< double > > > vector_vector_vector_double ;
//std::vector< std::list< double > > vector_list_double ;
} ;
#endif

View File

@ -1,93 +0,0 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
LIBRARY_DEPENDENCIES: (
(STLCheckpoint.o)
)
*/
#ifndef STLCHECKPOINT_HH
#define STLCHECKPOINT_HH
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <string>
#include <stack>
#include <queue>
#include <utility>
/* This shows the most difficult case in checkpointing STLs where all
STLs are private. There are no accessor routines to get individual
items out of the STLs. (In fact getting to all items in some of the
STLs forces changes in the contents, such as stacks and queues.) Anyways
in this case we need to specify a friend that carries out the checkpoint.
There are 2 methods one can use to call the Trick stl checkpoint routines:
1) Provide a companion class that calls the Trick routines for each STL
(STLCompanion in this example).
-- OR --
2) Invoke Trick's CHECKPOINT_STL macro in the sim object class for each STL
(theSimObject in this example).
Whichever method is chosen, make that class a friend of the class with STLs
(STLCheckpoint in this example).
Public STLs can be checkpointed in the same way (but no need to specify friend).
*/
class STLCheckpoint {
friend class STLCompanion ; // method 1
friend class theSimObject ; // method 2
public:
STLCheckpoint() ;
STLCheckpoint(std::string in_name) ;
int speak() ;
std::string name ;
private:
std::map< double , double > my_double_map ;
std::map< std::string , int > my_string_key_map ;
std::map< int , std::string > my_string_data_map ;
std::map< std::string , std::string > my_string_map ;
std::multimap< int , int > my_int_multimap ;
std::multimap< std::string , int > my_string_key_multimap ;
std::multimap< int , std::string > my_string_data_multimap ;
std::multimap< std::string , std::string > my_string_multimap ;
std::vector< double > my_double_vector ;
std::vector< std::string > my_string_vector ;
std::list< short > my_short_list ;
std::list< std::string > my_string_list ;
std::deque< float > my_float_deque ;
std::deque< std::string > my_string_deque ;
std::set< int > my_int_set ;
std::set< std::string > my_string_set ;
std::multiset< long > my_long_multiset ;
std::multiset< std::string > my_string_multiset ;
std::stack< unsigned int > my_uint_stack ;
std::stack< std::string > my_string_stack ;
std::queue< int > my_int_queue ;
std::queue< std::string > my_string_queue ;
std::priority_queue< int > my_int_priority_queue ;
std::priority_queue< std::string > my_string_priority_queue ;
std::pair< int , int > my_int_pair ;
std::pair< std::string , int > my_string_first_pair ;
std::pair< int , std::string > my_string_second_pair ;
std::pair< std::string , std::string > my_string_pair ;
} ;
#endif

View File

@ -1,42 +0,0 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
LIBRARY_DEPENDENCIES: (
(STLCompanion_checkpoint.o)
(STLCompanion_post_checkpoint.o)
(STLCompanion_restart.o)
)
*/
#ifndef STLCOMPANION_HH
#define STLCOMPANION_HH
#include <string>
#include "STLCheckpoint.hh"
/* STLCheckpoint's friend
This class's sole purpose in life is to keep up the STLs in the STLCheckpoint class.
Since this is a friend to the STLCheckpoint class, the methods of this class work
with the STLs in STLCheckpoint directly.
*/
class STLCompanion {
public:
STLCompanion() {} ;
/* writes out the STL data in arrays in the memory manager */
int checkpoint(STLCheckpoint * in_stlc, std::string var_name) ;
/* deletes the STL data in arrays from the memory manager */
int post_checkpoint(STLCheckpoint * in_stlc, std::string var_name) ;
/* restores memory from a checkpoint. the data resides in memory
manager. deletes the STL data in arrays after restoration */
int restart(STLCheckpoint * in_stlc, std::string var_name) ;
} ;
#endif

View File

@ -1,281 +0,0 @@
#include "sim_services/Message/include/message_proto.h"
#include "STLCheckpoint.hh"
/* These 2 constructors add different data to an STLCheckpoint. */
STLCheckpoint::STLCheckpoint() {
my_double_map[11.1] = 111.1 ;
my_double_map[22.2] = 222.2 ;
my_double_map[33.3] = 333.3 ;
my_string_key_map[std::string("one")] = 1 ;
my_string_key_map[std::string("two")] = 2 ;
my_string_key_map[std::string("three")] = 3 ;
my_string_data_map[4] = std::string("vier") ;
my_string_data_map[5] = std::string("fumf") ;
my_string_data_map[6] = std::string("sechs") ;
my_string_map[std::string("mother")] = std::string("Marge") ;
my_string_map[std::string("father")] = std::string("Homer") ;
my_string_map[std::string("son")] = std::string("Bart") ;
my_int_multimap.insert(std::pair<int, int>(11,111)) ;
my_int_multimap.insert(std::pair<int, int>(22,222)) ;
my_int_multimap.insert(std::pair<int, int>(33,333)) ;
my_int_multimap.insert(std::pair<int, int>(11,111)) ;
my_int_multimap.insert(std::pair<int, int>(22,222)) ;
my_int_multimap.insert(std::pair<int, int>(33,333)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("one", 1)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("two", 2)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("three", 3)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("one", 1)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("two", 2)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("three", 3)) ;
my_string_data_multimap.insert(std::pair<int, std::string>(4, "vier")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(5, "fumf")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(6, "sechs")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(4, "four")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(5, "five")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(6, "six")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("mother","Marge")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("father","Homer")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("mother","Lois")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("father","Meg")) ;
my_double_vector.push_back(1.0) ;
my_double_vector.push_back(2.0) ;
my_double_vector.push_back(3.0) ;
my_string_vector.push_back("I") ;
my_string_vector.push_back("was") ;
my_string_vector.push_back("here") ;
my_short_list.push_back(300) ;
my_short_list.push_back(301) ;
my_short_list.push_back(302) ;
my_string_list.push_back("I") ;
my_string_list.push_back("was") ;
my_string_list.push_back("there") ;
my_float_deque.push_back(12.3) ;
my_float_deque.push_back(45.6) ;
my_float_deque.push_back(78.9) ;
my_string_deque.push_back("meow") ;
my_string_deque.push_back("bark") ;
my_string_deque.push_back("quack") ;
my_int_set.insert(8) ;
my_int_set.insert(4) ;
my_int_set.insert(2) ;
my_int_set.insert(1) ;
my_string_set.insert("e") ;
my_string_set.insert("a") ;
my_string_set.insert("d") ;
my_long_multiset.insert(8) ;
my_long_multiset.insert(4) ;
my_long_multiset.insert(4) ;
my_long_multiset.insert(2) ;
my_long_multiset.insert(1) ;
my_string_multiset.insert("e") ;
my_string_multiset.insert("a") ;
my_string_multiset.insert("d") ;
my_string_multiset.insert("e") ;
my_string_multiset.insert("a") ;
my_string_multiset.insert("d") ;
my_uint_stack.push(10) ;
my_uint_stack.push(20) ;
my_uint_stack.push(30) ;
my_uint_stack.push(40) ;
my_string_stack.push("abc I") ;
my_string_stack.push("abc want the one") ;
my_string_stack.push("abc with the bigger") ;
my_string_stack.push("abc Gee Bees") ;
my_int_queue.push(10) ;
my_int_queue.push(20) ;
my_int_queue.push(30) ;
my_int_queue.push(40) ;
my_string_queue.push("abc I") ;
my_string_queue.push("abc want") ;
my_string_queue.push("abc an") ;
my_string_queue.push("abc iPhone 4") ;
my_int_priority_queue.push(30) ;
my_int_priority_queue.push(20) ;
my_int_priority_queue.push(40) ;
my_int_priority_queue.push(10) ;
my_string_priority_queue.push("abc I") ;
my_string_priority_queue.push("abc want") ;
my_string_priority_queue.push("abc an") ;
my_string_priority_queue.push("abc iPhone 4") ;
my_int_pair.first = 1 ;
my_int_pair.second = 2 ;
my_string_first_pair.first = "abc string first" ;
my_string_first_pair.second = 2 ;
my_string_second_pair.first = 2 ;
my_string_second_pair.second = "abc string second" ;
my_string_pair.first = "abc pair first string" ;
my_string_pair.second = "abc pair second string" ;
return ;
}
STLCheckpoint::STLCheckpoint(std::string in_name) {
name = in_name ;
my_double_map[44.4] = 444.4 ;
my_double_map[55.5] = 555.5 ;
my_double_map[66.6] = 666.6 ;
my_string_key_map[std::string("four")] = 4 ;
my_string_key_map[std::string("five")] = 5 ;
my_string_key_map[std::string("six")] = 6 ;
my_string_data_map[7] = std::string("seiben") ;
my_string_data_map[8] = std::string("acht") ;
my_string_data_map[9] = std::string("neun") ;
my_string_map[std::string("sister")] = std::string("Lisa") ;
my_string_map[std::string("dog")] = std::string("Santa's Little Helper") ;
my_int_multimap.insert(std::pair<int, int>(44,444)) ;
my_int_multimap.insert(std::pair<int, int>(55,555)) ;
my_int_multimap.insert(std::pair<int, int>(66,666)) ;
my_int_multimap.insert(std::pair<int, int>(44,444)) ;
my_int_multimap.insert(std::pair<int, int>(55,555)) ;
my_int_multimap.insert(std::pair<int, int>(66,666)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("four", 4)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("five", 5)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("six", 6)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("four", 44)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("five", 55)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("six", 66)) ;
my_string_data_multimap.insert(std::pair<int, std::string>(7, "seiben")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(8, "acht")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(9, "neun")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(7, "seven")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(8, "eight")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(9, "nine")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("sister","Lisa")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("dog","Santa's Little Helper")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("sister","Meg")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("dog","Brian")) ;
my_double_vector.push_back(4.0) ;
my_double_vector.push_back(5.0) ;
my_double_vector.push_back(6.0) ;
my_string_vector.push_back("It") ;
my_string_vector.push_back("has") ;
my_string_vector.push_back("the") ;
my_string_vector.push_back("Wi-Fies") ;
my_short_list.push_back(400) ;
my_short_list.push_back(401) ;
my_short_list.push_back(402) ;
my_string_list.push_back("I") ;
my_string_list.push_back("don't") ;
my_string_list.push_back("care") ;
my_float_deque.push_back(98.7) ;
my_float_deque.push_back(65.4) ;
my_float_deque.push_back(32.1) ;
my_string_deque.push_back("Welcome") ;
my_string_deque.push_back("to") ;
my_string_deque.push_back("PhoneMart") ;
my_int_set.insert(8000) ;
my_int_set.insert(4000) ;
my_int_set.insert(2000) ;
my_int_set.insert(1000) ;
my_string_set.insert("efg") ;
my_string_set.insert("abc") ;
my_string_set.insert("def") ;
my_long_multiset.insert(8000) ;
my_long_multiset.insert(4000) ;
my_long_multiset.insert(4000) ;
my_long_multiset.insert(2000) ;
my_long_multiset.insert(1000) ;
my_string_multiset.insert("efg") ;
my_string_multiset.insert("abc") ;
my_string_multiset.insert("def") ;
my_string_multiset.insert("efg") ;
my_string_multiset.insert("abc") ;
my_string_multiset.insert("def") ;
my_uint_stack.push(1) ;
my_uint_stack.push(2) ;
my_uint_stack.push(3) ;
my_uint_stack.push(4) ;
my_string_stack.push("I") ;
my_string_stack.push("want the one") ;
my_string_stack.push("with the bigger") ;
my_string_stack.push("Gee Bees") ;
my_int_queue.push(1) ;
my_int_queue.push(2) ;
my_int_queue.push(3) ;
my_int_queue.push(4) ;
my_string_queue.push("I") ;
my_string_queue.push("want") ;
my_string_queue.push("an") ;
my_string_queue.push("iPhone 4") ;
my_int_priority_queue.push(3) ;
my_int_priority_queue.push(2) ;
my_int_priority_queue.push(4) ;
my_int_priority_queue.push(1) ;
my_string_priority_queue.push("I") ;
my_string_priority_queue.push("want") ;
my_string_priority_queue.push("an") ;
my_string_priority_queue.push("iPhone 4") ;
my_int_pair.first = 10 ;
my_int_pair.second = 20 ;
my_string_first_pair.first = "string first" ;
my_string_first_pair.second = 25 ;
my_string_second_pair.first = 25 ;
my_string_second_pair.second = "string second" ;
my_string_pair.first = "pair first string" ;
my_string_pair.second = "pair second string" ;
return ;
}
int STLCheckpoint::speak() {
message_publish(1,"Quack!\n") ;
return 0 ;
}

View File

@ -1,53 +0,0 @@
#include <string>
#include "STLCompanion.hh"
#include "sim_services/CheckPointRestart/include/checkpoint_stl.hh"
/* All STLs are checkpointed through the same templated function checkpoint_stl. The
second and third arguments to the call give each set of STL data a unique name. In
this example the unique name is the concatenation of the object instance and the variable name
*/
int STLCompanion::checkpoint(STLCheckpoint * stlc, std::string object_name ) {
checkpoint_stl(stlc->my_double_map , object_name , std::string("my_double_map")) ;
checkpoint_stl(stlc->my_string_key_map , object_name , std::string("my_string_key_map")) ;
checkpoint_stl(stlc->my_string_data_map , object_name , std::string("my_string_data_map")) ;
checkpoint_stl(stlc->my_string_map , object_name , std::string("my_string_map")) ;
checkpoint_stl(stlc->my_int_multimap , object_name , std::string("my_int_multimap")) ;
checkpoint_stl(stlc->my_string_key_multimap , object_name , std::string("my_string_key_multimap")) ;
checkpoint_stl(stlc->my_string_data_multimap , object_name , std::string("my_string_data_multimap")) ;
checkpoint_stl(stlc->my_string_multimap , object_name , std::string("my_string_multimap")) ;
checkpoint_stl(stlc->my_double_vector , object_name , std::string("my_double_vector")) ;
checkpoint_stl(stlc->my_string_vector , object_name , std::string("my_string_vector")) ;
checkpoint_stl(stlc->my_short_list , object_name , std::string("my_short_list")) ;
checkpoint_stl(stlc->my_string_list , object_name , std::string("my_string_list")) ;
checkpoint_stl(stlc->my_float_deque , object_name , std::string("my_float_deque")) ;
checkpoint_stl(stlc->my_string_deque , object_name , std::string("my_string_deque")) ;
checkpoint_stl(stlc->my_int_set , object_name , std::string("my_int_set")) ;
checkpoint_stl(stlc->my_string_set , object_name , std::string("my_string_set")) ;
checkpoint_stl(stlc->my_long_multiset , object_name , std::string("my_long_multiset")) ;
checkpoint_stl(stlc->my_string_multiset , object_name , std::string("my_string_multiset")) ;
checkpoint_stl(stlc->my_uint_stack , object_name , std::string("my_uint_stack")) ;
checkpoint_stl(stlc->my_string_stack , object_name , std::string("my_string_stack")) ;
checkpoint_stl(stlc->my_int_queue , object_name , std::string("my_int_queue")) ;
checkpoint_stl(stlc->my_string_queue , object_name , std::string("my_string_queue")) ;
checkpoint_stl(stlc->my_int_priority_queue , object_name , std::string("my_int_priority_queue")) ;
checkpoint_stl(stlc->my_string_priority_queue , object_name , std::string("my_string_priority_queue")) ;
checkpoint_stl(stlc->my_int_pair , object_name , std::string("my_int_pair")) ;
checkpoint_stl(stlc->my_string_first_pair , object_name , std::string("my_string_first_pair")) ;
checkpoint_stl(stlc->my_string_second_pair , object_name , std::string("my_string_second_pair")) ;
checkpoint_stl(stlc->my_string_pair , object_name , std::string("my_stringpair")) ;
return 0 ;
}

View File

@ -1,55 +0,0 @@
#include <string>
#include "STLCompanion.hh"
#include "sim_services/CheckPointRestart/include/checkpoint_stl.hh"
/* All STLs are deleted through the same templated function delete_stl. The
second and third arguments give the unique name to delete. In
this example the unique name is the concatenation of the object instance and the variable name.
Currently the first argument is unused.
*/
int STLCompanion::post_checkpoint(STLCheckpoint * stlc, std::string object_name ) {
delete_stl(stlc->my_double_map , object_name , std::string("my_double_map")) ;
delete_stl(stlc->my_string_key_map , object_name , std::string("my_string_key_map")) ;
delete_stl(stlc->my_string_data_map , object_name , std::string("my_string_data_map")) ;
delete_stl(stlc->my_string_map , object_name , std::string("my_string_map")) ;
delete_stl(stlc->my_int_multimap , object_name , std::string("my_int_multimap")) ;
delete_stl(stlc->my_string_key_multimap , object_name , std::string("my_string_key_multimap")) ;
delete_stl(stlc->my_string_data_multimap , object_name , std::string("my_string_data_multimap")) ;
delete_stl(stlc->my_string_multimap , object_name , std::string("my_string_multimap")) ;
delete_stl(stlc->my_double_vector , object_name , std::string("my_double_vector")) ;
delete_stl(stlc->my_string_vector , object_name , std::string("my_string_vector")) ;
delete_stl(stlc->my_short_list , object_name , std::string("my_short_list")) ;
delete_stl(stlc->my_string_list , object_name , std::string("my_string_list")) ;
delete_stl(stlc->my_float_deque , object_name , std::string("my_float_deque")) ;
delete_stl(stlc->my_string_deque , object_name , std::string("my_string_deque")) ;
delete_stl(stlc->my_int_set , object_name , std::string("my_int_set")) ;
delete_stl(stlc->my_string_set , object_name , std::string("my_string_set")) ;
delete_stl(stlc->my_long_multiset , object_name , std::string("my_long_multiset")) ;
delete_stl(stlc->my_string_multiset , object_name , std::string("my_string_multiset")) ;
delete_stl(stlc->my_uint_stack , object_name , std::string("my_uint_stack")) ;
delete_stl(stlc->my_string_stack , object_name , std::string("my_string_stack")) ;
delete_stl(stlc->my_int_queue , object_name , std::string("my_int_queue")) ;
delete_stl(stlc->my_string_queue , object_name , std::string("my_string_queue")) ;
delete_stl(stlc->my_int_priority_queue , object_name , std::string("my_int_priority_queue")) ;
delete_stl(stlc->my_string_priority_queue , object_name , std::string("my_string_priority_queue")) ;
delete_stl(stlc->my_int_pair , object_name , std::string("my_int_pair")) ;
delete_stl(stlc->my_string_first_pair , object_name , std::string("my_string_first_pair")) ;
delete_stl(stlc->my_string_second_pair , object_name , std::string("my_string_second_pair")) ;
delete_stl(stlc->my_string_pair , object_name , std::string("my_stringpair")) ;
return 0 ;
}

View File

@ -1,54 +0,0 @@
#include <string>
#include "STLCompanion.hh"
#include "sim_services/CheckPointRestart/include/checkpoint_stl.hh"
/* All STLs are restored through the same templated function restore_stl. The
second and third arguments give the unique name to delete. In
this example the unique name is the concatenation of the object instance and the variable name.
retore_stl will delete the memory manager arrays.
*/
int STLCompanion::restart(STLCheckpoint * stlc, std::string object_name ) {
restore_stl(stlc->my_double_map , object_name , std::string("my_double_map")) ;
restore_stl(stlc->my_string_key_map , object_name , std::string("my_string_key_map")) ;
restore_stl(stlc->my_string_data_map , object_name , std::string("my_string_data_map")) ;
restore_stl(stlc->my_string_map , object_name , std::string("my_string_map")) ;
restore_stl(stlc->my_int_multimap , object_name , std::string("my_int_multimap")) ;
restore_stl(stlc->my_string_key_multimap , object_name , std::string("my_string_key_multimap")) ;
restore_stl(stlc->my_string_data_multimap , object_name , std::string("my_string_data_multimap")) ;
restore_stl(stlc->my_string_multimap , object_name , std::string("my_string_multimap")) ;
restore_stl(stlc->my_double_vector , object_name , std::string("my_double_vector")) ;
restore_stl(stlc->my_string_vector , object_name , std::string("my_string_vector")) ;
restore_stl(stlc->my_short_list , object_name , std::string("my_short_list")) ;
restore_stl(stlc->my_string_list , object_name , std::string("my_string_list")) ;
restore_stl(stlc->my_float_deque , object_name , std::string("my_float_deque")) ;
restore_stl(stlc->my_string_deque , object_name , std::string("my_string_deque")) ;
restore_stl(stlc->my_int_set , object_name , std::string("my_int_set")) ;
restore_stl(stlc->my_string_set , object_name , std::string("my_string_set")) ;
restore_stl(stlc->my_long_multiset , object_name , std::string("my_long_multiset")) ;
restore_stl(stlc->my_string_multiset , object_name , std::string("my_string_multiset")) ;
restore_stl(stlc->my_uint_stack , object_name , std::string("my_uint_stack")) ;
restore_stl(stlc->my_string_stack , object_name , std::string("my_string_stack")) ;
restore_stl(stlc->my_int_queue , object_name , std::string("my_int_queue")) ;
restore_stl(stlc->my_string_queue , object_name , std::string("my_string_queue")) ;
restore_stl(stlc->my_int_priority_queue , object_name , std::string("my_int_priority_queue")) ;
restore_stl(stlc->my_string_priority_queue , object_name , std::string("my_string_priority_queue")) ;
restore_stl(stlc->my_int_pair , object_name , std::string("my_int_pair")) ;
restore_stl(stlc->my_string_first_pair , object_name , std::string("my_string_first_pair")) ;
restore_stl(stlc->my_string_second_pair , object_name , std::string("my_string_second_pair")) ;
restore_stl(stlc->my_string_pair , object_name , std::string("my_stringpair")) ;
return 0 ;
}

View File

@ -1,24 +0,0 @@
def main():
#trick.echo_jobs_on()
simControlPanel = trick.SimControlPanel()
simControlPanel.thisown = 0
trick.add_external_application(simControlPanel)
trick.real_time_enable()
#trick.itimer_enable()
trick.checkpoint_post_init(True)
trick.checkpoint_end(True)
trick.freeze(2.0)
the_object.stlc2.name = "Daisy"
trick.exec_set_freeze_frame(0.10)
trick.stop(5.0)
if __name__ == "__main__":
main()

View File

@ -1,15 +0,0 @@
def main():
trick.checkpoint_post_init(True)
trick.checkpoint_end(True)
the_object.stlc2.name = "Daisy"
# Data recording HDF5 test
trick.exec_set_freeze_frame(0.10)
trick.stop(5.0)
if __name__ == "__main__":
main()

View File

@ -1,37 +0,0 @@
#include "sim_objects/default_trick_sys.sm"
##include "stl_checkpoint/STLCheckpoint.hh"
/* This object tests having 2 of the same type of object containing STLs in the same sim_object.
The checkpoints use the name of the objects to give the STLs unique and identifiable names
in the checkpoint. This is done by invoking CHECKPOINT_STL for each variable (see stl_checkpoints.sm) */
class theSimObject : public Trick::SimObject {
public:
STLCheckpoint stlc ;
STLCheckpoint stlc2 ;
/** Constructor to add the jobs */
theSimObject() : stlc(std::string("Petunia")) , stlc2() {
(1.0, "scheduled") stlc.speak() ;
#include "stl_checkpoints.sm"
}
} ;
// Multiple simobjects
theSimObject the_object ;
theSimObject the_object2 ;
// Connect objects
void create_connections() {
// Set the default termination time
trick_sys.sched.set_terminate_time(10.0) ;
trick_sys.sched.set_freeze_frame(0.10) ;
}

View File

@ -1,4 +0,0 @@
TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I./models

View File

@ -1,281 +0,0 @@
#include "sim_services/Message/include/message_proto.h"
#include "STLCheckpoint.hh"
/* These 2 constructors add different data to an STLCheckpoint. */
STLCheckpoint::STLCheckpoint() {
my_double_map[11.1] = 111.1 ;
my_double_map[22.2] = 222.2 ;
my_double_map[33.3] = 333.3 ;
my_string_key_map[std::string("one")] = 1 ;
my_string_key_map[std::string("two")] = 2 ;
my_string_key_map[std::string("three")] = 3 ;
my_string_data_map[4] = std::string("vier") ;
my_string_data_map[5] = std::string("fumf") ;
my_string_data_map[6] = std::string("sechs") ;
my_string_map[std::string("mother")] = std::string("Marge") ;
my_string_map[std::string("father")] = std::string("Homer") ;
my_string_map[std::string("son")] = std::string("Bart") ;
my_int_multimap.insert(std::pair<int, int>(11,111)) ;
my_int_multimap.insert(std::pair<int, int>(22,222)) ;
my_int_multimap.insert(std::pair<int, int>(33,333)) ;
my_int_multimap.insert(std::pair<int, int>(11,111)) ;
my_int_multimap.insert(std::pair<int, int>(22,222)) ;
my_int_multimap.insert(std::pair<int, int>(33,333)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("one", 1)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("two", 2)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("three", 3)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("one", 1)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("two", 2)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("three", 3)) ;
my_string_data_multimap.insert(std::pair<int, std::string>(4, "vier")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(5, "fumf")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(6, "sechs")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(4, "four")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(5, "five")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(6, "six")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("mother","Marge")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("father","Homer")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("mother","Lois")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("father","Meg")) ;
my_double_vector.push_back(1.0) ;
my_double_vector.push_back(2.0) ;
my_double_vector.push_back(3.0) ;
my_string_vector.push_back("I") ;
my_string_vector.push_back("was") ;
my_string_vector.push_back("here") ;
my_short_list.push_back(300) ;
my_short_list.push_back(301) ;
my_short_list.push_back(302) ;
my_string_list.push_back("I") ;
my_string_list.push_back("was") ;
my_string_list.push_back("there") ;
my_float_deque.push_back(12.3) ;
my_float_deque.push_back(45.6) ;
my_float_deque.push_back(78.9) ;
my_string_deque.push_back("meow") ;
my_string_deque.push_back("bark") ;
my_string_deque.push_back("quack") ;
my_int_set.insert(8) ;
my_int_set.insert(4) ;
my_int_set.insert(2) ;
my_int_set.insert(1) ;
my_string_set.insert("e") ;
my_string_set.insert("a") ;
my_string_set.insert("d") ;
my_long_multiset.insert(8) ;
my_long_multiset.insert(4) ;
my_long_multiset.insert(4) ;
my_long_multiset.insert(2) ;
my_long_multiset.insert(1) ;
my_string_multiset.insert("e") ;
my_string_multiset.insert("a") ;
my_string_multiset.insert("d") ;
my_string_multiset.insert("e") ;
my_string_multiset.insert("a") ;
my_string_multiset.insert("d") ;
my_uint_stack.push(10) ;
my_uint_stack.push(20) ;
my_uint_stack.push(30) ;
my_uint_stack.push(40) ;
my_string_stack.push("abc I") ;
my_string_stack.push("abc want the one") ;
my_string_stack.push("abc with the bigger") ;
my_string_stack.push("abc Gee Bees") ;
my_int_queue.push(10) ;
my_int_queue.push(20) ;
my_int_queue.push(30) ;
my_int_queue.push(40) ;
my_string_queue.push("abc I") ;
my_string_queue.push("abc want") ;
my_string_queue.push("abc an") ;
my_string_queue.push("abc iPhone 4") ;
my_int_priority_queue.push(30) ;
my_int_priority_queue.push(20) ;
my_int_priority_queue.push(40) ;
my_int_priority_queue.push(10) ;
my_string_priority_queue.push("abc I") ;
my_string_priority_queue.push("abc want") ;
my_string_priority_queue.push("abc an") ;
my_string_priority_queue.push("abc iPhone 4") ;
my_int_pair.first = 1 ;
my_int_pair.second = 2 ;
my_string_first_pair.first = "abc string first" ;
my_string_first_pair.second = 2 ;
my_string_second_pair.first = 2 ;
my_string_second_pair.second = "abc string second" ;
my_string_pair.first = "abc pair first string" ;
my_string_pair.second = "abc pair second string" ;
return ;
}
STLCheckpoint::STLCheckpoint(std::string in_name) {
name = in_name ;
my_double_map[44.4] = 444.4 ;
my_double_map[55.5] = 555.5 ;
my_double_map[66.6] = 666.6 ;
my_string_key_map[std::string("four")] = 4 ;
my_string_key_map[std::string("five")] = 5 ;
my_string_key_map[std::string("six")] = 6 ;
my_string_data_map[7] = std::string("seiben") ;
my_string_data_map[8] = std::string("acht") ;
my_string_data_map[9] = std::string("neun") ;
my_string_map[std::string("sister")] = std::string("Lisa") ;
my_string_map[std::string("dog")] = std::string("Santa's Little Helper") ;
my_int_multimap.insert(std::pair<int, int>(44,444)) ;
my_int_multimap.insert(std::pair<int, int>(55,555)) ;
my_int_multimap.insert(std::pair<int, int>(66,666)) ;
my_int_multimap.insert(std::pair<int, int>(44,444)) ;
my_int_multimap.insert(std::pair<int, int>(55,555)) ;
my_int_multimap.insert(std::pair<int, int>(66,666)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("four", 4)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("five", 5)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("six", 6)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("four", 44)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("five", 55)) ;
my_string_key_multimap.insert(std::pair<std::string, int>("six", 66)) ;
my_string_data_multimap.insert(std::pair<int, std::string>(7, "seiben")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(8, "acht")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(9, "neun")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(7, "seven")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(8, "eight")) ;
my_string_data_multimap.insert(std::pair<int, std::string>(9, "nine")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("sister","Lisa")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("dog","Santa's Little Helper")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("sister","Meg")) ;
my_string_multimap.insert(std::pair<std::string, std::string>("dog","Brian")) ;
my_double_vector.push_back(4.0) ;
my_double_vector.push_back(5.0) ;
my_double_vector.push_back(6.0) ;
my_string_vector.push_back("It") ;
my_string_vector.push_back("has") ;
my_string_vector.push_back("the") ;
my_string_vector.push_back("Wi-Fies") ;
my_short_list.push_back(400) ;
my_short_list.push_back(401) ;
my_short_list.push_back(402) ;
my_string_list.push_back("I") ;
my_string_list.push_back("don't") ;
my_string_list.push_back("care") ;
my_float_deque.push_back(98.7) ;
my_float_deque.push_back(65.4) ;
my_float_deque.push_back(32.1) ;
my_string_deque.push_back("Welcome") ;
my_string_deque.push_back("to") ;
my_string_deque.push_back("PhoneMart") ;
my_int_set.insert(8000) ;
my_int_set.insert(4000) ;
my_int_set.insert(2000) ;
my_int_set.insert(1000) ;
my_string_set.insert("efg") ;
my_string_set.insert("abc") ;
my_string_set.insert("def") ;
my_long_multiset.insert(8000) ;
my_long_multiset.insert(4000) ;
my_long_multiset.insert(4000) ;
my_long_multiset.insert(2000) ;
my_long_multiset.insert(1000) ;
my_string_multiset.insert("efg") ;
my_string_multiset.insert("abc") ;
my_string_multiset.insert("def") ;
my_string_multiset.insert("efg") ;
my_string_multiset.insert("abc") ;
my_string_multiset.insert("def") ;
my_uint_stack.push(1) ;
my_uint_stack.push(2) ;
my_uint_stack.push(3) ;
my_uint_stack.push(4) ;
my_string_stack.push("I") ;
my_string_stack.push("want the one") ;
my_string_stack.push("with the bigger") ;
my_string_stack.push("Gee Bees") ;
my_int_queue.push(1) ;
my_int_queue.push(2) ;
my_int_queue.push(3) ;
my_int_queue.push(4) ;
my_string_queue.push("I") ;
my_string_queue.push("want") ;
my_string_queue.push("an") ;
my_string_queue.push("iPhone 4") ;
my_int_priority_queue.push(3) ;
my_int_priority_queue.push(2) ;
my_int_priority_queue.push(4) ;
my_int_priority_queue.push(1) ;
my_string_priority_queue.push("I") ;
my_string_priority_queue.push("want") ;
my_string_priority_queue.push("an") ;
my_string_priority_queue.push("iPhone 4") ;
my_int_pair.first = 10 ;
my_int_pair.second = 20 ;
my_string_first_pair.first = "string first" ;
my_string_first_pair.second = 25 ;
my_string_second_pair.first = 25 ;
my_string_second_pair.second = "string second" ;
my_string_pair.first = "pair first string" ;
my_string_pair.second = "pair second string" ;
return ;
}
int STLCheckpoint::speak() {
message_publish(1,"Quack!\n") ;
return 0 ;
}

View File

@ -1,93 +0,0 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
LIBRARY_DEPENDENCIES: (
(STLCheckpoint.o)
)
*/
#ifndef STLCHECKPOINT_HH
#define STLCHECKPOINT_HH
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <string>
#include <stack>
#include <queue>
#include <utility>
/* This shows the most difficult case in checkpointing STLs where all
STLs are private. There are no accessor routines to get individual
items out of the STLs. (In fact getting to all items in some of the
STLs forces changes in the contents, such as stacks and queues.) Anyways
in this case we need to specify a friend that carries out the checkpoint.
There are 2 methods one can use to call the Trick stl checkpoint routines:
1) Provide a companion class that calls the Trick routines for each STL
(STLCompanion in this example).
-- OR --
2) Invoke Trick's CHECKPOINT_STL macro in the sim object class for each STL
(theSimObject in this example).
Whichever method is chosen, make that class a friend of the class with STLs
(STLCheckpoint in this example).
Public STLs can be checkpointed in the same way (but no need to specify friend).
*/
class STLCheckpoint {
friend class STLCompanion ; // method 1
friend class theSimObject ; // method 2
public:
STLCheckpoint() ;
STLCheckpoint(std::string in_name) ;
int speak() ;
std::string name ;
private:
std::map< double , double > my_double_map ;
std::map< std::string , int > my_string_key_map ;
std::map< int , std::string > my_string_data_map ;
std::map< std::string , std::string > my_string_map ;
std::multimap< int , int > my_int_multimap ;
std::multimap< std::string , int > my_string_key_multimap ;
std::multimap< int , std::string > my_string_data_multimap ;
std::multimap< std::string , std::string > my_string_multimap ;
std::vector< double > my_double_vector ;
std::vector< std::string > my_string_vector ;
std::list< short > my_short_list ;
std::list< std::string > my_string_list ;
std::deque< float > my_float_deque ;
std::deque< std::string > my_string_deque ;
std::set< int > my_int_set ;
std::set< std::string > my_string_set ;
std::multiset< long > my_long_multiset ;
std::multiset< std::string > my_string_multiset ;
std::stack< unsigned int > my_uint_stack ;
std::stack< std::string > my_string_stack ;
std::queue< int > my_int_queue ;
std::queue< std::string > my_string_queue ;
std::priority_queue< int > my_int_priority_queue ;
std::priority_queue< std::string > my_string_priority_queue ;
std::pair< int , int > my_int_pair ;
std::pair< std::string , int > my_string_first_pair ;
std::pair< int , std::string > my_string_second_pair ;
std::pair< std::string , std::string > my_string_pair ;
} ;
#endif

View File

@ -1,57 +0,0 @@
CHECKPOINT_STL(stlc.my_double_map) ;
CHECKPOINT_STL(stlc.my_string_key_map) ;
CHECKPOINT_STL(stlc.my_string_data_map) ;
CHECKPOINT_STL(stlc.my_string_map) ;
CHECKPOINT_STL(stlc.my_int_multimap) ;
CHECKPOINT_STL(stlc.my_string_key_multimap) ;
CHECKPOINT_STL(stlc.my_string_data_multimap) ;
CHECKPOINT_STL(stlc.my_string_multimap) ;
CHECKPOINT_STL(stlc.my_double_vector) ;
CHECKPOINT_STL(stlc.my_string_vector) ;
CHECKPOINT_STL(stlc.my_short_list) ;
CHECKPOINT_STL(stlc.my_string_list) ;
CHECKPOINT_STL(stlc.my_float_deque) ;
CHECKPOINT_STL(stlc.my_string_deque) ;
CHECKPOINT_STL(stlc.my_int_set) ;
CHECKPOINT_STL(stlc.my_string_set) ;
CHECKPOINT_STL(stlc.my_long_multiset) ;
CHECKPOINT_STL(stlc.my_string_multiset) ;
CHECKPOINT_STL(stlc.my_uint_stack) ;
CHECKPOINT_STL(stlc.my_string_stack) ;
CHECKPOINT_STL(stlc.my_int_queue) ;
CHECKPOINT_STL(stlc.my_string_queue) ;
CHECKPOINT_STL(stlc.my_int_priority_queue) ;
CHECKPOINT_STL(stlc.my_string_priority_queue) ;
CHECKPOINT_STL(stlc.my_int_pair) ;
CHECKPOINT_STL(stlc.my_string_first_pair) ;
CHECKPOINT_STL(stlc.my_string_second_pair) ;
CHECKPOINT_STL(stlc.my_string_pair) ;
CHECKPOINT_STL(stlc2.my_double_map) ;
CHECKPOINT_STL(stlc2.my_string_key_map) ;
CHECKPOINT_STL(stlc2.my_string_data_map) ;
CHECKPOINT_STL(stlc2.my_string_map) ;
CHECKPOINT_STL(stlc2.my_int_multimap) ;
CHECKPOINT_STL(stlc2.my_string_key_multimap) ;
CHECKPOINT_STL(stlc2.my_string_data_multimap) ;
CHECKPOINT_STL(stlc2.my_string_multimap) ;
CHECKPOINT_STL(stlc2.my_double_vector) ;
CHECKPOINT_STL(stlc2.my_string_vector) ;
CHECKPOINT_STL(stlc2.my_short_list) ;
CHECKPOINT_STL(stlc2.my_string_list) ;
CHECKPOINT_STL(stlc2.my_float_deque) ;
CHECKPOINT_STL(stlc2.my_string_deque) ;
CHECKPOINT_STL(stlc2.my_int_set) ;
CHECKPOINT_STL(stlc2.my_string_set) ;
CHECKPOINT_STL(stlc2.my_long_multiset) ;
CHECKPOINT_STL(stlc2.my_string_multiset) ;
CHECKPOINT_STL(stlc2.my_uint_stack) ;
CHECKPOINT_STL(stlc2.my_string_stack) ;
CHECKPOINT_STL(stlc2.my_int_queue) ;
CHECKPOINT_STL(stlc2.my_string_queue) ;
CHECKPOINT_STL(stlc2.my_int_priority_queue) ;
CHECKPOINT_STL(stlc2.my_string_priority_queue) ;
CHECKPOINT_STL(stlc2.my_int_pair) ;
CHECKPOINT_STL(stlc2.my_string_first_pair) ;
CHECKPOINT_STL(stlc2.my_string_second_pair) ;
CHECKPOINT_STL(stlc2.my_string_pair) ;

View File

@ -1,8 +0,0 @@
def main():
trick.checkpoint_pre_init(True)
trick.stop(1.0)
if __name__ == "__main__":
main()

View File

@ -1,9 +0,0 @@
def main():
trick.real_time_enable()
trick.exec_set_software_frame(0.1)
trick.sim_control_panel_set_enabled(True)
if __name__ == "__main__":
main()

View File

@ -1,23 +0,0 @@
/*
This sim demonstrates the use of Trick STLs. Trick includes
checkpointable versions of all the STL constructs.
*/
#include "sim_objects/default_trick_sys.sm"
##include "TrickSTL/include/TrickSTLCheckpoint.hh"
class theSimObject : public Trick::SimObject {
public:
TrickSTLCheckpoint tstlc ;
theSimObject() {
(1.0, "scheduled") tstlc.speak() ;
(1.0, "freeze_scheduled") tstlc.speak() ;
}
} ;
theSimObject the_object ;

View File

@ -1,4 +0,0 @@
TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I./models -std=c++11

View File

@ -1,167 +0,0 @@
/*
PURPOSE: (Illustrate how to checkpoint STLs)
LIBRARY_DEPENDENCIES: (
(TrickSTLCheckpoint.o)
)
*/
#ifndef TRICKSTLCHECKPOINT_HH_
#define TRICKSTLCHECKPOINT_HH_
#include <string>
#include "sim_services/STL/include/trick_vector.hh"
#include "sim_services/STL/include/trick_list.hh"
#include "sim_services/STL/include/trick_deque.hh"
#include "sim_services/STL/include/trick_set.hh"
#include "sim_services/STL/include/trick_map.hh"
#include "sim_services/STL/include/trick_stack.hh"
#include "sim_services/STL/include/trick_queue.hh"
#include "sim_services/STL/include/trick_pair.hh"
class ClassOfInts {
public:
int i1 ;
int i2 ;
int i3 ;
bool operator < ( const ClassOfInts & c ) const {
return i1 > c.i1 ;
}
} ;
class TrickSTLCheckpoint {
public:
TrickSTLCheckpoint() ;
int speak() ;
std::string name ;
/* VECTOR */
Trick::vector< double > vector_double ;
Trick::vector< double , std::allocator<double> > vector_double_alloc ;
Trick::vector< std::string > vector_string ;
Trick::vector< double > vector_range ;
Trick::vector< double > vector_fill ;
Trick::vector< double > vector_copy ;
Trick::vector< ClassOfInts > vector_class ;
Trick::vector< ClassOfInts * > vector_class_ptr ;
Trick::vector< Trick::vector< double > > vector_vector_double ;
/* LIST */
Trick::list< double > list_double ;
Trick::list< double , std::allocator<double> > list_double_alloc ;
Trick::list< std::string > list_string ;
Trick::list< double > list_range ;
Trick::list< double > list_fill ;
Trick::list< double > list_copy ;
Trick::list< ClassOfInts > list_class ;
Trick::list< ClassOfInts * > list_class_ptr ;
Trick::list< Trick::list< double > > list_list_double ;
/* DEQUE */
Trick::deque< double > deque_double ;
Trick::deque< double , std::allocator<double> > deque_double_alloc ;
Trick::deque< std::string > deque_string ;
Trick::deque< double > deque_range ;
Trick::deque< double > deque_fill ;
Trick::deque< double > deque_copy ;
Trick::deque< ClassOfInts > deque_class ;
Trick::deque< ClassOfInts * > deque_class_ptr ;
Trick::deque< Trick::deque< double > > deque_deque_double ;
/* SET */
Trick::set< double > set_double ;
Trick::set< double , std::less< double > > set_double_compare ;
Trick::set< double , std::less< double > , std::allocator<double> > set_double_compare_alloc ;
Trick::set< std::string > set_string ;
Trick::set< double > set_range ;
Trick::set< double > set_fill ;
Trick::set< double > set_copy ;
Trick::set< ClassOfInts > set_class ;
Trick::set< ClassOfInts * > set_class_ptr ;
Trick::set< Trick::set< double > > set_set_double ;
/* MULTISET */
Trick::multiset< double > multiset_double ;
Trick::multiset< double , std::less< double > > multiset_double_compare ;
Trick::multiset< double , std::less< double > , std::allocator<double> > multiset_double_compare_alloc ;
Trick::multiset< std::string > multiset_string ;
Trick::multiset< double > multiset_range ;
Trick::multiset< double > multiset_fill ;
Trick::multiset< double > multiset_copy ;
Trick::multiset< ClassOfInts > multiset_class ;
Trick::multiset< ClassOfInts * > multiset_class_ptr ;
Trick::multiset< Trick::multiset< double > > multiset_multiset_double ;
/* MAP */
Trick::map< double , double > map_double_double ;
Trick::map< int , std::string > map_int_string ;
Trick::map< int , Trick::vector< double > > map_int_vector_double ;
Trick::map< std::string , int > map_string_int ;
Trick::map< std::string , std::string > map_string_string ;
Trick::map< std::string , Trick::vector< double > > map_string_vector_double ;
Trick::map< Trick::list< int > , double > map_list_int_double ;
Trick::map< Trick::list< int > , std::string > map_list_int_string ;
Trick::map< Trick::list< int > , Trick::vector< double > > map_list_int_vector_double ;
/* MULTIMAP */
Trick::multimap< double , double > multimap_double_double ;
Trick::multimap< int , std::string > multimap_int_string ;
Trick::multimap< int , Trick::vector< double > > multimap_int_vector_double ;
Trick::multimap< std::string , int > multimap_string_int ;
Trick::multimap< std::string , std::string > multimap_string_string ;
Trick::multimap< std::string , Trick::vector< double > > multimap_string_vector_double ;
Trick::multimap< Trick::list< int > , double > multimap_list_int_double ;
Trick::multimap< Trick::list< int > , std::string > multimap_list_int_string ;
Trick::multimap< Trick::list< int > , Trick::vector< double > > multimap_list_int_vector_double ;
/* STACK */
Trick::stack< unsigned int > stack_uint ;
Trick::stack< std::string > stack_string ;
Trick::stack< Trick::vector< double > > stack_vector_double ;
/* QUEUE */
Trick::queue< unsigned int > queue_uint ;
Trick::queue< std::string > queue_string ;
Trick::queue< Trick::vector< double > > queue_vector_double ;
/* PRIORITY QUEUE */
Trick::priority_queue< unsigned int > priority_queue_uint ;
Trick::priority_queue< std::string > priority_queue_string ;
Trick::priority_queue< Trick::vector< double > > priority_queue_vector_double ;
/* PAIRS */
Trick::pair< int , int > pair_int_int ;
Trick::pair< int , int > pair_fill_int_int ;
Trick::pair< int , std::string > pair_int_string ;
Trick::pair< int , Trick::list< int > > pair_int_list_int ;
Trick::pair< std::string , int > pair_string_int ;
Trick::pair< std::string , std::string > pair_string_string ;
Trick::pair< std::string , Trick::list< int > > pair_string_list_int ;
Trick::pair< Trick::list< int > , int > pair_list_int_int ;
Trick::pair< Trick::list< int > , std::string > pair_list_int_string ;
Trick::pair< Trick::list< int > , Trick::list< int > > pair_list_int_list_int ;
} ;
#endif

View File

@ -1,504 +0,0 @@
#include "TrickSTLCheckpoint.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/MemoryManager/include/memorymanager_c_intf.h"
double matrix[3][3] = {{101,102,103},{104,105,106},{107,108,109}} ;
TrickSTLCheckpoint::TrickSTLCheckpoint()
: vector_range(matrix[2], matrix[2] + 3) ,
vector_fill( 5 , 200 ) ,
vector_copy( vector_range ) ,
list_range(matrix[2], matrix[2] + 3) ,
list_fill( 5 , 200 ) ,
list_copy( list_range ) ,
deque_range(matrix[2], matrix[2] + 3) ,
deque_fill( 5 , 200 ) ,
deque_copy( deque_range ) ,
pair_fill_int_int( 92 , 93 )
{
ClassOfInts coi ;
ClassOfInts * coi_ptr ;
/* VECTOR */
vector_double.push_back(1.0) ;
vector_double.push_back(2.0) ;
vector_double.push_back(3.0) ;
vector_double_alloc.push_back(4.0) ;
vector_double_alloc.push_back(5.0) ;
vector_double_alloc.push_back(6.0) ;
vector_string.push_back("I") ;
vector_string.push_back("was") ;
vector_string.push_back("here") ;
coi.i1 = 1 ;
coi.i2 = 2 ;
coi.i3 = 3 ;
vector_class.push_back(coi) ;
coi.i1 = 4 ;
coi.i2 = 5 ;
coi.i3 = 6 ;
vector_class.push_back(coi) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 11 ;
coi_ptr->i2 = 12 ;
coi_ptr->i3 = 13 ;
vector_class_ptr.push_back(coi_ptr) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 14 ;
coi_ptr->i2 = 15 ;
coi_ptr->i3 = 16 ;
vector_class_ptr.push_back(coi_ptr) ;
Trick::vector< double > vector_d3( 3 , 300 ) ;
Trick::vector< double > vector_d4( 4 , 400 ) ;
Trick::vector< double > vector_d5( 5 , 500 ) ;
vector_vector_double.push_back(vector_d3) ;
vector_vector_double.push_back(vector_d4) ;
vector_vector_double.push_back(vector_d5) ;
/* LIST */
list_double.push_back(1.0) ;
list_double.push_back(2.0) ;
list_double.push_back(3.0) ;
list_double_alloc.push_back(4.0) ;
list_double_alloc.push_back(5.0) ;
list_double_alloc.push_back(6.0) ;
list_string.push_back("I") ;
list_string.push_back("was") ;
list_string.push_back("here") ;
coi.i1 = 1 ;
coi.i2 = 2 ;
coi.i3 = 3 ;
list_class.push_back(coi) ;
coi.i1 = 4 ;
coi.i2 = 5 ;
coi.i3 = 6 ;
list_class.push_back(coi) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 11 ;
coi_ptr->i2 = 12 ;
coi_ptr->i3 = 13 ;
list_class_ptr.push_back(coi_ptr) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 14 ;
coi_ptr->i2 = 15 ;
coi_ptr->i3 = 16 ;
list_class_ptr.push_back(coi_ptr) ;
Trick::list< double > list_d3( 3 , 300 ) ;
Trick::list< double > list_d4( 4 , 400 ) ;
Trick::list< double > list_d5( 5 , 500 ) ;
list_list_double.push_back(list_d3) ;
list_list_double.push_back(list_d4) ;
list_list_double.push_back(list_d5) ;
/* DEQUE */
deque_double.push_back(1.0) ;
deque_double.push_back(2.0) ;
deque_double.push_back(3.0) ;
deque_double_alloc.push_back(4.0) ;
deque_double_alloc.push_back(5.0) ;
deque_double_alloc.push_back(6.0) ;
deque_string.push_back("I") ;
deque_string.push_back("was") ;
deque_string.push_back("here") ;
coi.i1 = 1 ;
coi.i2 = 2 ;
coi.i3 = 3 ;
deque_class.push_back(coi) ;
coi.i1 = 4 ;
coi.i2 = 5 ;
coi.i3 = 6 ;
deque_class.push_back(coi) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 11 ;
coi_ptr->i2 = 12 ;
coi_ptr->i3 = 13 ;
deque_class_ptr.push_back(coi_ptr) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 14 ;
coi_ptr->i2 = 15 ;
coi_ptr->i3 = 16 ;
deque_class_ptr.push_back(coi_ptr) ;
Trick::deque< double > deque_d3( 3 , 300 ) ;
Trick::deque< double > deque_d4( 4 , 400 ) ;
Trick::deque< double > deque_d5( 5 , 500 ) ;
deque_deque_double.push_back(deque_d3) ;
deque_deque_double.push_back(deque_d4) ;
deque_deque_double.push_back(deque_d5) ;
/* SET */
set_double.insert(1.0) ;
set_double.insert(2.0) ;
set_double.insert(3.0) ;
set_double_compare_alloc.insert(4.0) ;
set_double_compare_alloc.insert(5.0) ;
set_double_compare_alloc.insert(6.0) ;
set_string.insert("I") ;
set_string.insert("was") ;
set_string.insert("here") ;
coi.i1 = 1 ;
coi.i2 = 2 ;
coi.i3 = 3 ;
set_class.insert(coi) ;
coi.i1 = 4 ;
coi.i2 = 5 ;
coi.i3 = 6 ;
set_class.insert(coi) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 11 ;
coi_ptr->i2 = 12 ;
coi_ptr->i3 = 13 ;
set_class_ptr.insert(coi_ptr) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 14 ;
coi_ptr->i2 = 15 ;
coi_ptr->i3 = 16 ;
set_class_ptr.insert(coi_ptr) ;
Trick::set< double > set_d3( matrix[0], matrix[0] + 3 ) ;
Trick::set< double > set_d4( matrix[1], matrix[1] + 3 ) ;
Trick::set< double > set_d5( matrix[2], matrix[2] + 3 ) ;
set_set_double.insert(set_d3) ;
set_set_double.insert(set_d4) ;
set_set_double.insert(set_d5) ;
/* MULTISET */
multiset_double.insert(1.0) ;
multiset_double.insert(2.0) ;
multiset_double.insert(3.0) ;
multiset_double_compare_alloc.insert(4.0) ;
multiset_double_compare_alloc.insert(5.0) ;
multiset_double_compare_alloc.insert(6.0) ;
multiset_string.insert("I") ;
multiset_string.insert("was") ;
multiset_string.insert("here") ;
coi.i1 = 1 ;
coi.i2 = 2 ;
coi.i3 = 3 ;
multiset_class.insert(coi) ;
coi.i1 = 4 ;
coi.i2 = 5 ;
coi.i3 = 6 ;
multiset_class.insert(coi) ;
// Add an extra copy for multi-set.
multiset_class.insert(coi) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 11 ;
coi_ptr->i2 = 12 ;
coi_ptr->i3 = 13 ;
multiset_class_ptr.insert(coi_ptr) ;
coi_ptr = (ClassOfInts *)TMM_declare_var_1d("ClassOfInts" , 1) ;
coi_ptr->i1 = 14 ;
coi_ptr->i2 = 15 ;
coi_ptr->i3 = 16 ;
multiset_class_ptr.insert(coi_ptr) ;
Trick::multiset< double > multiset_d3( matrix[0], matrix[0] + 3 ) ;
Trick::multiset< double > multiset_d4( matrix[1], matrix[1] + 3 ) ;
Trick::multiset< double > multiset_d5( matrix[2], matrix[2] + 3 ) ;
multiset_multiset_double.insert(multiset_d3) ;
multiset_multiset_double.insert(multiset_d4) ;
multiset_multiset_double.insert(multiset_d5) ;
/* MAP */
map_double_double[11.1] = 111.1 ;
map_double_double[22.2] = 222.2 ;
map_double_double[33.3] = 333.3 ;
map_string_int[std::string("one")] = 1 ;
map_string_int[std::string("two")] = 2 ;
map_string_int[std::string("three")] = 3 ;
map_int_string[4] = std::string("vier") ;
map_int_string[5] = std::string("fumf") ;
map_int_string[6] = std::string("sechs") ;
map_string_string[std::string("mother")] = std::string("Marge") ;
map_string_string[std::string("father")] = std::string("Homer") ;
map_string_string[std::string("son")] = std::string("Bart") ;
map_int_vector_double[80] = vector_d3 ;
map_int_vector_double[81] = vector_d4 ;
map_int_vector_double[82] = vector_d5 ;
map_string_vector_double[std::string("cat")] = vector_d3 ;
map_string_vector_double[std::string("dog")] = vector_d4 ;
map_string_vector_double[std::string("duck")] = vector_d5 ;
Trick::list< int > list_int_i1(3 , 111) ;
Trick::list< int > list_int_i2(3 , 222) ;
map_list_int_double[list_int_i1] = 11.1 ;
map_list_int_double[list_int_i2] = 22.2 ;
// this line should overwrite the previous
map_list_int_double[list_int_i2] = 33.3 ;
map_list_int_string[list_int_i1] = std::string("banana") ;
map_list_int_string[list_int_i2] = std::string("apple") ;
map_list_int_vector_double[list_int_i1] = vector_d3 ;
map_list_int_vector_double[list_int_i2] = vector_d4 ;
/* MULTIMAP */
multimap_double_double.insert(std::pair<double, double >(11.1,111.1)) ;
multimap_double_double.insert(std::pair<double, double >(22.2,222.2)) ;
multimap_double_double.insert(std::pair<double, double >(33.2,333.3)) ;
multimap_string_int.insert(std::pair<std::string, int >(std::string("one"),1)) ;
multimap_string_int.insert(std::pair<std::string, int >(std::string("two"),2)) ;
multimap_string_int.insert(std::pair<std::string, int >(std::string("three"),3)) ;
multimap_int_string.insert(std::pair<int, std::string >(4 , std::string("vier"))) ;
multimap_int_string.insert(std::pair<int, std::string >(5 , std::string("fumf"))) ;
multimap_int_string.insert(std::pair<int, std::string >(6 , std::string("sechs"))) ;
multimap_string_string.insert(std::pair<std::string, std::string >(std::string("mother") , std::string("Marge"))) ;
multimap_string_string.insert(std::pair<std::string, std::string >(std::string("father") , std::string("Homer"))) ;
multimap_string_string.insert(std::pair<std::string, std::string >(std::string("son") , std::string("Bart"))) ;
multimap_int_vector_double.insert(std::pair<int, Trick::vector<double > >(80, vector_d3)) ;
multimap_int_vector_double.insert(std::pair<int, Trick::vector<double > >(81, vector_d4)) ;
multimap_int_vector_double.insert(std::pair<int, Trick::vector<double > >(82, vector_d5)) ;
multimap_string_vector_double.insert(std::pair<std::string, Trick::vector<double > >(std::string("cat"), vector_d3)) ;
multimap_string_vector_double.insert(std::pair<std::string, Trick::vector<double > >(std::string("dog"), vector_d4)) ;
multimap_string_vector_double.insert(std::pair<std::string, Trick::vector<double > >(std::string("duck"), vector_d5)) ;
multimap_list_int_double.insert(std::pair< Trick::list<int >, double >(list_int_i1, 11.1)) ;
multimap_list_int_double.insert(std::pair< Trick::list<int >, double >(list_int_i2, 22.2)) ;
// this line should not overwrite the previous
multimap_list_int_double.insert(std::pair< Trick::list<int >, double >(list_int_i2, 33.3)) ;
multimap_list_int_string.insert(std::pair< Trick::list<int >, std::string >(list_int_i1, std::string("banana"))) ;
multimap_list_int_string.insert(std::pair< Trick::list<int >, std::string >(list_int_i2, std::string("apple"))) ;
multimap_list_int_vector_double.insert(std::pair< Trick::list<int >, Trick::vector<double > >(list_int_i1, vector_d3)) ;
multimap_list_int_vector_double.insert(std::pair< Trick::list<int >, Trick::vector<double > >(list_int_i2, vector_d4)) ;
stack_uint.push(60) ;
stack_uint.push(61) ;
stack_uint.push(62) ;
stack_uint.push(63) ;
stack_string.push("abc I") ;
stack_string.push("abc want the one") ;
stack_string.push("abc with the bigger") ;
stack_string.push("abc Gee Bees") ;
stack_vector_double.push(vector_d3) ;
stack_vector_double.push(vector_d4) ;
stack_vector_double.push(vector_d5) ;
queue_uint.push(70) ;
queue_uint.push(71) ;
queue_uint.push(72) ;
queue_uint.push(73) ;
queue_string.push("efg I") ;
queue_string.push("efg want the one") ;
queue_string.push("efg with the bigger") ;
queue_string.push("efg Gee Bees") ;
queue_vector_double.push(vector_d3) ;
queue_vector_double.push(vector_d4) ;
queue_vector_double.push(vector_d5) ;
priority_queue_uint.push(81) ;
priority_queue_uint.push(80) ;
priority_queue_uint.push(83) ;
priority_queue_uint.push(82) ;
priority_queue_string.push("efg I") ;
priority_queue_string.push("efg want the one") ;
priority_queue_string.push("efg with the bigger") ;
priority_queue_string.push("efg Gee Bees") ;
priority_queue_vector_double.push(vector_d3) ;
priority_queue_vector_double.push(vector_d4) ;
priority_queue_vector_double.push(vector_d5) ;
pair_int_int = Trick::make_pair( 90 , 91 ) ;
pair_int_string = Trick::make_pair( 94 , "earth" ) ;
pair_int_list_int = Trick::make_pair( 95 , list_int_i1 ) ;
pair_string_int = Trick::make_pair( "mars" , 2 ) ;
pair_string_string = Trick::make_pair( "blue" , "moon" ) ;
pair_string_list_int = Trick::make_pair( "tissue" , list_int_i2 ) ;
pair_list_int_int = Trick::make_pair( list_int_i1 , 96 ) ;
pair_list_int_string = Trick::make_pair( list_int_i1 , "bag" ) ;
pair_list_int_list_int = Trick::make_pair( list_int_i1 , list_int_i2 ) ;
}
template< typename T>
void print_sequence(T & container) {
typename T::iterator lit ;
for ( lit = container.begin() ; lit != container.end() ; lit++ ) {
std::cout << (*lit) << " " ;
}
std::cout << std::endl ;
}
template< typename T>
void print_class_of_ints(T & container) {
typename T::iterator lit ;
unsigned int ii ;
for ( ii = 0 , lit = container.begin() ; lit != container.end() ; ii++ , lit++ ) {
std::cout << "ii = " << ii << ": " << (*lit).i1 << " " << (*lit).i2 ;
std::cout << " " << (*lit).i3 << std::endl ;
}
}
template< typename T>
void print_2d_container(T & container) {
typename T::iterator lldit ;
for ( lldit = container.begin() ; lldit != container.end() ; lldit++ ) {
std::cout << "size = " << (*lldit).size() << std::endl ;
typename T::value_type::iterator ldit ;
for ( ldit = (*lldit).begin() ; ldit != (*lldit).end() ; ldit++ ) {
std::cout << (*ldit) << " " ;
}
std::cout << std::endl ;
}
}
template< typename T>
void print_map(T & container) {
typename T::iterator lit ;
unsigned int ii ;
for ( ii = 0 , lit = container.begin() ; lit != container.end() ; ii++ , lit++ ) {
std::cout << "ii = " << ii << ": " << (*lit).first << " " << (*lit).second << std::endl ;
}
}
template< typename T>
void print_map_keys(T & container) {
typename T::iterator lit ;
unsigned int ii ;
for ( ii = 0 , lit = container.begin() ; lit != container.end() ; ii++ , lit++ ) {
std::cout << "ii = " << ii << ": " << (*lit).first << std::endl ;
}
}
template< typename T>
void print_map_data(T & container) {
typename T::iterator lit ;
unsigned int ii ;
for ( ii = 0 , lit = container.begin() ; lit != container.end() ; ii++ , lit++ ) {
std::cout << "ii = " << ii << ": " << (*lit).second << std::endl ;
}
}
int TrickSTLCheckpoint::speak() {
std::cout << "VECTOR" << std::endl ;
print_class_of_ints< Trick::vector< ClassOfInts > >( vector_class ) ;
print_2d_container< Trick::vector< Trick::vector< double > > >( vector_vector_double ) ;
std::cout << std::endl ;
std::cout << "LIST" << std::endl ;
print_class_of_ints< Trick::list< ClassOfInts > >( list_class ) ;
print_2d_container< Trick::list< Trick::list< double > > >( list_list_double ) ;
std::cout << std::endl ;
std::cout << "DEQUE" << std::endl ;
print_class_of_ints< Trick::deque< ClassOfInts > >( deque_class ) ;
print_2d_container< Trick::deque< Trick::deque< double > > >( deque_deque_double ) ;
std::cout << std::endl ;
std::cout << "SET" << std::endl ;
print_class_of_ints< Trick::set< ClassOfInts > >( set_class ) ;
print_2d_container< Trick::set< Trick::set< double > > >( set_set_double ) ;
std::cout << std::endl ;
std::cout << "MULTISET" << std::endl ;
print_class_of_ints< Trick::multiset< ClassOfInts > >( multiset_class ) ;
print_2d_container< Trick::multiset< Trick::multiset< double > > >( multiset_multiset_double ) ;
std::cout << std::endl ;
std::cout << "MAP" << std::endl ;
print_map< Trick::map< double,double > >( map_double_double ) ;
print_map< Trick::map< std::string,int > >( map_string_int ) ;
print_map< Trick::map< int,std::string > >( map_int_string ) ;
print_map< Trick::map< std::string,std::string > >( map_string_string ) ;
print_map_keys< Trick::map< int , Trick::vector< double > > >( map_int_vector_double ) ;
print_map_keys< Trick::map< std::string , Trick::vector< double > > >( map_string_vector_double ) ;
print_map_data< Trick::map< Trick::list< int > , double > >( map_list_int_double ) ;
print_map_data< Trick::map< Trick::list< int > , std::string > >( map_list_int_string ) ;
std::cout << std::endl ;
std::cout << "MULTIMAP" << std::endl ;
print_map< Trick::multimap< double,double > >( multimap_double_double ) ;
print_map< Trick::multimap< std::string,int > >( multimap_string_int ) ;
print_map< Trick::multimap< int,std::string > >( multimap_int_string ) ;
print_map< Trick::multimap< std::string,std::string > >( multimap_string_string ) ;
print_map_keys< Trick::multimap< int , Trick::vector< double > > >( multimap_int_vector_double ) ;
print_map_keys< Trick::multimap< std::string , Trick::vector< double > > >( multimap_string_vector_double ) ;
print_map_data< Trick::multimap< Trick::list< int > , double > >( multimap_list_int_double ) ;
print_map_data< Trick::multimap< Trick::list< int > , std::string > >( multimap_list_int_string ) ;
std::cout << std::endl ;
std::cout << "STACK" << std::endl ;
std::cout << "top " << stack_uint.top() << std::endl ;
std::cout << "top " << stack_string.top() << std::endl ;
print_sequence< Trick::vector< double > >( stack_vector_double.top() ) ;
std::cout << std::endl ;
std::cout << "QUEUE" << std::endl ;
std::cout << "front " << queue_uint.front() << std::endl ;
std::cout << "front " << queue_string.front() << std::endl ;
print_sequence< Trick::vector< double > >( queue_vector_double.front() ) ;
std::cout << std::endl ;
std::cout << "PRIORITY QUEUE" << std::endl ;
std::cout << "top " << priority_queue_uint.top() << std::endl ;
std::cout << "top " << priority_queue_string.top() << std::endl ;
//print_sequence< Trick::vector< double > >( priority_queue_vector_double.top() ) ;
std::cout << std::endl ;
std::cout << "PAIR" << std::endl ;
std::cout << "pair_int_int " << pair_int_int.first << " " << pair_int_int.second << std::endl ;
std::cout << "pair_fill_int_int " << pair_fill_int_int.first << " " << pair_fill_int_int.second << std::endl ;
std::cout << "pair_int_string " << pair_int_string.first << " " << pair_int_string.second << std::endl ;
std::cout << "pair_int_list_int " << pair_int_list_int.first << std::endl ;
print_sequence< Trick::list< int > >(pair_int_list_int.second) ;
std::cout << "pair_string_int " << pair_string_int.first << " " << pair_string_int.second << std::endl ;
std::cout << "pair_string_string " << pair_string_string.first << " " << pair_string_string.second << std::endl ;
std::cout << "pair_string_list_int " << pair_string_list_int.first << std::endl ;
print_sequence< Trick::list< int > >(pair_string_list_int.second) ;
std::cout << "pair_list_int_int " << std::endl ;
print_sequence< Trick::list< int > >(pair_list_int_int.first) ;
std::cout << pair_list_int_int.second << std::endl ;
std::cout << "pair_list_int_string " << std::endl ;
print_sequence< Trick::list< int > >(pair_list_int_string.first) ;
std::cout << pair_list_int_string.second << std::endl ;
std::cout << "pair_list_int_list_int " << std::endl ;
print_sequence< Trick::list< int > >(pair_list_int_list_int.first) ;
print_sequence< Trick::list< int > >(pair_list_int_list_int.second) ;
std::cout << std::endl ;
return 0 ;
}

View File

@ -7,7 +7,6 @@ COMPILE_DIRS = \
SIM_events \
SIM_rti \
SIM_stls \
SIM_stls2 \
SIM_test_dp \
SIM_test_dr \
SIM_test_io \
@ -30,7 +29,6 @@ SIMS_NEEDING_TEST = \
# SIM_test_varserv ( not sure what it is testing )
# SIM_dynamic_sim_object ( not running, class won't instantiate )
# SIM_segments ( not a test, but a demo )
# SIM_stls3 ( not compiling on most platforms )
# This test is temporarily sitting out until fixed.
# SIM_test_varserv

View File

@ -40,8 +40,11 @@ void ConstructValues::getNamespacesAndClasses( const clang::DeclContext * Ctx )
if (const clang::NamespaceDecl *nd = clang::dyn_cast<clang::NamespaceDecl>(*I)) {
if (! nd->isAnonymousNamespace()) {
//std::cout << "namespace " << nd->getIdentifier()->getName().str() << std::endl ;
std::string temp_name = nd->getIdentifier()->getName().str() ;
if ( temp_name.compare("std") and temp_name.compare("__1")) {
addNamespace(nd->getIdentifier()->getName().str()) ;
}
}
} else if (const clang::RecordDecl *rd = clang::dyn_cast<clang::RecordDecl>(*I)) {
if (rd->getIdentifier()) {
//std::cout << "in class " << rd->getName().str() << std::endl ;

View File

@ -35,6 +35,8 @@ FieldDescription::FieldDescription(
bitfield_word_offset(0) ,
is_enum(0) ,
is_record(0) ,
is_stl(0) ,
has_stl_clear(1) ,
is_static(0) ,
num_dims(0) ,
array_sizes() {} ;
@ -368,6 +370,22 @@ bool FieldDescription::isRecord() {
return is_record ;
}
void FieldDescription::setSTL(bool yes_no) {
is_stl = yes_no ;
}
bool FieldDescription::isSTL() {
return is_stl ;
}
void FieldDescription::setSTLClear(bool yes_no) {
has_stl_clear = yes_no ;
}
bool FieldDescription::hasSTLClear() {
return has_stl_clear ;
}
void FieldDescription::setStatic(bool yes_no) {
is_static = yes_no ;
}

View File

@ -70,6 +70,10 @@ class FieldDescription : public ConstructValues {
bool isEnum() ;
void setRecord( bool yes_no ) ;
bool isRecord() ;
void setSTL( bool yes_no ) ;
bool isSTL() ;
void setSTLClear( bool yes_no ) ;
bool hasSTLClear() ;
void setStatic( bool yes_no ) ;
bool isStatic() ;
bool getAccessSpecFound() ;
@ -150,6 +154,12 @@ class FieldDescription : public ConstructValues {
/** is a record class */
bool is_record ;
/** is an stl */
bool is_stl ;
/** does this stl have a clear */
bool has_stl_clear ;
/** is this field declared static */
bool is_static ;

View File

@ -5,6 +5,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Comment.h"
#include "FieldVisitor.hh"
#include "FieldDescription.hh"
@ -143,27 +144,28 @@ bool FieldVisitor::VisitDeclaratorDecl( clang::DeclaratorDecl *dd ) {
/* Get the source location of this field. */
clang::SourceRange dd_range = dd->getSourceRange() ;
std::string file_name = ci.getSourceManager().getBufferName(dd_range.getEnd()) ;
char * resolved_path = almostRealPath( file_name.c_str() ) ;
if ( resolved_path ) {
std::string file_name = getFileName(ci, dd_range.getEnd(), hsd) ;
if ( ! file_name.empty() ) {
if ( isInUserOrTrickCode( ci , dd_range.getEnd() , hsd ) ) {
fdes->setLineNo(ci.getSourceManager().getSpellingLineNumber(dd_range.getEnd())) ;
/* process comment if neither ICG:(No) or ICG:(NoComment) is present */
if ( cs.hasTrickHeader(resolved_path) and
!cs.hasICGNoComment(resolved_path) and
!hsd.isPathInICGNoComment(resolved_path) ) {
if ( cs.hasTrickHeader(file_name) and
!cs.hasICGNoComment(file_name) and
!hsd.isPathInICGNoComment(file_name) ) {
/* Get the possible comment on this line and parse it */
fdes->parseComment(cs.getComment(resolved_path , fdes->getLineNo())) ;
fdes->parseComment(cs.getComment(file_name , fdes->getLineNo())) ;
}
}
free(resolved_path) ;
}
if ( debug_level >= 3 ) {
if ( ! ci.getSourceManager().isInSystemHeader(dd_range.getEnd()) ) {
std::cout << "FieldVisitor VisitDeclaratorDecl" << std::endl ;
//dd->dump() ;
std::cout << " file_name = " << file_name << std::endl ;
std::cout << " line num = " << fdes->getLineNo() << std::endl ;
std::cout << " comment = " << cs.getComment(file_name , fdes->getLineNo()) << std::endl ;
std::cout << " public/private = " << fdes->getAccess() << std::endl ;
std::cout << " io = " << fdes->getIO() << std::endl ;
}
}
@ -217,19 +219,12 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) {
if ( !qt.isCanonical() ) {
clang::QualType ct = qt.getCanonicalType() ;
std::string tst_string = ct.getAsString() ;
// If we have a standard template library specializations other than std::string, don't process it.
if ( (! tst_string.compare( 0 , 9 , "class std") or ! tst_string.compare( 0 , 10 , "struct std")) and
tst_string.compare( 0, 23 , "class std::basic_string") ) {
// This is a standard template library type. don't process any further.
fdes->setIO(0) ;
} else {
if ( debug_level >= 3 ) {
std::cout << "\033[33mFieldVisitor VisitFieldDecl: Processing canonical type\033[00m" << std::endl ;
ct.dump() ;
}
TraverseType(ct) ;
}
// We have either skipped a std template or extracted the canonical type and everything else we need
// We have extracted the canonical type and everything else we need
// return false so we cut off processing of this AST branch
return false ;
}
@ -242,30 +237,7 @@ bool FieldVisitor::VisitPointerType(clang::PointerType *p) {
return true;
}
std::map < std::string , std::string > FieldVisitor::processed_templates ;
bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl * crd ) {
// Save container namespaces and classes.
fdes->getNamespacesAndClasses(crd->getDeclContext()) ;
size_t pos ;
if ((pos = in_name.find("class ")) != std::string::npos ) {
in_name.erase(pos , 6) ;
}
// clang changes bool to _Bool. We need to change it back
if ((pos = in_name.find("<_Bool")) != std::string::npos ) {
in_name.replace(pos , 6, "<bool") ;
}
while ((pos = in_name.find(" _Bool")) != std::string::npos ) {
in_name.replace(pos , 6, " bool") ;
}
// NOTE: clang also changes FILE * to struct _SFILE *. We may need to change that too.
// Check to see if we've processed this template before
// If not we need to create attributes for this template
if ( processed_templates.find(in_name) == processed_templates.end() ) {
static std::string mangle_string( std::string in_name ) {
// convert characters not valid in a function name to underscores
std::string mangled_name = in_name ;
// Create a mangled type name, some characters have to converted to underscores.
@ -275,6 +247,22 @@ bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl *
std::replace( mangled_name.begin(), mangled_name.end(), ',', '_') ;
std::replace( mangled_name.begin(), mangled_name.end(), ':', '_') ;
std::replace( mangled_name.begin(), mangled_name.end(), '*', '_') ;
return mangled_name ;
}
std::map < std::string , std::string > FieldVisitor::processed_templates ;
bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl * crd ) {
// Save container namespaces and classes.
fdes->getNamespacesAndClasses(crd->getDeclContext()) ;
size_t pos ;
// Check to see if we've processed this template before
// If not we need to create attributes for this template
if ( processed_templates.find(in_name) == processed_templates.end() ) {
std::string mangled_name = mangle_string(in_name) ;
// save off the mangled name of this template to be used if another variable is the same template type
processed_templates[in_name] = fdes->getContainerClass() + "_" +
@ -305,6 +293,35 @@ bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl *
return false ;
}
static std::map<std::string, bool> init_stl_classes() {
std::map<std::string, bool> my_map ;
my_map.insert(std::pair<std::string, bool>("std::deque", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::list", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::map", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::multiset", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::multimap", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::pair", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::priority_queue", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::queue", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::set", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::stack", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::vector", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::deque", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::list", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::map", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::multiset", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::multimap", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::pair", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::priority_queue", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::queue", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::set", 1)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::stack", 0)) ;
my_map.insert(std::pair<std::string, bool>("std::__1::vector", 1)) ;
return my_map ;
}
static std::map<std::string, bool> stl_classes = init_stl_classes() ;
bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
if ( debug_level >= 3 ) {
std::cout << "FieldVisitor VisitRecordType" << std::endl ;
@ -320,12 +337,45 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
return false ;
}
std::string tst_string = rt->desugar().getAsString() ;
// remove class keyword if it exists
size_t pos ;
while ((pos = tst_string.find("class ")) != std::string::npos ) {
tst_string.erase(pos , 6) ;
}
while ((pos = tst_string.find("struct ")) != std::string::npos ) {
tst_string.erase(pos , 7) ;
}
// clang changes bool to _Bool. We need to change it back
if ((pos = tst_string.find("<_Bool")) != std::string::npos ) {
tst_string.replace(pos , 6, "<bool") ;
}
while ((pos = tst_string.find(" _Bool")) != std::string::npos ) {
tst_string.replace(pos , 6, " bool") ;
}
// NOTE: clang also changes FILE * to struct _SFILE *. We may need to change that too.
// Test if we have some type from std.
if (!tst_string.compare( 0 , 5 , "std::")) {
// If we have some type from std, figure out if it is one we support.
for ( std::map<std::string, bool>::iterator it = stl_classes.begin() ; it != stl_classes.end() ; it++ ) {
/* Mark STL types that are not strings and exit */
if (!tst_string.compare( 0 , (*it).first.size() , (*it).first)) {
fdes->setEnumString("TRICK_STL") ;
fdes->setSTL(true) ;
fdes->setTypeName(tst_string) ;
fdes->setSTLClear((*it).second) ;
fdes->setMangledTypeName(mangle_string(tst_string)) ;
return false ;
}
}
}
/* Template specialization types will be processed here because the canonical type
will be typed as a record. We test if we have a template specialization type.
If so process the template type and return */
clang::RecordDecl * rd = rt->getDecl()->getDefinition() ;
if ( rd != NULL and clang::ClassTemplateSpecializationDecl::classof(rd) ) {
std::string tst_string = rt->desugar().getAsString() ;
if ( debug_level >= 3 ) {
rd->dump() ;
std::cout << " tst_string = " << tst_string << std::endl ;

View File

@ -417,6 +417,7 @@ void PrintAttributes::printIOMakefile() {
std::cout << "Creating/updating io_src Makefile" << std::endl ;
makefile_io_src.open("build/Makefile_io_src") ;
makefile_io_src << "TRICK_SYSTEM_CXXFLAGS += -std=c++11" << std::endl ;
makefile_io_src << "TRICK_SYSTEM_CXXFLAGS += \\" << std::endl ;
makefile_io_src << " -Wno-invalid-offsetof \\" << std::endl ;
makefile_io_src << " -Wno-old-style-cast \\" << std::endl ;

View File

@ -45,6 +45,7 @@ void PrintFileContents10::printIOHeader(std::ofstream & outfile , std::string he
"#include \"trick/attributes.h\"\n"
"#include \"trick/parameter_types.h\"\n"
"#include \"trick/UnitsMap.hh\"\n\n"
"#include \"trick/checkpoint_stl.hh\"\n\n"
"#include \""
<< header_file_name <<
"\"\n\n" ;
@ -103,7 +104,9 @@ void PrintFileContents10::print_field_attr(std::ofstream & outfile , FieldDescr
if ( array_dim < 0 ) array_dim = 0 ;
outfile << ",{" << array_dim << ",0}" ; // indexes 1 through 7
}
outfile << "} }" ;
outfile << "}," << std::endl ;
outfile << " NULL, NULL, NULL, NULL" ;
outfile << "}" ;
}
/** Prints class attributes */
@ -186,7 +189,7 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ofstream & outfile ,
outfile << cv->getMangledTypeName() << "," << fdes->getName() << ") ;\n" ;
}
if ( !fdes->isRecord() and !fdes->isEnum() and !fdes->isBitField() ) {
if ( !fdes->isRecord() and !fdes->isEnum() and !fdes->isBitField() and !fdes->isSTL()) {
outfile << " attr" ;
printNamespaces( outfile, cv , "__" ) ;
printContainerClasses( outfile, cv , "__" ) ;
@ -196,6 +199,46 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ofstream & outfile ,
outfile << fdes->getTypeName() << ") ;\n" ;
}
if ( fdes->isSTL()) {
outfile << " attr" ;
printNamespaces( outfile, cv , "__" ) ;
printContainerClasses( outfile, cv , "__" ) ;
outfile << cv->getMangledTypeName() << "[i].checkpoint_stl = checkpoint_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << " ;\n" ;
outfile << " attr" ;
printNamespaces( outfile, cv , "__" ) ;
printContainerClasses( outfile, cv , "__" ) ;
outfile << cv->getMangledTypeName() << "[i].post_checkpoint_stl = post_checkpoint_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << " ;\n" ;
outfile << " attr" ;
printNamespaces( outfile, cv , "__" ) ;
printContainerClasses( outfile, cv , "__" ) ;
outfile << cv->getMangledTypeName() << "[i].restore_stl = restore_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << " ;\n" ;
if (fdes->hasSTLClear()) {
outfile << " attr" ;
printNamespaces( outfile, cv , "__" ) ;
printContainerClasses( outfile, cv , "__" ) ;
outfile << cv->getMangledTypeName() << "[i].clear_stl = clear_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << " ;\n" ;
}
}
if ( fdes->isRecord() or fdes->isEnum()) {
outfile << " next_attr = std::string(attr" ;
printNamespaces( outfile, cv , "__" ) ;
@ -425,8 +468,121 @@ void PrintFileContents10::print_io_src_delete( std::ofstream & outfile , ClassVa
}
}
void PrintFileContents10::print_stl_helper_proto(std::ofstream & outfile , ClassValues * cv ) {
unsigned int ii ;
ClassValues::FieldIterator fit ;
print_open_extern_c(outfile) ;
for ( fit = cv->field_begin() ; fit != cv->field_end() ; fit++ ) {
if ( (*fit)->isSTL() and determinePrintAttr(cv , *fit) ) {
outfile << "void checkpoint_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << (*fit)->getName() ;
outfile << "(void * start_address, const char * obj_name , const char * var_name) ;" << std::endl ;
outfile << "void post_checkpoint_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << (*fit)->getName() ;
outfile << "(void * start_address, const char * obj_name , const char * var_name) ;" << std::endl ;
outfile << "void restore_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << (*fit)->getName() ;
outfile << "(void * start_address, const char * obj_name , const char * var_name) ;" << std::endl ;
if ((*fit)->hasSTLClear()) {
outfile << "void clear_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << (*fit)->getName() ;
outfile << "(void * start_address) ;" << std::endl ;
}
}
}
print_close_extern_c(outfile) ;
}
void PrintFileContents10::print_checkpoint_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
outfile << "void checkpoint_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << "(void * start_address, const char * obj_name , const char * var_name) {" << std::endl ;
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
outfile << " " << "checkpoint_stl(*stl , obj_name , var_name) ;" << std::endl ;
outfile << "}" << std::endl ;
}
void PrintFileContents10::print_post_checkpoint_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
outfile << "void post_checkpoint_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << "(void * start_address, const char * obj_name , const char * var_name) {" << std::endl ;
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
outfile << " " << "delete_stl(*stl , obj_name , var_name) ;" << std::endl ;
outfile << "}" << std::endl ;
}
void PrintFileContents10::print_restore_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
outfile << "void restore_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << "(void * start_address, const char * obj_name , const char * var_name) {" << std::endl ;
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
outfile << " " << "restore_stl(*stl , obj_name , var_name) ;" << std::endl ;
outfile << "}" << std::endl ;
}
void PrintFileContents10::print_clear_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
outfile << "void clear_stl_" ;
outfile << cv->getMangledTypeName() ;
outfile << "_" ;
outfile << fdes->getName() ;
outfile << "(void * start_address) {" << std::endl ;
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
outfile << " " << "stl->clear() ;" << std::endl ;
outfile << "}" << std::endl ;
}
void PrintFileContents10::print_stl_helper(std::ofstream & outfile , ClassValues * cv ) {
unsigned int ii ;
ClassValues::FieldIterator fit ;
print_open_extern_c(outfile) ;
for ( fit = cv->field_begin() ; fit != cv->field_end() ; fit++ ) {
if ( (*fit)->isSTL() and determinePrintAttr(cv , *fit) ) {
print_checkpoint_stl(outfile , *fit, cv) ;
print_post_checkpoint_stl(outfile , *fit, cv) ;
print_restore_stl(outfile , *fit, cv) ;
if ((*fit)->hasSTLClear()) {
print_clear_stl(outfile , *fit, cv) ;
}
}
}
print_close_extern_c(outfile) ;
}
void PrintFileContents10::printClass( std::ofstream & outfile , ClassValues * cv ) {
print_stl_helper_proto(outfile, cv) ;
print_class_attr(outfile, cv) ;
print_stl_helper(outfile, cv) ;
print_init_attr_func(outfile, cv) ;
print_open_extern_c(outfile) ;
print_init_attr_c_intf(outfile, cv) ;

View File

@ -83,6 +83,24 @@ class PrintFileContents10 : public PrintFileContentsBase {
/** Prints the io_src_delete function */
void print_io_src_delete(std::ofstream & outfile , ClassValues * cv ) ;
/** Prints stl helper function prototypes */
void print_stl_helper_proto(std::ofstream & outfile , ClassValues * in_class) ;
/** Prints stl helper function */
void print_stl_helper(std::ofstream & outfile , ClassValues * in_class) ;
/** Prints stl checkpoint function */
void print_checkpoint_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * in_class) ;
/** Prints stl post_checkpoint function */
void print_post_checkpoint_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * in_class) ;
/** Prints stl restart function */
void print_restore_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * in_class) ;
/** Prints stl clear function */
void print_clear_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * in_class) ;
} ;
#endif

View File

@ -40,7 +40,8 @@ const int Trick::ClassicCheckPointAgent::array_elements_per_line[TRICK_NUMBER_OF
5, /** TRICK_VOID_PTR */
10, /** TRICK_ENUMERATED */
5, /** TRICK_STRUCTURED (for pointers) */
5 /** TRICK_OPAQUE_TYPE */
5, /** TRICK_OPAQUE_TYPE */
1 /** TRICK_STL */
};
// MEMBER FUNCTION
@ -489,6 +490,10 @@ int Trick::ClassicCheckPointAgent::is_nil_valued( void* address,
test_addr = (char*)address + offset * sizeof(void*);
if (*(std::string*)test_addr == "") return(1);
break;
case TRICK_STL :
// Can't test properly, always return 0 to indicate the STL is not empty.
return(0);
break;
default :
message_publish(MSG_ERROR, "Checkpoint Agent file %s: Unhandled Type (%d).\n", __FILE__, attr->type) ;
return(-1);
@ -1059,9 +1064,13 @@ void Trick::ClassicCheckPointAgent::assign_rvalue(std::ostream& chkpnt_os, void*
if (!input_perm_check(attr)) {
chkpnt_os << "/* OUTPUT-ONLY: ";
}
if ( attr->type == TRICK_STL ) {
chkpnt_os << "// STL: " << lname ;
} else {
chkpnt_os << lname << " = ";
write_rvalue( chkpnt_os, (void*)address, attr, curr_dim, offset);
chkpnt_os << ";";
}
if (!input_perm_check(attr)) {
chkpnt_os << "*/";
}

View File

@ -23,7 +23,6 @@
#include "trick/message_proto.h"
#include "trick/message_type.h"
#include "trick/TrickConstant.hh"
#include "trick/checkpoint_stl.hh"
Trick::CheckPointRestart * the_cpr ;
@ -397,24 +396,6 @@ int Trick::CheckPointRestart::safestore_checkpoint() {
return(0) ;
}
// These are jobs called from the S_define file. I called this one pre_checkpoint to avoid name overloading
int Trick::CheckPointRestart::pre_checkpoint() {
checkpoint_stl(checkpoint_times , std::string("trick_mm") , std::string("checkpoint_times")) ;
return 0 ;
}
int Trick::CheckPointRestart::post_checkpoint() {
if ( ! checkpoint_times.empty() ) {
delete_stl(checkpoint_times , std::string("trick_mm") , std::string("checkpoint_times")) ;
}
return 0 ;
}
int Trick::CheckPointRestart::restart() {
restore_stl(checkpoint_times , std::string("trick_mm") , std::string("checkpoint_times")) ;
return 0 ;
}
void Trick::CheckPointRestart::load_checkpoint(std::string file_name) {
load_checkpoint_file_name = file_name ;
}

View File

@ -16,46 +16,8 @@ object_${TRICK_HOST_CPU}/CheckPointRestart_c_intf.o: CheckPointRestart_c_intf.cp
${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h
object_${TRICK_HOST_CPU}/checkpoint_queue.o: checkpoint_queue.cpp \
${TRICK_HOME}/include/trick/checkpoint_queue.hh \
${TRICK_HOME}/include/trick/checkpoint_sequence_stl.hh \
${TRICK_HOME}/include/trick/memorymanager_c_intf.h \
${TRICK_HOME}/include/trick/parameter_types.h \
${TRICK_HOME}/include/trick/attributes.h \
${TRICK_HOME}/include/trick/reference.h \
${TRICK_HOME}/include/trick/value.h \
${TRICK_HOME}/include/trick/dllist.h \
${TRICK_HOME}/include/trick/var.h \
${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h
object_${TRICK_HOST_CPU}/checkpoint_map.o: checkpoint_map.cpp \
${TRICK_HOME}/include/trick/checkpoint_map.hh \
${TRICK_HOME}/include/trick/memorymanager_c_intf.h \
${TRICK_HOME}/include/trick/parameter_types.h \
${TRICK_HOME}/include/trick/attributes.h \
${TRICK_HOME}/include/trick/reference.h \
${TRICK_HOME}/include/trick/value.h \
${TRICK_HOME}/include/trick/dllist.h \
${TRICK_HOME}/include/trick/var.h \
${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h
object_${TRICK_HOST_CPU}/next_attr_name.o: next_attr_name.cpp \
${TRICK_HOME}/include/trick/CheckPointRestart_c_intf.hh
object_${TRICK_HOST_CPU}/checkpoint_stack.o: checkpoint_stack.cpp \
${TRICK_HOME}/include/trick/checkpoint_stack.hh \
${TRICK_HOME}/include/trick/checkpoint_sequence_stl.hh \
${TRICK_HOME}/include/trick/memorymanager_c_intf.h \
${TRICK_HOME}/include/trick/parameter_types.h \
${TRICK_HOME}/include/trick/attributes.h \
${TRICK_HOME}/include/trick/reference.h \
${TRICK_HOME}/include/trick/value.h \
${TRICK_HOME}/include/trick/dllist.h \
${TRICK_HOME}/include/trick/var.h \
${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h
object_${TRICK_HOST_CPU}/CheckPointRestart.o: CheckPointRestart.cpp \
${TRICK_HOME}/include/trick/DMTCP.hh \
${TRICK_HOME}/include/trick/dmtcp_checkpoint_c_intf.hh \
@ -77,47 +39,22 @@ object_${TRICK_HOST_CPU}/CheckPointRestart.o: CheckPointRestart.cpp \
${TRICK_HOME}/include/trick/CheckPointAgent.hh \
${TRICK_HOME}/include/trick/UCFn.hh \
${TRICK_HOME}/include/trick/Executive.hh \
${TRICK_HOME}/include/trick/Scheduler.hh \
${TRICK_HOME}/include/trick/ScheduledJobQueue.hh \
${TRICK_HOME}/include/trick/SimObject.hh \
${TRICK_HOME}/include/trick/Threads.hh \
${TRICK_HOME}/include/trick/ThreadBase.hh \
${TRICK_HOME}/include/trick/ThreadTrigger.hh \
${TRICK_HOME}/include/trick/sim_mode.h \
${TRICK_HOME}/include/trick/exec_proto.hh \
${TRICK_HOME}/include/trick/exec_proto.h \
${TRICK_HOME}/include/trick/sim_mode.h \
${TRICK_HOME}/include/trick/command_line_protos.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h \
${TRICK_HOME}/include/trick/TrickConstant.hh \
${TRICK_HOME}/include/trick/checkpoint_stl.hh \
${TRICK_HOME}/include/trick/checkpoint_sequence_stl.hh \
${TRICK_HOME}/include/trick/checkpoint_is_stl_container.hh \
${TRICK_HOME}/include/trick/checkpoint_fwd_declare.hh \
${TRICK_HOME}/include/trick/memorymanager_c_intf.h \
${TRICK_HOME}/include/trick/checkpoint_map.hh \
${TRICK_HOME}/include/trick/checkpoint_stack.hh \
${TRICK_HOME}/include/trick/checkpoint_queue.hh \
${TRICK_HOME}/include/trick/checkpoint_pair.hh
object_${TRICK_HOST_CPU}/checkpoint_pair.o: checkpoint_pair.cpp \
${TRICK_HOME}/include/trick/checkpoint_pair.hh \
${TRICK_HOME}/include/trick/memorymanager_c_intf.h \
${TRICK_HOME}/include/trick/parameter_types.h \
${TRICK_HOME}/include/trick/attributes.h \
${TRICK_HOME}/include/trick/reference.h \
${TRICK_HOME}/include/trick/value.h \
${TRICK_HOME}/include/trick/dllist.h \
${TRICK_HOME}/include/trick/var.h \
${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h
object_${TRICK_HOST_CPU}/checkpoint_sequence_stl.o: checkpoint_sequence_stl.cpp \
${TRICK_HOME}/include/trick/checkpoint_sequence_stl.hh \
${TRICK_HOME}/include/trick/memorymanager_c_intf.h \
${TRICK_HOME}/include/trick/parameter_types.h \
${TRICK_HOME}/include/trick/attributes.h \
${TRICK_HOME}/include/trick/reference.h \
${TRICK_HOME}/include/trick/value.h \
${TRICK_HOME}/include/trick/dllist.h \
${TRICK_HOME}/include/trick/var.h \
${TRICK_HOME}/include/trick/io_alloc.h \
${TRICK_HOME}/include/trick/message_proto.h \
${TRICK_HOME}/include/trick/message_type.h

View File

@ -1,22 +0,0 @@
#include <string>
#include <map>
#include "trick/checkpoint_map.hh"
int checkpoint_stl(std::map<std::string , std::string> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_strings( in_map , object_name , var_name ) ;
}
int checkpoint_stl(std::multimap<std::string , std::string> & in_map , std::string object_name , std::string var_name ) {
return checkpoint_map_stl_strings( in_map , object_name , var_name ) ;
}
int restore_stl(std::map<std::string , std::string> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl_strings( in_map , object_name , var_name ) ;
}
int restore_stl(std::multimap<std::string , std::string> & in_map , std::string object_name , std::string var_name ) {
return restore_map_stl_strings( in_map , object_name , var_name ) ;
}

View File

@ -1,51 +0,0 @@
#include <string>
#include <utility>
#include "trick/checkpoint_pair.hh"
int checkpoint_stl(std::pair<std::string, std::string> & in_stl , std::string object_name , std::string var_name ) {
char var_declare[128] ;
char ** first ;
char ** second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
sprintf(var_declare, "char * %s_%s_first[1]", object_name.c_str(), var_name.c_str()) ;
first = (char **)TMM_declare_var_s(var_declare) ;
sprintf(var_declare, "char * %s_%s_second[1]" , object_name.c_str(), var_name.c_str()) ;
second = (char **)TMM_declare_var_s(var_declare) ;
first[0] = (char *)(in_stl.first.c_str()) ;
second[0] = (char *)(in_stl.second.c_str()) ;
return 0 ;
}
int restore_stl(std::pair<std::string, std::string> & in_stl , std::string object_name , std::string var_name ) {
REF2 * first_ref ;
REF2 * second_ref ;
char ** first ;
char ** second ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<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 + std::string("_") + var_name + std::string("_first")).c_str()) ;
second_ref = ref_attributes((char *)(object_name + std::string("_") + var_name + std::string("_second")).c_str()) ;
if ( first_ref != NULL && second_ref != NULL ) {
first = (char **)first_ref->address ;
second = (char **)second_ref->address ;
in_stl.first = std::string(first[0]) ;
in_stl.second = std::string(second[0]) ;
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}

View File

@ -1,74 +0,0 @@
#include "trick/checkpoint_queue.hh"
int checkpoint_stl(std::queue<std::string> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
int status ;
char ** items = NULL ;
std::queue<std::string> temp_queue ;
cont_size = in_stl.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_queue = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = (char *)((temp_queue.front()).c_str()) ;
temp_queue.pop() ;
}
}
return 0 ;
}
int checkpoint_stl(std::priority_queue<std::string> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
int status ;
char ** items = NULL ;
std::priority_queue<std::string> temp_queue ;
cont_size = in_stl.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_queue = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = (char *)((temp_queue.top()).c_str()) ;
temp_queue.pop() ;
}
}
return 0 ;
}
int restore_stl(std::queue<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_queue_stl_string(in_stl , object_name , var_name) ;
}
int restore_stl(std::priority_queue<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_queue_stl_string(in_stl , object_name , var_name) ;
}

View File

@ -1,43 +0,0 @@
#include "trick/checkpoint_sequence_stl.hh"
int checkpoint_stl(std::vector<std::string> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int checkpoint_stl(std::list<std::string> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int checkpoint_stl(std::deque<std::string> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int checkpoint_stl(std::set<std::string> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int checkpoint_stl(std::multiset<std::string> & in_stl , std::string object_name , std::string var_name ) {
return checkpoint_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int restore_stl(std::vector<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int restore_stl(std::list<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int restore_stl(std::deque<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int restore_stl(std::set<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl_string( in_stl , object_name , var_name ) ;
}
int restore_stl(std::multiset<std::string> & in_stl , std::string object_name , std::string var_name ) {
return restore_sequence_stl_string( in_stl , object_name , var_name ) ;
}

View File

@ -1,65 +0,0 @@
#include "trick/checkpoint_stack.hh"
int checkpoint_stl(std::stack<std::string> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
char var_declare[128] ;
int status ;
char ** items = NULL ;
std::stack<std::string> temp_stack ;
cont_size = in_stl.size() ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
if ( cont_size > 0 ) {
sprintf(var_declare, "%s %s_%s[%d]" ,
abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ), object_name.c_str(), var_name.c_str(), cont_size) ;
items = (char **)TMM_declare_var_s(var_declare) ;
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
temp_stack = in_stl ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
items[ii] = (char *)((temp_stack.top()).c_str()) ;
temp_stack.pop() ;
}
}
return 0 ;
}
int restore_stl(std::stack<std::string> & in_stl , std::string object_name , std::string var_name ) {
unsigned int ii ;
unsigned int cont_size ;
REF2 * items_ref ;
char ** items ;
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
//message_publish(1, "RESTORE_STL_STACK %s_%s\n", object_name.c_str() , var_name.c_str()) ;
cont_size = in_stl.size() ;
for ( ii = 0 ; ii < cont_size ; ii++ ) {
in_stl.pop() ;
}
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
if ( items_ref != NULL ) {
items = (char **)items_ref->address ;
cont_size = get_size((char *)items) ;
for ( ii = cont_size - 1 ; ii < cont_size ; ii-- ) {
in_stl.push( items[ii] ) ;
}
delete_stl( in_stl , object_name , var_name ) ;
}
return 0 ;
}

View File

@ -0,0 +1,11 @@
#include <string>
std::string stl_type_name_convert(std::string in_type) {
std::string type_string(in_type) ;
std::string basic_string("std::__1::basic_string") ;
if ( !type_string.compare(0, basic_string.length(), basic_string)) {
type_string = "std::string" ;
}
return type_string ;
}

View File

@ -64,8 +64,6 @@ Trick::Executive::Executive() {
num_all_jobs = 0 ;
all_jobs_for_checkpoint = NULL ;
num_sim_objects_in_checkpoint = 0 ;
sim_objects_for_checkpoint = NULL ;
software_frame_tics = (long long)(software_frame * time_tic_value) ;
next_frame_check_tics = software_frame_tics ;

View File

@ -4,19 +4,20 @@
#include "trick/Executive.hh"
#include "trick/exec_proto.h"
#include "trick/memorymanager_c_intf.h"
#include "trick/checkpoint_stl.hh"
/**
@details
-# Save the number of jobs in the scheduler
-# Copy all of the job information in a checkpointable array
-# Save the number of sim_objects in the scheduler
-# Copy all of the sim_objects in a checkpointable array
*/
int Trick::Executive::checkpoint() {
unsigned int ii ;
/*
The all_jobs_vector contains memory that is not known to the memory manager. We need to
copy the information into memory that is declared to the memory manager.
*/
/* save the number of jobs in the scheduler */
num_all_jobs = all_jobs_vector.size() ;
@ -29,9 +30,6 @@ int Trick::Executive::checkpoint() {
}
}
checkpoint_stl(sim_objects , std::string("trick_sys") , std::string("sim_objects")) ;
checkpoint_stl(freeze_times , std::string("trick_sys") , std::string("freeze_times")) ;
return(0) ;
}

View File

@ -68,7 +68,7 @@ int Trick::Executive::init() {
} else {
except_file = "somewhere in Executive::init" ;
}
fprintf(stderr, "\nExecutive::loop terminated with std::exception\n ROUTINE: %s\n DIAGNOSTIC: %s\n",
fprintf(stderr, "\nExecutive::init terminated with std::exception\n ROUTINE: %s\n DIAGNOSTIC: %s\n",
except_file.c_str(), ex.what()) ;
exit(-1) ;
} catch (...) {
@ -78,7 +78,7 @@ int Trick::Executive::init() {
except_file = "somewhere in Executive::init" ;
}
except_message = "unknown error" ;
fprintf(stderr, "\nExecutive::loop terminated with unknown exception\n ROUTINE: %s\n DIAGNOSTIC: %s\n",
fprintf(stderr, "\nExecutive::init terminated with unknown exception\n ROUTINE: %s\n DIAGNOSTIC: %s\n",
except_file.c_str() , except_message.c_str()) ;
exit(-1) ;
}

View File

@ -4,19 +4,11 @@
#include "trick/Executive.hh"
#include "trick/exec_proto.h"
#include "trick/memorymanager_c_intf.h"
#include "trick/checkpoint_stl.hh"
int Trick::Executive::post_checkpoint() {
TMM_delete_var_a(all_jobs_for_checkpoint) ;
all_jobs_for_checkpoint = NULL ;
delete_stl(sim_objects , std::string("trick_sys") , std::string("sim_objects")) ;
if ( ! freeze_times.empty() ) {
delete_stl(freeze_times , std::string("trick_sys") , std::string("freeze_times")) ;
}
return(0) ;
}

View File

@ -7,7 +7,6 @@
#include "trick/message_proto.h"
#include "trick/message_type.h"
#include "trick/memorymanager_c_intf.h"
#include "trick/checkpoint_stl.hh"
#include "trick/ScheduledJobQueue.hh"
#include "trick/Threads.hh"
@ -44,13 +43,6 @@ int Trick::Executive::restart() {
all_jobs_vector.clear() ;
all_tagged_jobs.clear() ;
/* clear all sim_object information in scheduler */
num_sim_objects = 0 ;
sim_objects.clear() ;
/* restore the list of sim_objects from the checkpoint. */
restore_stl(sim_objects , std::string("trick_sys") , std::string("sim_objects")) ;
/* Create a temporary all_jobs map to use to restore job data from all_jobs_for_checkpoint */
for ( sit = sim_objects.begin() ; sit != sim_objects.end() ; sit++ ) {
for ( jit = (*sit)->jobs.begin() ; jit != (*sit)->jobs.end() ; jit++ ) {
@ -107,9 +99,6 @@ int Trick::Executive::restart() {
TMM_delete_var_a(all_jobs_for_checkpoint) ;
all_jobs_for_checkpoint = NULL ;
// restore the vector of freeze times
restore_stl(freeze_times , std::string("trick_sys") , std::string("freeze_times")) ;
/* Set the main thread current time to the simulation time tics value, used with Executive::get_sim_time() */
threads[0]->curr_time_tics = time_tics ;

View File

@ -1,7 +1,6 @@
#include "trick/IntegLoopSimObject.hh"
#include "trick/exec_proto.hh"
#include "trick/checkpoint_stl.hh"
void IntegLoopSimObject::add_jobs(double in_cycle, unsigned int child) {
Trick::JobData * job ;
@ -15,14 +14,11 @@ void IntegLoopSimObject::add_jobs(double in_cycle, unsigned int child) {
job->add_tag("TRK") ;
job = add_job(child, 3, "integ_loop", NULL, in_cycle, "integ_sched.integrate", "", 60000) ;
job->add_tag("TRK") ;
job = add_job(0, 4, "checkpoint", NULL, 1, "checkpoint_stl", "", 60000) ;
job = add_job(0, 5, "post_checkpoint", NULL, 1, "delete_stl", "", 60000) ;
job = add_job(0, 6, "restart", NULL, 1, "restore_stl", "", 60000) ;
job = add_job(0, 7, "preload_checkpoint", NULL, 1, "integ_sched.restart_checkpoint", "", 0) ;
job = add_job(0, 4, "preload_checkpoint", NULL, 1, "integ_sched.restart_checkpoint", "", 0) ;
job->add_tag("TRK") ;
job = add_job(0, 8, "restart", NULL, 1, "integ_sched.rebuild_jobs", "", 60000) ;
job = add_job(0, 5, "restart", NULL, 1, "integ_sched.rebuild_jobs", "", 60000) ;
job->add_tag("TRK") ;
job = add_job(0, 9, "restart", NULL, 1, "integ_sched.get_first_step_deriv_from_integrator", "", 65535) ;
job = add_job(0, 6, "restart", NULL, 1, "integ_sched.get_first_step_deriv_from_integrator", "", 65535) ;
job->add_tag("TRK") ;
}
@ -45,21 +41,12 @@ int IntegLoopSimObject::call_function ( Trick::JobData * curr_job ) {
integ_sched.integrate() ;
break ;
case 4:
checkpoint_stl(integ_sched.sim_objects, name + std::string("_") + std::string("integ_sched.sim_objects"), std::string("")) ;
break ;
case 5:
delete_stl (integ_sched.sim_objects, name + std::string("_") + std::string("integ_sched.sim_objects"), std::string("")) ;
break ;
case 6:
restore_stl (integ_sched.sim_objects, name + std::string("_") + std::string("integ_sched.sim_objects"), std::string("")) ;
break ;
case 7:
integ_sched.restart_checkpoint() ;
break ;
case 8:
case 5:
integ_sched.rebuild_jobs() ;
break ;
case 9:
case 6:
integ_sched.get_first_step_deriv_from_integrator() ;
break ;
default:

View File

@ -574,3 +574,11 @@ extern "C" int get_enumerated(const char* name, V_DATA* v_data) {
return 1 ;
}
}
extern "C" void TMM_add_checkpoint_alloc_dependency(const char * name) {
if (trick_MM != NULL) {
trick_MM->add_checkpoint_alloc_dependency(name) ;
}
return ;
}

View File

@ -0,0 +1,11 @@
#include "trick/MemoryManager.hh"
// MEMBER FUNCTION:
void Trick::MemoryManager::add_checkpoint_alloc_dependency(const char *name) {
VARIABLE_MAP_ITER it = variable_map.find(name) ;
if ( it != variable_map.end() ) {
dependencies.push_back(it->second) ;
stl_dependencies.push_back(it->second) ;
}
}

View File

@ -2,7 +2,7 @@
#include "trick/attributes.h"
// MEMBER FUNCTION
void Trick::MemoryManager::get_alloc_deps_in_allocation(std::vector<ALLOC_INFO*>& dependencies, ALLOC_INFO* alloc_info ) {
void Trick::MemoryManager::get_alloc_deps_in_allocation(ALLOC_INFO* alloc_info ) {
ATTRIBUTES* reference_attr;
@ -58,12 +58,12 @@ void Trick::MemoryManager::get_alloc_deps_in_allocation(std::vector<ALLOC_INFO*>
// Get the dependencies of the allocation
if (alloc_info->type == TRICK_STRUCTURED) {
if (reference_attr->num_index > 0) {
get_alloc_deps_in_arrayed_class( dependencies, (char*)(alloc_info->start), reference_attr, 0, 0) ;
get_alloc_deps_in_arrayed_class( (char*)(alloc_info->start), reference_attr, 0, 0) ;
} else {
get_alloc_deps_in_class( dependencies, (char*)(alloc_info->start), alloc_info->attr) ;
get_alloc_deps_in_class( (char*)(alloc_info->start), alloc_info->attr) ;
}
} else {
get_alloc_deps_in_intrinsic( dependencies, alloc_info->start, reference_attr, 0, 0 );
get_alloc_deps_in_intrinsic( alloc_info->start, reference_attr, 0, 0 );
}
if (debug_level) {
@ -76,7 +76,7 @@ void Trick::MemoryManager::get_alloc_deps_in_allocation(std::vector<ALLOC_INFO*>
}
// MEMBER FUNCTION
void Trick::MemoryManager::get_alloc_deps_in_allocation( std::vector<ALLOC_INFO*>& dependencies, const char* var_name ) {
void Trick::MemoryManager::get_alloc_deps_in_allocation( const char* var_name ) {
VARIABLE_MAP::iterator pos;
ALLOC_INFO *alloc_info;
@ -89,7 +89,7 @@ void Trick::MemoryManager::get_alloc_deps_in_allocation( std::vector<ALLOC_INFO*
if (pos != variable_map.end()) {
alloc_info = pos->second;
get_alloc_deps_in_allocation( dependencies, alloc_info );
get_alloc_deps_in_allocation( alloc_info );
} else {
std::cerr << "ERROR: get_alloc_deps_in_allocation(\""<< var_name
<<"\") failed because the given name is'nt known by the MemoryManager."
@ -100,7 +100,7 @@ void Trick::MemoryManager::get_alloc_deps_in_allocation( std::vector<ALLOC_INFO*
// MEMBER FUNCTION
void Trick::MemoryManager::get_alloc_deps_in_class( std::vector<ALLOC_INFO*>& dependencies, char* address, ATTRIBUTES* attr) {
void Trick::MemoryManager::get_alloc_deps_in_class( char* address, ATTRIBUTES* attr) {
int ii;
if (debug_level > 1) {
@ -123,19 +123,19 @@ void Trick::MemoryManager::get_alloc_deps_in_class( std::vector<ALLOC_INFO*>& de
if (attr[ii].type == TRICK_STRUCTURED) {
if (attr[ii].num_index != 0) {
get_alloc_deps_in_arrayed_class( dependencies, elem_addr, &attr[ii], 0, 0);
get_alloc_deps_in_arrayed_class( elem_addr, &attr[ii], 0, 0);
} else {
get_alloc_deps_in_class( dependencies, elem_addr, (ATTRIBUTES*)(attr[ii].attr));
get_alloc_deps_in_class( elem_addr, (ATTRIBUTES*)(attr[ii].attr));
}
} else {
get_alloc_deps_in_intrinsic( dependencies, elem_addr, &(attr[ii]), 0, 0);
get_alloc_deps_in_intrinsic( elem_addr, &(attr[ii]), 0, 0);
}
}
}
}
// MEMBER FUNCTION
void Trick::MemoryManager::get_alloc_deps_in_arrayed_class( std::vector<ALLOC_INFO*>& dependencies,
void Trick::MemoryManager::get_alloc_deps_in_arrayed_class(
char* address,
ATTRIBUTES* attr,
int curr_dim,
@ -163,7 +163,7 @@ void Trick::MemoryManager::get_alloc_deps_in_arrayed_class( std::vector<ALLOC_IN
if (debug_level) {
std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
}
get_alloc_deps_in_allocation(dependencies, alloc_info);
get_alloc_deps_in_allocation(alloc_info);
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
@ -182,11 +182,11 @@ void Trick::MemoryManager::get_alloc_deps_in_arrayed_class( std::vector<ALLOC_IN
curr_dim_size = attr->index[curr_dim].size;
for (ii = 0; ii < curr_dim_size; ii++) {
if (curr_dim < attr->num_index - 1) {
get_alloc_deps_in_arrayed_class( dependencies, address, attr, curr_dim + 1, offset * curr_dim_size + ii);
get_alloc_deps_in_arrayed_class( address, attr, curr_dim + 1, offset * curr_dim_size + ii);
} else {
char* elem_addr;
elem_addr = address + (offset * curr_dim + ii) * attr->size ;
get_alloc_deps_in_class( dependencies, elem_addr, (ATTRIBUTES*)attr->attr );
get_alloc_deps_in_class( elem_addr, (ATTRIBUTES*)attr->attr );
}
}
}
@ -194,7 +194,7 @@ void Trick::MemoryManager::get_alloc_deps_in_arrayed_class( std::vector<ALLOC_IN
// MEMBER FUNCTION
void Trick::MemoryManager::get_alloc_deps_in_intrinsic( std::vector<ALLOC_INFO*>& dependencies, void* address, ATTRIBUTES* attr, int curr_dim, int offset) {
void Trick::MemoryManager::get_alloc_deps_in_intrinsic( void* address, ATTRIBUTES* attr, int curr_dim, int offset) {
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
@ -215,7 +215,7 @@ void Trick::MemoryManager::get_alloc_deps_in_intrinsic( std::vector<ALLOC_INFO*>
if (debug_level) {
std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
}
get_alloc_deps_in_allocation(dependencies, alloc_info);
get_alloc_deps_in_allocation(alloc_info);
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
@ -232,7 +232,7 @@ void Trick::MemoryManager::get_alloc_deps_in_intrinsic( std::vector<ALLOC_INFO*>
} else { // otherwise its a constrained array.
int ii;
for (ii=0 ; ii< attr->index[curr_dim].size ; ii++) {
get_alloc_deps_in_intrinsic( dependencies, address, attr, curr_dim + 1, offset * attr->index[curr_dim].size + ii);
get_alloc_deps_in_intrinsic( address, attr, curr_dim + 1, offset * attr->index[curr_dim].size + ii);
}
}
}

View File

@ -95,6 +95,12 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
final_address = (char*)base_address + offset * sizeof(void*);
*(std::string*)final_address = "";
break;
case TRICK_STL :
final_address = (char*)base_address + offset * attr->size ;
if ( attr->clear_stl ) {
(*attr->clear_stl)(final_address) ;
}
break;
default :
std::stringstream message;
message << "Unhandled Type (" << (int)attr->type << ").";

View File

@ -0,0 +1,192 @@
#include <algorithm>
#include "trick/MemoryManager.hh"
#include "trick/attributes.h"
// MEMBER FUNCTION
void Trick::MemoryManager::get_stl_dependencies( ALLOC_INFO* alloc_info ) {
ATTRIBUTES* reference_attr;
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
if (alloc_info == NULL) {
std::cout << "ERROR: Trick::MemoryManager::get_stl_dependencies called with alloc_info == NULL." << std::endl;
std::cout.flush();
return;
}
if (debug_level) {
std::cout << __FUNCTION__ << ": Begin scan of allocation @" << (void*)alloc_info->start << " for dependencies." << std::endl;
}
reference_attr = make_reference_attr( alloc_info );
// Get the dependencies of the allocation
if (alloc_info->type == TRICK_STRUCTURED) {
if (reference_attr->num_index > 0) {
get_stl_dependencies_in_arrayed_class(alloc_info->name, (char*)(alloc_info->start), reference_attr, 0, 0) ;
} else {
get_stl_dependencies_in_class(alloc_info->name, (char*)(alloc_info->start), alloc_info->attr) ;
}
} else {
get_stl_dependencies_in_intrinsic(alloc_info->name, alloc_info->start, reference_attr, 0, 0 );
}
if (debug_level) {
std::cout << __FUNCTION__ << ": End scan of allocation @" << (void*)alloc_info->start << "." << std::endl;
}
free_reference_attr( reference_attr );
}
// MEMBER FUNCTION
void Trick::MemoryManager::get_stl_dependencies_in_class( std::string name, char* address, ATTRIBUTES* attr) {
int ii;
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
if (attr == NULL) {
std::cerr << "ERROR: Trick::MemoryManager::get_stl_dependencies_in_class called with attr = NULL." << std::endl;
return;
}
for (ii = 0; attr[ii].name[0] != '\0'; ii++) {
if (currentCheckPointAgent->output_perm_check(&attr[ii])) {
char *elem_addr;
if (attr[ii].mods & 2) {
elem_addr = (char *) attr[ii].offset;
} else {
elem_addr = address + attr[ii].offset;
}
if (attr[ii].type == TRICK_STRUCTURED) {
if (attr[ii].num_index != 0) {
get_stl_dependencies_in_arrayed_class( name + "." + attr[ii].name, elem_addr, &attr[ii], 0, 0);
} else {
get_stl_dependencies_in_class( name + "." + attr[ii].name, elem_addr, (ATTRIBUTES*)(attr[ii].attr));
}
} else if (attr[ii].type == TRICK_STL) {
(*attr[ii].checkpoint_stl)(elem_addr, name.c_str(), attr[ii].name) ;
} else {
get_stl_dependencies_in_intrinsic( name + "." + attr[ii].name , elem_addr, &(attr[ii]), 0, 0);
}
}
}
}
// MEMBER FUNCTION
void Trick::MemoryManager::get_stl_dependencies_in_arrayed_class(
std::string name,
char* address,
ATTRIBUTES* attr,
int curr_dim,
int offset) {
int ii;
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
if (attr == NULL) {
std::cerr << "Trick::MemoryManager::get_stl_dependencies_in_arrayed_class: ERROR: attr = NULL." << std::endl;
return;
}
if (attr->index[curr_dim].size == 0) {
void* pointer = *(void**)((char*)address + offset * sizeof(void*));
if (pointer != NULL) {
ALLOC_INFO *alloc_info;
alloc_info = get_alloc_info_of( pointer);
if (alloc_info != NULL) {
if (debug_level) {
std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
}
//get_stl_dependencies(alloc_info);
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
std::cout.flush();
}
}
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Allocation reference is NULL." << std::endl;
std::cout.flush();
}
}
} else {
int curr_dim_size;
curr_dim_size = attr->index[curr_dim].size;
for (ii = 0; ii < curr_dim_size; ii++) {
char index[16] ;
sprintf(index, "[%d]", ii) ;
if (curr_dim < attr->num_index - 1) {
get_stl_dependencies_in_arrayed_class( name + index, address, attr, curr_dim + 1, offset * curr_dim_size + ii);
} else {
char* elem_addr;
elem_addr = address + (offset * curr_dim + ii) * attr->size ;
get_stl_dependencies_in_class( name + index, elem_addr, (ATTRIBUTES*)attr->attr );
}
}
}
}
// MEMBER FUNCTION
void Trick::MemoryManager::get_stl_dependencies_in_intrinsic( std::string name , void* address, ATTRIBUTES* attr, int curr_dim, int offset) {
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
// If the variable that we are pointing to is an arrayed
if (curr_dim < attr->num_index) {
// If it is an unconstrained array (a pointer)
if (attr->index[curr_dim].size == 0) {
void* pointer = *(void**)((char*)address + offset * sizeof(void*));
if (pointer != NULL) {
ALLOC_INFO *alloc_info;
alloc_info = get_alloc_info_of( pointer);
if (alloc_info != NULL) {
if (debug_level) {
std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
}
//get_stl_dependencies(alloc_info);
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
std::cout.flush();
}
}
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Allocation reference is NULL." << std::endl;
std::cout.flush();
}
}
} else { // otherwise its a constrained array.
int ii;
for (ii=0 ; ii< attr->index[curr_dim].size ; ii++) {
char index[16] ;
sprintf(index, "[%d]", ii) ;
//get_stl_dependencies_in_intrinsic( name + index , address, attr, curr_dim + 1, offset * attr->index[curr_dim].size + ii);
}
}
}
}

View File

@ -20,14 +20,19 @@ int Trick::MemoryManager::read_checkpoint( std::istream *is) {
emitError("Checkpoint restore failed.") ;
}
// Search for stls and restore them
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
// for those whose names start with the temporary-variable prefix and:
pthread_mutex_lock(&mm_mutex);
for ( pos=alloc_info_map.begin() ; pos!=alloc_info_map.end() ; pos++ ) {
alloc_info = pos->second;
if ( alloc_info->stcl == TRICK_LOCAL) {
// If the temporary-variable prefix occurs at the beginning of the name ...

View File

@ -0,0 +1,197 @@
#include <algorithm>
#include "trick/MemoryManager.hh"
#include "trick/attributes.h"
// MEMBER FUNCTION
void Trick::MemoryManager::restore_stls( ALLOC_INFO* alloc_info ) {
ATTRIBUTES* reference_attr;
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
if (alloc_info == NULL) {
std::cout << "ERROR: Trick::MemoryManager::restore_stls called with alloc_info == NULL." << std::endl;
std::cout.flush();
return;
}
// If there is no name associated with this alloc_info, we won't be able to find any stls associated with it.
if (alloc_info->name == NULL) {
return;
}
if (debug_level) {
std::cout << __FUNCTION__ << ": Begin scan of allocation @" << (void*)alloc_info->start << " for dependencies." << std::endl;
}
reference_attr = make_reference_attr( alloc_info );
// Get the dependencies of the allocation
if (alloc_info->type == TRICK_STRUCTURED) {
if (reference_attr->num_index > 0) {
restore_stls_in_arrayed_class(alloc_info->name, (char*)(alloc_info->start), reference_attr, 0, 0) ;
} else {
restore_stls_in_class(alloc_info->name, (char*)(alloc_info->start), alloc_info->attr) ;
}
} else {
restore_stls_in_intrinsic(alloc_info->name, alloc_info->start, reference_attr, 0, 0 );
}
if (debug_level) {
std::cout << __FUNCTION__ << ": End scan of allocation @" << (void*)alloc_info->start << "." << std::endl;
}
free_reference_attr( reference_attr );
}
// MEMBER FUNCTION
void Trick::MemoryManager::restore_stls_in_class( std::string name, char* address, ATTRIBUTES* attr) {
int ii;
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
if (attr == NULL) {
std::cerr << "ERROR: Trick::MemoryManager::restore_stls called with attr = NULL." << std::endl;
return;
}
for (ii = 0; attr[ii].name[0] != '\0'; ii++) {
if (currentCheckPointAgent->input_perm_check(&attr[ii])) {
char *elem_addr;
if (attr[ii].mods & 2) {
elem_addr = (char *) attr[ii].offset;
} else {
elem_addr = address + attr[ii].offset;
}
if (attr[ii].type == TRICK_STRUCTURED) {
if (attr[ii].num_index != 0) {
restore_stls_in_arrayed_class( name + "." + attr[ii].name, elem_addr, &attr[ii], 0, 0);
} else {
restore_stls_in_class( name + "." + attr[ii].name, elem_addr, (ATTRIBUTES*)(attr[ii].attr));
}
} else if (attr[ii].type == TRICK_STL) {
(*attr[ii].restore_stl)(elem_addr, name.c_str(), attr[ii].name) ;
} else {
restore_stls_in_intrinsic( name + "." + attr[ii].name , elem_addr, &(attr[ii]), 0, 0);
}
}
}
}
// MEMBER FUNCTION
void Trick::MemoryManager::restore_stls_in_arrayed_class(
std::string name,
char* address,
ATTRIBUTES* attr,
int curr_dim,
int offset) {
int ii;
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
if (attr == NULL) {
std::cerr << "Trick::MemoryManager::restore_stls_in_arrayed_class: ERROR: attr = NULL." << std::endl;
return;
}
if (attr->index[curr_dim].size == 0) {
void* pointer = *(void**)((char*)address + offset * sizeof(void*));
if (pointer != NULL) {
ALLOC_INFO *alloc_info;
alloc_info = get_alloc_info_of( pointer);
if (alloc_info != NULL) {
if (debug_level) {
std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
}
//restore_stls(alloc_info);
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
std::cout.flush();
}
}
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Allocation reference is NULL." << std::endl;
std::cout.flush();
}
}
} else {
int curr_dim_size;
curr_dim_size = attr->index[curr_dim].size;
for (ii = 0; ii < curr_dim_size; ii++) {
char index[16] ;
sprintf(index, "[%d]", ii) ;
if (curr_dim < attr->num_index - 1) {
restore_stls_in_arrayed_class( name + index, address, attr, curr_dim + 1, offset * curr_dim_size + ii);
} else {
char* elem_addr;
elem_addr = address + (offset * curr_dim + ii) * attr->size ;
restore_stls_in_class( name + index, elem_addr, (ATTRIBUTES*)attr->attr );
}
}
}
}
// MEMBER FUNCTION
void Trick::MemoryManager::restore_stls_in_intrinsic( std::string name , void* address, ATTRIBUTES* attr, int curr_dim, int offset) {
if (debug_level > 1) {
std::cout << "DEBUG: Entered function:" << __FUNCTION__ << std::endl;
}
// If the variable that we are pointing to is an arrayed
if (curr_dim < attr->num_index) {
// If it is an unconstrained array (a pointer)
if (attr->index[curr_dim].size == 0) {
void* pointer = *(void**)((char*)address + offset * sizeof(void*));
if (pointer != NULL) {
ALLOC_INFO *alloc_info;
alloc_info = get_alloc_info_of( pointer);
if (alloc_info != NULL) {
if (debug_level) {
std::cout << __FUNCTION__ << ": @" << (void*)address << "." << attr->name << "[" << offset << "] points to @" << (void*)pointer << std::endl;
}
//restore_stls(alloc_info);
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Pointer ("<< (void*)pointer <<") refers to memory that the MemoryManager doesn't know about." << std::endl;
std::cout.flush();
}
}
} else {
if (debug_level) {
std::cout << __FUNCTION__ << ": Allocation reference is NULL." << std::endl;
std::cout.flush();
}
}
} else { // otherwise its a constrained array.
int ii;
for (ii=0 ; ii< attr->index[curr_dim].size ; ii++) {
char index[16] ;
sprintf(index, "[%d]", ii) ;
//restore_stls_in_intrinsic( name + index , address, attr, curr_dim + 1, offset * attr->index[curr_dim].size + ii);
}
}
}
}

View File

@ -11,7 +11,7 @@
#endif
// MEMBER FUNCTION
void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<ALLOC_INFO*>& dependencies) {
void Trick::MemoryManager::execute_checkpoint( std::ostream& out_s ) {
ALLOC_INFO_MAP::iterator pos;
ALLOC_INFO* alloc_info;
@ -26,16 +26,17 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<AL
local_anon_var_number = 0;
extern_anon_var_number = 0;
// Give names to the anonymous declarations
// Also search each allocation for STLs.
// STLs will be added to the dependencies vector.
int n_depends = dependencies.size();
for (int ii = 0 ; ii < n_depends ; ii ++) {
alloc_info = dependencies[ii];
/** Generate temporary names for anonymous variables. */
if (alloc_info->name == NULL) {
if ( alloc_info->stcl == TRICK_LOCAL) {
sprintf( name, "%s%d", local_anon_var_prefix, local_anon_var_number++);
alloc_info->name = strdup( name);
currentCheckPointAgent->write_decl( out_s, alloc_info);
} else if (alloc_info->stcl == TRICK_EXTERN) {
sprintf( name, "%s%d", extern_anon_var_prefix, extern_anon_var_number++);
alloc_info->name = strdup( name);
@ -44,7 +45,15 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<AL
} else {
emitError("write_checkpoint: This is bad. ALLOC_INFO object is messed up.\n") ;
}
} else {
}
get_stl_dependencies(alloc_info);
}
// Write a declaration statement for all of the LOCAL variables,
n_depends = dependencies.size();
for (int ii = 0 ; ii < n_depends ; ii ++) {
alloc_info = dependencies[ii];
if ( alloc_info->stcl == TRICK_LOCAL) {
currentCheckPointAgent->write_decl( out_s, alloc_info);
}
}
@ -77,6 +86,12 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<AL
alloc_info->name = NULL;
}
}
// Delete the variables created by STLs. Remove memory in reverse order.
std::vector<ALLOC_INFO*>::reverse_iterator it ;
for ( it = stl_dependencies.rbegin() ; it != stl_dependencies.rend() ; it++ ) {
delete_var((*it)->start) ;
}
}
// Local sort function used in write_checkpoint.
@ -87,7 +102,8 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s) {
ALLOC_INFO_MAP::iterator pos;
ALLOC_INFO* alloc_info;
std::vector<ALLOC_INFO*> dependencies;
dependencies.clear();
stl_dependencies.clear();
pthread_mutex_lock(&mm_mutex);
for ( pos=alloc_info_map.begin() ; pos!=alloc_info_map.end() ; pos++ ) {
@ -98,7 +114,8 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s) {
// Sort the dependencies by ALLOC_INFO.id.
std::sort( dependencies.begin() , dependencies.end() , alloc_info_id_compare) ;
pthread_mutex_unlock(&mm_mutex);
write_checkpoint( out_s, dependencies);
execute_checkpoint( out_s );
}
@ -119,21 +136,20 @@ void Trick::MemoryManager::write_checkpoint(const char* filename) {
// MEMBER FUNCTION
void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, const char* var_name) {
std::vector<ALLOC_INFO*> dependencies;
dependencies.clear();
stl_dependencies.clear();
pthread_mutex_lock(&mm_mutex);
get_alloc_deps_in_allocation( dependencies, var_name);
get_alloc_deps_in_allocation( var_name);
pthread_mutex_unlock(&mm_mutex);
write_checkpoint( out_s, dependencies);
execute_checkpoint( out_s );
}
// MEMBER FUNCTION
void Trick::MemoryManager::write_checkpoint(const char* filename, const char* var_name) {
std::vector<ALLOC_INFO*> dependencies;
std::ofstream out_s( filename, std::ios::out);
if (out_s.is_open()) {
write_checkpoint( out_s, var_name);
} else {
@ -146,19 +162,21 @@ void Trick::MemoryManager::write_checkpoint(const char* filename, const char* va
// MEMBER FUNCTION
void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<const char*>& var_name_list) {
std::vector<ALLOC_INFO*> dependencies;
const char* var_name;
int n_names;
dependencies.clear();
stl_dependencies.clear();
n_names = var_name_list.size();
for (int ii=0; ii< n_names; ii++) {
var_name = var_name_list[ii];
pthread_mutex_lock(&mm_mutex);
get_alloc_deps_in_allocation(dependencies, var_name);
get_alloc_deps_in_allocation(var_name);
pthread_mutex_unlock(&mm_mutex);
}
write_checkpoint( out_s, dependencies);
execute_checkpoint( out_s );
}
// MEMBER FUNCTION

View File

@ -42,14 +42,14 @@ bool dependencies_contain(std::vector<ALLOC_INFO*>& dependencies, const char* na
// ================================================================================
TEST_F(MM_alloc_deps, dbl_singleton) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
double *dbl_p = (double*)memmgr->declare_var("double dbl_singleton");
*dbl_p = 3.1415;
memmgr->get_alloc_deps_in_allocation(dependencies, "dbl_singleton");
memmgr->get_alloc_deps_in_allocation("dbl_singleton");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 1);
@ -59,7 +59,7 @@ TEST_F(MM_alloc_deps, dbl_singleton) {
// ================================================================================
TEST_F(MM_alloc_deps, dbl_pointer) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -68,7 +68,7 @@ TEST_F(MM_alloc_deps, dbl_pointer) {
*dbl_pp = dbl_p;
memmgr->get_alloc_deps_in_allocation(dependencies, "dbl_pointer");
memmgr->get_alloc_deps_in_allocation("dbl_pointer");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 2);
@ -78,7 +78,7 @@ TEST_F(MM_alloc_deps, dbl_pointer) {
// ================================================================================
TEST_F(MM_alloc_deps, dbl_array) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -88,7 +88,7 @@ TEST_F(MM_alloc_deps, dbl_array) {
dbl_p[1] = 2.2;
dbl_p[2] = 3.3;
memmgr->get_alloc_deps_in_allocation(dependencies, "dbl_array");
memmgr->get_alloc_deps_in_allocation("dbl_array");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 1);
@ -97,7 +97,7 @@ TEST_F(MM_alloc_deps, dbl_array) {
// ================================================================================
TEST_F(MM_alloc_deps, dbl_array_pointers) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(2);
@ -111,7 +111,7 @@ TEST_F(MM_alloc_deps, dbl_array_pointers) {
dbl_pa[1] = dbl_p2;
dbl_pa[2] = dbl_p3;
memmgr->get_alloc_deps_in_allocation(dependencies, "dbl_array_ptrs");
memmgr->get_alloc_deps_in_allocation("dbl_array_ptrs");
// There should be 4 dependencies.
EXPECT_EQ( dependencies.size(), 4);
@ -123,7 +123,7 @@ TEST_F(MM_alloc_deps, dbl_array_pointers) {
// ================================================================================
TEST_F(MM_alloc_deps, udt_singleton_no_deps) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -133,7 +133,7 @@ TEST_F(MM_alloc_deps, udt_singleton_no_deps) {
udt_p->udt_p = NULL;
udt_p->dbl_p = NULL;
memmgr->get_alloc_deps_in_allocation(dependencies, "udt_singleton");
memmgr->get_alloc_deps_in_allocation("udt_singleton");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 1);
@ -142,7 +142,7 @@ TEST_F(MM_alloc_deps, udt_singleton_no_deps) {
// ================================================================================
TEST_F(MM_alloc_deps, udt_singleton_self_referential) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -152,7 +152,7 @@ TEST_F(MM_alloc_deps, udt_singleton_self_referential) {
udt_p->udt_p = udt_p;
udt_p->dbl_p = NULL;
memmgr->get_alloc_deps_in_allocation(dependencies, "udt_singleton");
memmgr->get_alloc_deps_in_allocation("udt_singleton");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 1);
@ -161,7 +161,7 @@ TEST_F(MM_alloc_deps, udt_singleton_self_referential) {
// ================================================================================
TEST_F(MM_alloc_deps, udt_singleton_deps) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -173,7 +173,7 @@ TEST_F(MM_alloc_deps, udt_singleton_deps) {
udt1_p->udt_p = udt2_p;
udt1_p->dbl_p = dbl1_p;
memmgr->get_alloc_deps_in_allocation(dependencies, "udt1");
memmgr->get_alloc_deps_in_allocation("udt1");
// There should be 3 dependencies.
EXPECT_EQ( dependencies.size(), 3);
@ -184,7 +184,7 @@ TEST_F(MM_alloc_deps, udt_singleton_deps) {
// ================================================================================
TEST_F(MM_alloc_deps, udt_pointer) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -196,7 +196,7 @@ TEST_F(MM_alloc_deps, udt_pointer) {
*udt1_p = a1;
memmgr->get_alloc_deps_in_allocation(dependencies, "udt_p");
memmgr->get_alloc_deps_in_allocation("udt_p");
// There should be 2 dependencies.
EXPECT_EQ( dependencies.size(), 2);
@ -207,7 +207,7 @@ TEST_F(MM_alloc_deps, udt_pointer) {
// ================================================================================
TEST_F(MM_alloc_deps, udt_array_no_deps) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -225,7 +225,7 @@ TEST_F(MM_alloc_deps, udt_array_no_deps) {
udt_p[2].udt_p = NULL;
udt_p[2].dbl_p = NULL;
memmgr->get_alloc_deps_in_allocation(dependencies, "udt_array");
memmgr->get_alloc_deps_in_allocation("udt_array");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 1);
@ -234,7 +234,7 @@ TEST_F(MM_alloc_deps, udt_array_no_deps) {
// ================================================================================
TEST_F(MM_alloc_deps, udt_array_deps) {
std::vector<ALLOC_INFO*> dependencies;
std::vector<ALLOC_INFO*> & dependencies = memmgr->dependencies ;
//memmgr->set_debug_level(1);
@ -259,7 +259,7 @@ TEST_F(MM_alloc_deps, udt_array_deps) {
udt_p[2].udt_p = udt3_p;
udt_p[2].dbl_p = dbl3_p;
memmgr->get_alloc_deps_in_allocation(dependencies, "udt_array");
memmgr->get_alloc_deps_in_allocation("udt_array");
// There should be 1 dependency.
EXPECT_EQ( dependencies.size(), 7);

View File

@ -11,7 +11,7 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
#TRICK_LDFLAGS += ${COVERAGE_FLAGS}
# Flags passed to the preprocessor.
TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wall -Wextra ${COVERAGE_FLAGS}
TRICK_CPPFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wall -Wextra ${COVERAGE_FLAGS} -std=c++11
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick_mm -ltrick_units -ltrick -ltrick_mm -ltrick_units -ltrick