00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00030
00031
00032 #ifndef _OFFSET_STACK_GUARD_H_INCLUDED_
00033 #define _OFFSET_STACK_GUARD_H_INCLUDED_
00034
00035 namespace cttl {
00036
00092 template< typename UniverseT >
00093 class offset_stack_guard {
00094
00095 protected:
00097 typedef typename UniverseT::offset_manager_T offset_guard_T;
00098
00100 typedef typename UniverseT::node_T node_T;
00101
00102 protected:
00104 offset_guard_T m_offset_manager;
00105
00107 std::stack< size_t >& m_offset_stack;
00108
00109 public:
00114 offset_stack_guard( std::stack< size_t >& offset_stack_, node_T& node_ )
00115 :
00116 m_offset_manager( node_.parent().container(), node_.offset() ),
00117 m_offset_stack( offset_stack_ )
00118 {
00119 m_offset_stack.push( m_offset_manager.stack_identity() );
00120 }
00121
00123 ~offset_stack_guard()
00124 {
00125 m_offset_stack.pop();
00126 }
00127
00129 static size_t offset( UniverseT const& universe_, size_t stack_identity_ )
00130 {
00131 return universe_.first.parent().container().stack_offset( stack_identity_ );
00132 }
00133
00135 void operator=( offset_stack_guard< UniverseT > const& ) const
00136 {
00137 }
00138
00139 };
00140
00141
00142 }
00143
00144
00145 #endif //_OFFSET_STACK_GUARD_H_INCLUDED_