Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_sg_field 5 #define tools_sg_field 6 7 #include <ostream> 8 9 #include "../scast" 10 #include "../S_STRING" 11 12 #ifdef TOOLS_MEM 13 #include "../mem" 14 #endif 15 16 namespace tools { 17 namespace io { 18 class iwbuf; 19 class irbuf; 20 }} 21 22 namespace tools { 23 namespace sg { 24 25 class field { 26 public: 27 TOOLS_SCLASS(tools::sg::field) 28 virtual void* cast(const std::string& a_clas 29 if(void* p = cmp_cast<field>(this,a_class) 30 else return 0; 31 } 32 virtual const std::string& s_cls() const = 0 33 public: 34 virtual bool write(io::iwbuf&) = 0; 35 virtual bool read(io::irbuf&) = 0; 36 virtual bool dump(std::ostream&) = 0; 37 virtual bool s_value(std::string&) const = 0 38 virtual bool s2value(const std::string&) = 0 39 protected: 40 field():m_touched(true){ 41 #ifdef TOOLS_MEM 42 mem::increment(s_class().c_str()); 43 #endif 44 } 45 public: 46 virtual ~field(){ 47 #ifdef TOOLS_MEM 48 mem::decrement(s_class().c_str()); 49 #endif 50 } 51 protected: 52 field(const field&):m_touched(true){ 53 #ifdef TOOLS_MEM 54 mem::increment(s_class().c_str()); 55 #endif 56 } 57 field& operator=(const field&){m_touched=fal 58 public: 59 void touch() {m_touched = true;} 60 bool touched() const {return m_touched;} 61 void reset_touched() {m_touched = false;} 62 protected: 63 bool m_touched; 64 }; 65 66 }} 67 68 #define TOOLS_FIELD_DESC_NODE_CLASS(a__class) 69 static const std::string s_node_class(#a__cl 70 71 #define TOOLS_ARG_FIELD_DESC(a__field) \ 72 new tools::sg::field_desc(s_node_class+"."+# 73 74 #define TOOLS_ARG_FIELD_DESC_NOT_EDITABLE(a__f 75 new tools::sg::field_desc(s_node_class+"."+# 76 77 #define TOOLS_ARG_FIELD_DESC_ENUMS_BEG(a__fiel 78 new tools::sg::field_desc_enums(s_node_class 79 #define TOOLS_ARG_FIELD_DESC_ENUMS_END ) 80 81 #define TOOLS_ARG_FIELD_DESC_NOT_EDITABLE_ENUM 82 new tools::sg::field_desc_enums(s_node_class 83 #define TOOLS_ARG_FIELD_DESC_ENUMS_END ) 84 85 #define TOOLS_ARG_ENUM(a__value) #a__value,a__ 86 87 #define TOOLS_ARG_FIELD_DESC_OPTS_BEG(a__field 88 new tools::sg::field_desc_opts(s_node_class+ 89 #define TOOLS_ARG_FIELD_DESC_OPTS_END ) 90 91 #endif 92