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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/sg/states (Version 11.3.0) and /externals/g4tools/include/tools/sg/states (Version 10.4)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_sg_states                           
  5 #define tools_sg_states                           
  6                                                   
  7 #include "state"                                  
  8                                                   
  9 //#define TOOLS_SG_STATES_CUR                     
 10                                                   
 11 namespace tools {                                 
 12 namespace sg {                                    
 13                                                   
 14 class states {                                    
 15 public:                                           
 16 #ifdef TOOLS_SG_STATES_CUR                        
 17   states(unsigned int a_ww,unsigned int a_wh)     
 18   :m_states(8)                                    
 19   ,m_state(&(m_states[0]))                        
 20   ,m_cur_state(0)                                 
 21   {                                               
 22     m_state->m_ww = a_ww;                         
 23     m_state->m_wh = a_wh;                         
 24   }                                               
 25 #else                                             
 26   states(unsigned int a_ww,unsigned int a_wh):    
 27     m_state.m_ww = a_ww;                          
 28     m_state.m_wh = a_wh;                          
 29   }                                               
 30 #endif                                            
 31   virtual ~states(){}                             
 32 protected:                                        
 33 #ifdef TOOLS_SG_STATES_CUR                        
 34   states(const states& a_from)                    
 35   :m_states(a_from.m_states)                      
 36   ,m_state(&(m_states[a_from.m_cur_state]))       
 37   ,m_cur_state(a_from.m_cur_state)                
 38   ,m_saved_state(a_from.m_saved_state)            
 39   {}                                              
 40   states& operator=(const states& a_from){        
 41     m_states = a_from.m_states;                   
 42     m_state = &(m_states[a_from.m_cur_state]);    
 43     m_cur_state = a_from.m_cur_state;             
 44     m_saved_state = a_from.m_saved_state;         
 45     return *this;                                 
 46   }                                               
 47 #else                                             
 48   states(const states& a_from)                    
 49   :m_states(a_from.m_states)                      
 50   ,m_state(a_from.m_state)                        
 51   ,m_saved_state(a_from.m_saved_state)            
 52   {}                                              
 53   states& operator=(const states& a_from){        
 54     m_states = a_from.m_states;                   
 55     m_state = a_from.m_state;                     
 56     m_saved_state = a_from.m_saved_state;         
 57     return *this;                                 
 58   }                                               
 59 #endif                                            
 60 public:                                           
 61 #ifdef TOOLS_SG_STATES_CUR                        
 62   const sg::state& state() const {return *m_st    
 63   sg::state& state() {return *m_state;}           
 64   void pop_state() {                              
 65     m_state = &(m_states[m_cur_state]);           
 66     m_cur_state--;                                
 67   }                                               
 68   void push_state() {                             
 69     if((m_cur_state+1)>=(int)m_states.size())     
 70       m_states.resize(m_states.size()+5);         
 71     }                                             
 72     m_cur_state++;                                
 73     m_states[m_cur_state] = *m_state;             
 74   }                                               
 75 #else                                             
 76   const sg::state& state() const {return m_sta    
 77   sg::state& state() {return m_state;}            
 78   void pop_state() {                              
 79     //if(!m_states.size()) return; //throw.       
 80     m_state = m_states.back();                    
 81     m_states.pop_back();                          
 82   }                                               
 83   void push_state() {m_states.push_back(m_stat    
 84 #endif                                            
 85                                                   
 86   void save_state(const sg::state& a_state) {m    
 87   const sg::state& saved_state() const {return    
 88   sg::state& saved_state() {return m_saved_sta    
 89 protected:                                        
 90   std::vector<sg::state> m_states;                
 91 #ifdef TOOLS_SG_STATES_CUR                        
 92   sg::state* m_state;                             
 93   int m_cur_state;                                
 94 #else                                             
 95   sg::state m_state;                              
 96 #endif                                            
 97   sg::state m_saved_state;                        
 98 };                                                
 99                                                   
100 }}                                                
101                                                   
102 #endif