mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Add direct STL checkpointing
Added queue and priority queue handling. refs #206
This commit is contained in:
parent
94febe62f2
commit
5368108723
@ -109,6 +109,26 @@ template <class FIRST, class SECOND, typename std::enable_if< is_stl_container<F
|
||||
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 ) ;
|
||||
|
||||
/* ===================================================================================================== */
|
||||
|
||||
// Restore routines
|
||||
@ -199,5 +219,25 @@ template <class FIRST, class SECOND, typename std::enable_if< is_stl_container<F
|
||||
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 ) ;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <utility>
|
||||
|
||||
template <typename T>
|
||||
@ -57,5 +58,15 @@ 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 _Sequence, typename _Compare>
|
||||
struct is_stl_container<std::priority_queue<_Tp,_Sequence,_Compare> > {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,54 +8,44 @@
|
||||
|
||||
#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_fwd_declare.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 = nullptr ;
|
||||
std::queue<ITEM_TYPE> temp_queue ;
|
||||
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 << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
|
||||
<< 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 ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
items[ii] = temp_queue.front() ;
|
||||
@ -66,29 +56,61 @@ 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] ;
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
std::priority_queue<ITEM_TYPE> temp_queue ;
|
||||
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 = (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) ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
temp_queue = in_stl ;
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
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 ) {
|
||||
var_declare << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
|
||||
<< 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() ;
|
||||
@ -99,33 +121,34 @@ 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] ;
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
ITEM_TYPE * items = NULL ;
|
||||
std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::greater<ITEM_TYPE> > temp_queue ;
|
||||
ITEM_TYPE * 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 << abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status ) << " "
|
||||
<< 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 ;
|
||||
//message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
items[ii] = temp_queue.top() ;
|
||||
std::ostringstream index_string ;
|
||||
index_string << ii ;
|
||||
checkpoint_stl (temp_queue.top(), object_name + "_" + var_name, index_string.str()) ;
|
||||
temp_queue.pop() ;
|
||||
}
|
||||
}
|
||||
@ -133,24 +156,41 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, std::vector<ITEM_TYPE>, std::g
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/* Find the arrays the map data was stored in the checkpoint using ref_attributes
|
||||
/* =================================================================================================*/
|
||||
|
||||
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_stl( 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_stl( 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.
|
||||
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()) ;
|
||||
items_ref = ref_attributes((char *)(object_name + std::string("_") + var_name).c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
cont_size = in_stl.size() ;
|
||||
@ -158,7 +198,7 @@ int restore_queue_stl(STL & in_stl , std::string object_name , std::string var_n
|
||||
in_stl.pop() ;
|
||||
}
|
||||
|
||||
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++ ) {
|
||||
@ -166,27 +206,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 + std::string("_") + var_name).c_str()) ;
|
||||
items_ref = ref_attributes((char *)(object_name + "_" + var_name).c_str()) ;
|
||||
|
||||
if ( items_ref != NULL ) {
|
||||
STL().swap(in_stl) ;
|
||||
items = (char **)items_ref->address ;
|
||||
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 ) {
|
||||
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++ ) {
|
||||
@ -194,31 +275,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 ;
|
||||
|
||||
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 ) ;
|
||||
}
|
||||
REF2 * items_ref ;
|
||||
std::string * items ;
|
||||
std::replace_if(object_name.begin(), object_name.end(), std::ptr_fun<int,int>(&std::ispunct), '_');
|
||||
|
||||
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 ) ;
|
||||
}
|
||||
//message_publish(1, "RESTORE_STL_queue %s_%s\n", object_name.c_str() , var_name.c_str()) ;
|
||||
|
||||
// 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
|
||||
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 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -412,7 +412,9 @@ int STLCheckpoint::speak() {
|
||||
//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,"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()) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,7 @@ class STLCheckpoint {
|
||||
|
||||
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::pair< int , int > int_pair ;
|
||||
std::pair< std::string , int > string_first_pair ;
|
||||
|
@ -1,76 +1,4 @@
|
||||
|
||||
#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) ;
|
||||
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] = (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) ;
|
||||
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] = (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) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,44 +1,3 @@
|
||||
|
||||
#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 ) ;
|
||||
}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user