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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/bmf (Version 11.3.0) and /externals/g4tools/include/tools/sg/bmf (Version 10.1.p2)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_sg_bmf                              
  5 #define tools_sg_bmf                              
  6                                                   
  7 // mf for multiple field.                         
  8                                                   
  9 // bmf is intended to have no implementation o    
 10 //   virtual bool write(io::iwbuf&)               
 11 //   virtual bool read(io::irbuf&)                
 12                                                   
 13 #include "field"                                  
 14                                                   
 15 #include "../vdata"                               
 16                                                   
 17 namespace tools {                                 
 18 namespace sg {                                    
 19                                                   
 20 template <class T>                                
 21 class bmf : public field {                        
 22   typedef field parent;                           
 23 public:                                           
 24   static const std::string& s_class() {           
 25     //we do not use stype(T()).                   
 26     static const std::string s_v("tools::sg::b    
 27     return s_v;                                   
 28   }                                               
 29 //static bool is_a(const std::string& a_class)    
 30   virtual void* cast(const std::string& a_clas    
 31     if(void* p = cmp_cast< bmf<T> >(this,a_cla    
 32     return parent::cast(a_class);                 
 33   }                                               
 34   virtual const std::string& s_cls() const {re    
 35 public:                                           
 36   bmf(){}                                         
 37   bmf(const T& a_value) {m_values.push_back(a_    
 38   bmf(const std::vector<T>& a_v) {m_values = a    
 39   virtual ~bmf(){m_values.clear();}               
 40 public:                                           
 41   bmf(const bmf& a_from):parent(a_from),m_valu    
 42   bmf& operator=(const bmf& a_from){              
 43     parent::operator=(a_from);                    
 44     if(a_from.m_values!=m_values) m_touched =     
 45     m_values = a_from.m_values;                   
 46     return *this;                                 
 47   }                                               
 48 public:                                           
 49   bmf& operator=(const std::vector<T>& a_from)    
 50     if(a_from!=m_values) m_touched = true;        
 51     m_values = a_from;                            
 52     return *this;                                 
 53   }                                               
 54   bool operator==(const bmf& a_from) const {      
 55     return m_values==a_from.m_values;             
 56   }                                               
 57   bool operator!=(const bmf& a_from) const {      
 58     return !operator==(a_from);                   
 59   }                                               
 60   const T& operator[](size_t a_index) const {     
 61     //WARNING : no check is done on a_index.      
 62     return m_values[a_index];                     
 63   }                                               
 64   T& operator[](size_t a_index) {                 
 65     //WARNING : no check is done on a_index.      
 66     return m_values[a_index];                     
 67   }                                               
 68 public:                                           
 69   size_t size() const {return m_values.size();    
 70   bool empty() const {return m_values.empty();    
 71   const std::vector<T>& values() const {return    
 72   std::vector<T>& values() {return m_values;}     
 73   void add(const T& a_value) {                    
 74     m_values.push_back(a_value);                  
 75     m_touched = true;                             
 76   }                                               
 77   void add(const std::vector<T>& a_vals) {        
 78     if(a_vals.empty()) return;                    
 79     typedef typename std::vector<T>::const_ite    
 80     for(const_it_t it=a_vals.begin();it!=a_val    
 81       m_values.push_back(*it);                    
 82     }                                             
 83     m_touched = true;                             
 84   }                                               
 85   void add_allocated(size_t& a_pos,const T& a_    
 86     std::vector<T>& v = m_values;                 
 87     v[a_pos] = a_1;a_pos++;                       
 88     v[a_pos] = a_2;a_pos++;                       
 89     v[a_pos] = a_3;a_pos++;                       
 90     m_touched = true;                             
 91   }                                               
 92   typedef typename std::vector<T>::iterator it    
 93   void insert(const it_t& a_it,const T& a_valu    
 94     m_values.insert(a_it,a_value);                
 95     m_touched = true;                             
 96   }                                               
 97   bool set_value(size_t a_index,const T& a_val    
 98     if(a_index>=m_values.size()) return false;    
 99     if(m_values[a_index]!=a_value) m_touched =    
100     m_values[a_index] = a_value;                  
101     return true;                                  
102   }                                               
103   bool get_value(size_t a_index,T& a_value) {     
104     if(a_index>=m_values.size()) {a_value=T();    
105     a_value = m_values[a_index];                  
106     return true;                                  
107   }                                               
108   void clear() {                                  
109     if(m_values.size()) m_touched = true;         
110     m_values.clear();                             
111   }                                               
112                                                   
113   void set_values(const std::vector<T>& a_valu    
114     if(a_values!=m_values) m_touched = true;      
115     m_values = a_values;                          
116   }                                               
117   void set_value(const T& a_value) { //used in    
118     bool to_resize = m_values.size()==1?false:    
119     bool is_eq = ( (m_values.size()>=1) && (m_    
120     if(to_resize) m_values.resize(1);             
121     if(to_resize || !is_eq) m_touched = true;     
122     m_values[0] = a_value;                        
123   }                                               
124                                                   
125 public: //for iv2sg                               
126   //bool setValues(size_t a_index,size_t a_num    
127   //  for(size_t index=0;index<a_num;index++)     
128   //    if(!set1Value(a_index+index,a_vs[index    
129   //  }                                           
130   //  return true;                                
131   //}                                             
132                                                   
133   bool setValues(size_t a_index,size_t a_num,c    
134     //  012345678                                 
135     //    234                                     
136     if((a_index+a_num)>=m_values.size()) m_val    
137     for(size_t index=0;index<a_num;index++) {     
138       if(a_vs[index]!=m_values[a_index+index])    
139       m_values[a_index+index] = a_vs[index];      
140     }                                             
141     return true;                                  
142   }                                               
143                                                   
144   bool set1Value(size_t a_index,const T& a_val    
145     if(a_index>=m_values.size()) m_values.resi    
146     if(m_values[a_index]!=a_value) m_touched =    
147     m_values[a_index] = a_value;                  
148     return true;                                  
149   }                                               
150   bool setValue(const T& a_value) {set_value(a    
151                                                   
152   bmf& operator=(const T& a_v){                   
153     if(!setValue(a_v)) {}                         
154     return *this;                                 
155   }                                               
156   size_t getNum() const {return m_values.size(    
157   T* getValues(size_t a_start) { //for gopaw.     
158     if(a_start>=(m_values.size()+1)) return 0;    
159     T* data = vec_data(m_values);                 
160     return data+a_start;                          
161   }                                               
162 protected:                                        
163   std::vector<T> m_values;                        
164 };                                                
165                                                   
166 }}                                                
167                                                   
168 #endif