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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/bsf (Version 11.3.0) and /externals/g4tools/include/tools/sg/bsf (Version 8.3)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_sg_bsf                              
  5 #define tools_sg_bsf                              
  6                                                   
  7 // sf for simple field.                           
  8                                                   
  9 // bsf 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 namespace tools {                                 
 16 namespace sg {                                    
 17                                                   
 18 template <class T>                                
 19 class bsf : public field {                        
 20   typedef field parent;                           
 21 public:                                           
 22   static const std::string& s_class() {           
 23     //we do not use stype(T()).                   
 24     static const std::string s_v("tools::sg::b    
 25     return s_v;                                   
 26   }                                               
 27   virtual void* cast(const std::string& a_clas    
 28     if(void* p = cmp_cast< bsf<T> >(this,a_cla    
 29     return parent::cast(a_class);                 
 30   }                                               
 31   virtual const std::string& s_cls() const {re    
 32 /*                                                
 33   virtual bool equal(const field& a_field) con    
 34     bsf<T>* fld = safe_cast<field,bsf<T>>(a_fi    
 35     if(!fld) return false;                        
 36     return operator==(*fld);                      
 37   }                                               
 38 */                                                
 39 protected:                                        
 40   bsf():m_value(T()){}                            
 41 public:                                           
 42   bsf(const T& a_value):m_value(a_value){}        
 43   virtual ~bsf(){}                                
 44 public:                                           
 45   bsf(const bsf& a_from)                          
 46   :parent(a_from)                                 
 47   ,m_value(a_from.m_value){}                      
 48                                                   
 49   bsf& operator=(const bsf& a_from){              
 50     parent::operator=(a_from);                    
 51     if(a_from.m_value!=m_value) m_touched = tr    
 52     m_value = a_from.m_value;                     
 53     return *this;                                 
 54   }                                               
 55 public:                                           
 56   bsf& operator=(const T& a_value){               
 57     if(a_value!=m_value) m_touched = true;        
 58     m_value = a_value;                            
 59     return *this;                                 
 60   }                                               
 61   bool operator==(const bsf& a_from) const {      
 62     return m_value==a_from.m_value;               
 63   }                                               
 64   bool operator!=(const bsf& a_from) const {      
 65     return !operator==(a_from);                   
 66   }                                               
 67                                                   
 68   bool operator==(const T& a_value) const {       
 69     return m_value==a_value;                      
 70   }                                               
 71   bool operator!=(const T& a_value) const {       
 72     return !operator==(a_value);                  
 73   }                                               
 74                                                   
 75   operator const T& () const {return m_value;}    
 76   operator T() {return m_value;}                  
 77                                                   
 78 /* does not work with qrot                        
 79   bsf& operator+=(const T& a_value){              
 80     m_value += a_value;                           
 81     m_touched = true;                             
 82     return *this;                                 
 83   }                                               
 84 */                                                
 85 /* does not work with T=std::string               
 86   bsf& operator-=(const T& a_value){              
 87     m_value -= a_value;                           
 88     m_touched = true;                             
 89     return *this;                                 
 90   }                                               
 91   bsf& operator*=(const T& a_value){              
 92     m_value *= a_value;                           
 93     m_touched = true;                             
 94     return *this;                                 
 95   }                                               
 96 */                                                
 97 public:                                           
 98   T& value() {return m_value;}                    
 99   const T& value() const {return m_value;}        
100   void value(const T& a_value) {                  
101     if(a_value!=m_value) m_touched = true;        
102     m_value = a_value;                            
103   }                                               
104   void value_no_cmp(const T& a_value) {           
105     //if(a_value!=m_value) m_touched = true;      
106     m_value = a_value;                            
107   }                                               
108 //public: //for style.                            
109 //  bool s2v(const std::string& a_s) {            
110 //    T v;                                        
111 //    if(!to<T>(a_s,v)) return false;             
112 //    if(v!=m_value) m_touched = true;            
113 //    m_value = v;                                
114 //    return true;                                
115 //  }                                             
116 public: //for iv2sg                               
117   void setValue(const T& a_value) {value(a_val    
118   const T& getValue() const {return m_value;}     
119 protected:                                        
120   T m_value;                                      
121 };                                                
122                                                   
123 }}                                                
124                                                   
125 #endif