Warning, /include/Geant4/tools/sg/bsf is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_bsf
0005 #define tools_sg_bsf
0006
0007 // sf for simple field.
0008
0009 // bsf is intended to have no implementation of :
0010 // virtual bool write(io::iwbuf&)
0011 // virtual bool read(io::irbuf&)
0012
0013 #include "field"
0014
0015 namespace tools {
0016 namespace sg {
0017
0018 template <class T>
0019 class bsf : public field {
0020 typedef field parent;
0021 public:
0022 static const std::string& s_class() {
0023 //we do not use stype(T()).
0024 static const std::string s_v("tools::sg::bsf");
0025 return s_v;
0026 }
0027 virtual void* cast(const std::string& a_class) const {
0028 if(void* p = cmp_cast< bsf<T> >(this,a_class)) {return p;}
0029 return parent::cast(a_class);
0030 }
0031 virtual const std::string& s_cls() const {return s_class();}
0032 protected:
0033 bsf():m_value(T()){}
0034 public:
0035 bsf(const T& a_value):m_value(a_value){}
0036 virtual ~bsf(){}
0037 public:
0038 bsf(const bsf& a_from)
0039 :parent(a_from)
0040 ,m_value(a_from.m_value){}
0041
0042 bsf& operator=(const bsf& a_from){
0043 parent::operator=(a_from);
0044 if(a_from.m_value!=m_value) m_touched = true;
0045 m_value = a_from.m_value;
0046 return *this;
0047 }
0048 public:
0049 bsf& operator=(const T& a_value){
0050 if(a_value!=m_value) m_touched = true;
0051 m_value = a_value;
0052 return *this;
0053 }
0054 bool operator==(const bsf& a_from) const {
0055 return m_value==a_from.m_value;
0056 }
0057 bool operator!=(const bsf& a_from) const {
0058 return !operator==(a_from);
0059 }
0060
0061 bool operator==(const T& a_value) const {
0062 return m_value==a_value;
0063 }
0064 bool operator!=(const T& a_value) const {
0065 return !operator==(a_value);
0066 }
0067
0068 operator const T& () const {return m_value;}
0069 operator T() {return m_value;}
0070
0071 public:
0072 T& value() {return m_value;}
0073 const T& value() const {return m_value;}
0074 void value(const T& a_value) {
0075 if(a_value!=m_value) m_touched = true;
0076 m_value = a_value;
0077 }
0078 void value_no_cmp(const T& a_value) {
0079 m_value = a_value;
0080 }
0081
0082 public: //for iv2sg
0083 void setValue(const T& a_value) {value(a_value);}
0084 const T& getValue() const {return m_value;}
0085 protected:
0086 T m_value;
0087 };
0088
0089 }}
0090
0091 #endif