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


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