mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
parent
5368108723
commit
06a405ef35
@ -129,6 +129,15 @@ template <typename ITEM_TYPE, typename _Container, typename _Compare,
|
||||
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
|
||||
@ -239,5 +248,14 @@ template <typename ITEM_TYPE, typename _Container, typename _Compare,
|
||||
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
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <stack>
|
||||
#include <utility>
|
||||
|
||||
template <typename T>
|
||||
@ -63,8 +64,13 @@ 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> > {
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,7 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
std::string * items = nullptr ;
|
||||
std::queue<ITEM_TYPE,_Sequence> temp_queue(in_stl) ;
|
||||
|
||||
cont_size = temp_queue.size() ;
|
||||
@ -75,11 +75,15 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & in_stl , std::string object
|
||||
if ( cont_size > 0 ) {
|
||||
var_declare << "std::string "
|
||||
<< object_name << "_" << var_name << "[" << cont_size << "]" ;
|
||||
items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ;
|
||||
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_queue.front(), object_name + "_" + var_name, index_string.str()) ;
|
||||
@ -132,7 +136,7 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
|
||||
std::ostringstream var_declare ;
|
||||
int status ;
|
||||
|
||||
ITEM_TYPE * items = nullptr ;
|
||||
std::string * items = nullptr ;
|
||||
std::priority_queue<ITEM_TYPE,_Container,_Compare> temp_queue(in_stl) ;
|
||||
|
||||
cont_size = temp_queue.size() ;
|
||||
@ -141,14 +145,18 @@ int checkpoint_stl(std::priority_queue<ITEM_TYPE, _Container, _Compare> & in_stl
|
||||
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()) ;
|
||||
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_queue.top(), object_name + "_" + var_name, index_string.str()) ;
|
||||
checkpoint_stl (const_cast< ITEM_TYPE &>(temp_queue.top()), object_name + "_" + var_name, index_string.str()) ;
|
||||
temp_queue.pop() ;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
#include <stack>
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <cxxabi.h>
|
||||
@ -17,36 +20,31 @@
|
||||
#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 = nullptr ;
|
||||
std::stack<ITEM_TYPE> temp_stack ;
|
||||
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) ;
|
||||
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_stack = in_stl ;
|
||||
|
||||
for ( ii = 0 ; ii < cont_size ; ii++ ) {
|
||||
items[ii] = temp_stack.top() ;
|
||||
temp_stack.pop() ;
|
||||
@ -56,14 +54,61 @@ 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 ;
|
||||
int status ;
|
||||
|
||||
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 ;
|
||||
}
|
||||
|
||||
/* =================================================================================================*/
|
||||
|
||||
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_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.
|
||||
*/
|
||||
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 ;
|
||||
|
||||
@ -73,7 +118,6 @@ int restore_stl(std::stack<ITEM_TYPE> & in_stl , std::string object_name , std::
|
||||
|
||||
//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 ) {
|
||||
@ -93,10 +137,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
|
||||
|
@ -5,135 +5,6 @@
|
||||
/* These 2 constructors add different data to an STLCheckpoint. */
|
||||
|
||||
STLCheckpoint::STLCheckpoint() {
|
||||
|
||||
double_map[11.1] = 111.1 ;
|
||||
double_map[22.2] = 222.2 ;
|
||||
double_map[33.3] = 333.3 ;
|
||||
|
||||
string_key_map[std::string("one")] = 1 ;
|
||||
string_key_map[std::string("two")] = 2 ; string_key_map[std::string("three")] = 3 ;
|
||||
|
||||
string_data_map[4] = std::string("vier") ;
|
||||
string_data_map[5] = std::string("fumf") ;
|
||||
string_data_map[6] = std::string("sechs") ;
|
||||
|
||||
string_map[std::string("mother")] = std::string("Marge") ;
|
||||
string_map[std::string("father")] = std::string("Homer") ;
|
||||
string_map[std::string("son")] = std::string("Bart") ;
|
||||
|
||||
int_multimap.insert(std::pair<int, int>(11,111)) ;
|
||||
int_multimap.insert(std::pair<int, int>(22,222)) ;
|
||||
int_multimap.insert(std::pair<int, int>(33,333)) ;
|
||||
int_multimap.insert(std::pair<int, int>(11,111)) ;
|
||||
int_multimap.insert(std::pair<int, int>(22,222)) ;
|
||||
int_multimap.insert(std::pair<int, int>(33,333)) ;
|
||||
|
||||
string_key_multimap.insert(std::pair<std::string, int>("one", 1)) ;
|
||||
string_key_multimap.insert(std::pair<std::string, int>("two", 2)) ;
|
||||
string_key_multimap.insert(std::pair<std::string, int>("three", 3)) ;
|
||||
string_key_multimap.insert(std::pair<std::string, int>("one", 1)) ;
|
||||
string_key_multimap.insert(std::pair<std::string, int>("two", 2)) ;
|
||||
string_key_multimap.insert(std::pair<std::string, int>("three", 3)) ;
|
||||
|
||||
string_data_multimap.insert(std::pair<int, std::string>(4, "vier")) ;
|
||||
string_data_multimap.insert(std::pair<int, std::string>(5, "fumf")) ;
|
||||
string_data_multimap.insert(std::pair<int, std::string>(6, "sechs")) ;
|
||||
string_data_multimap.insert(std::pair<int, std::string>(4, "four")) ;
|
||||
string_data_multimap.insert(std::pair<int, std::string>(5, "five")) ;
|
||||
string_data_multimap.insert(std::pair<int, std::string>(6, "six")) ;
|
||||
|
||||
string_multimap.insert(std::pair<std::string, std::string>("mother","Marge")) ;
|
||||
string_multimap.insert(std::pair<std::string, std::string>("father","Homer")) ;
|
||||
string_multimap.insert(std::pair<std::string, std::string>("mother","Lois")) ;
|
||||
string_multimap.insert(std::pair<std::string, std::string>("father","Meg")) ;
|
||||
|
||||
double_vector.push_back(1.0) ;
|
||||
double_vector.push_back(2.0) ;
|
||||
double_vector.push_back(3.0) ;
|
||||
|
||||
string_vector.push_back("I") ;
|
||||
string_vector.push_back("was") ;
|
||||
string_vector.push_back("here") ;
|
||||
|
||||
short_list.push_back(300) ;
|
||||
short_list.push_back(301) ;
|
||||
short_list.push_back(302) ;
|
||||
|
||||
string_list.push_back("I") ;
|
||||
string_list.push_back("was") ;
|
||||
string_list.push_back("there") ;
|
||||
|
||||
float_deque.push_back(12.3) ;
|
||||
float_deque.push_back(45.6) ;
|
||||
float_deque.push_back(78.9) ;
|
||||
|
||||
string_deque.push_back("meow") ;
|
||||
string_deque.push_back("bark") ;
|
||||
string_deque.push_back("quack") ;
|
||||
|
||||
int_set.insert(8) ;
|
||||
int_set.insert(4) ;
|
||||
int_set.insert(2) ;
|
||||
int_set.insert(1) ;
|
||||
|
||||
string_set.insert("e") ;
|
||||
string_set.insert("a") ;
|
||||
string_set.insert("d") ;
|
||||
|
||||
long_multiset.insert(8) ;
|
||||
long_multiset.insert(4) ;
|
||||
long_multiset.insert(4) ;
|
||||
long_multiset.insert(2) ;
|
||||
long_multiset.insert(1) ;
|
||||
|
||||
string_multiset.insert("e") ;
|
||||
string_multiset.insert("a") ;
|
||||
string_multiset.insert("d") ;
|
||||
string_multiset.insert("e") ;
|
||||
string_multiset.insert("a") ;
|
||||
string_multiset.insert("d") ;
|
||||
|
||||
uint_stack.push(10) ;
|
||||
uint_stack.push(20) ;
|
||||
uint_stack.push(30) ;
|
||||
uint_stack.push(40) ;
|
||||
|
||||
string_stack.push("abc I") ;
|
||||
string_stack.push("abc want the one") ;
|
||||
string_stack.push("abc with the bigger") ;
|
||||
string_stack.push("abc Gee Bees") ;
|
||||
|
||||
int_queue.push(10) ;
|
||||
int_queue.push(20) ;
|
||||
int_queue.push(30) ;
|
||||
int_queue.push(40) ;
|
||||
|
||||
string_queue.push("abc I") ;
|
||||
string_queue.push("abc want") ;
|
||||
string_queue.push("abc an") ;
|
||||
string_queue.push("abc iPhone 4") ;
|
||||
|
||||
int_priority_queue.push(30) ;
|
||||
int_priority_queue.push(20) ;
|
||||
int_priority_queue.push(40) ;
|
||||
int_priority_queue.push(10) ;
|
||||
|
||||
string_priority_queue.push("abc I") ;
|
||||
string_priority_queue.push("abc want") ;
|
||||
string_priority_queue.push("abc an") ;
|
||||
string_priority_queue.push("abc iPhone 4") ;
|
||||
|
||||
int_pair.first = 1 ;
|
||||
int_pair.second = 2 ;
|
||||
|
||||
string_first_pair.first = "abc string first" ;
|
||||
string_first_pair.second = 2 ;
|
||||
|
||||
string_second_pair.first = 2 ;
|
||||
string_second_pair.second = "abc string second" ;
|
||||
|
||||
string_pair.first = "abc pair first string" ;
|
||||
string_pair.second = "abc pair second string" ;
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -270,6 +141,9 @@ STLCheckpoint::STLCheckpoint(std::string in_name) :
|
||||
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) ;
|
||||
@ -290,6 +164,12 @@ STLCheckpoint::STLCheckpoint(std::string in_name) :
|
||||
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 ;
|
||||
|
||||
@ -413,8 +293,12 @@ int STLCheckpoint::speak() {
|
||||
//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,"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 ;
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,16 @@ class STLCheckpoint {
|
||||
|
||||
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 ;
|
||||
|
@ -1,65 +1,3 @@
|
||||
|
||||
#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) ;
|
||||
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] = (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()) ;
|
||||
|
||||
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 = (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 ;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user