trick/include/trick/trick_stack.hh
Alex Lin 19025d77ad Standardize directory names
Reorganized.  Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory.  Created a libexec directory that holds all of the executables that users don't need to execute directly.  Changed all of the executables remaining in bin to start with "trick-".  In the sim_services directories changed all source files to find the Trick headers in their new location.  Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level.  Moved the makefiles, docs, man, and other architecture independent files into a top level share directory.  Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on.

refs #63
2015-06-09 08:44:42 -05:00

84 lines
3.1 KiB
C++

#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