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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 11.1.1)


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