Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/field 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_field
0005 #define tools_sg_field
0006 
0007 #include <ostream>
0008 
0009 #include "../scast"
0010 #include "../S_STRING"
0011 
0012 #ifdef TOOLS_MEM
0013 #include "../mem"
0014 #endif
0015 
0016 namespace tools {
0017 namespace io {
0018 class iwbuf;
0019 class irbuf;
0020 }}
0021 
0022 namespace tools {
0023 namespace sg {
0024 
0025 class field {
0026 public:
0027   TOOLS_SCLASS(tools::sg::field)
0028   virtual void* cast(const std::string& a_class) const {
0029     if(void* p = cmp_cast<field>(this,a_class)) {return p;}
0030     else return 0;
0031   }
0032   virtual const std::string& s_cls() const = 0;
0033 public:
0034   virtual bool write(io::iwbuf&) = 0;
0035   virtual bool read(io::irbuf&) = 0;
0036   virtual bool dump(std::ostream&) = 0;
0037   virtual bool s_value(std::string&) const = 0;
0038   virtual bool s2value(const std::string&) = 0;
0039 protected:
0040   field():m_touched(true){
0041 #ifdef TOOLS_MEM
0042     mem::increment(s_class().c_str());
0043 #endif
0044   }
0045 public:
0046   virtual ~field(){
0047 #ifdef TOOLS_MEM
0048     mem::decrement(s_class().c_str());
0049 #endif
0050   }
0051 protected:
0052   field(const field&):m_touched(true){
0053 #ifdef TOOLS_MEM
0054     mem::increment(s_class().c_str());
0055 #endif
0056   }
0057   field& operator=(const field&){m_touched=false;return *this;}
0058 public:
0059   void touch() {m_touched = true;}
0060   bool touched() const {return m_touched;}
0061   void reset_touched() {m_touched = false;}
0062 protected:
0063   bool m_touched;
0064 };
0065 
0066 }}
0067 
0068 #define TOOLS_FIELD_DESC_NODE_CLASS(a__class) \
0069   static const std::string s_node_class(#a__class);
0070 
0071 #define TOOLS_ARG_FIELD_DESC(a__field) \
0072   new tools::sg::field_desc(s_node_class+"."+#a__field,this->a__field.s_cls(),(char*)((tools::sg::field*)&(this->a__field))-(char*)((tools::sg::node*)this),true)
0073 
0074 #define TOOLS_ARG_FIELD_DESC_NOT_EDITABLE(a__field) \
0075   new tools::sg::field_desc(s_node_class+"."+#a__field,this->a__field.s_cls(),(char*)((tools::sg::field*)&(this->a__field))-(char*)((tools::sg::node*)this),false)
0076 
0077 #define TOOLS_ARG_FIELD_DESC_ENUMS_BEG(a__field,a__num) \
0078   new tools::sg::field_desc_enums(s_node_class+"."+#a__field,this->a__field.s_cls(),(char*)((tools::sg::field*)&(this->a__field))-(char*)((tools::sg::node*)this),true,a__num,
0079 #define TOOLS_ARG_FIELD_DESC_ENUMS_END )
0080 
0081 #define TOOLS_ARG_FIELD_DESC_NOT_EDITABLE_ENUMS_BEG(a__field,a__num) \
0082   new tools::sg::field_desc_enums(s_node_class+"."+#a__field,this->a__field.s_cls(),(char*)((tools::sg::field*)&(this->a__field))-(char*)((tools::sg::node*)this),false,a__num,
0083 #define TOOLS_ARG_FIELD_DESC_ENUMS_END )
0084 
0085 #define TOOLS_ARG_ENUM(a__value) #a__value,a__value
0086 
0087 #define TOOLS_ARG_FIELD_DESC_OPTS_BEG(a__field,a__num) \
0088   new tools::sg::field_desc_opts(s_node_class+"."+#a__field,this->a__field.s_cls(),(char*)((tools::sg::field*)&(this->a__field))-(char*)((tools::sg::node*)this),true,a__num,
0089 #define TOOLS_ARG_FIELD_DESC_OPTS_END )
0090 
0091 #endif
0092