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 namespace tools {
0013 namespace io {
0014 class iwbuf;
0015 class irbuf;
0016 }}
0017
0018 namespace tools {
0019 namespace sg {
0020
0021 class field {
0022 public:
0023 TOOLS_SCLASS(tools::sg::field)
0024 virtual void* cast(const std::string& a_class) const {
0025 if(void* p = cmp_cast<field>(this,a_class)) {return p;}
0026 else return 0;
0027 }
0028 virtual const std::string& s_cls() const = 0;
0029 public:
0030 virtual bool write(io::iwbuf&) = 0;
0031 virtual bool read(io::irbuf&) = 0;
0032 virtual bool dump(std::ostream&) = 0;
0033 virtual bool s_value(std::string&) const = 0;
0034 virtual bool s2value(const std::string&) = 0;
0035 protected:
0036 field():m_touched(true){
0037 }
0038 public:
0039 virtual ~field(){
0040 }
0041 protected:
0042 field(const field&):m_touched(true){
0043 }
0044 field& operator=(const field&){m_touched=false;return *this;}
0045 public:
0046 void touch() {m_touched = true;}
0047 bool touched() const {return m_touched;}
0048 void reset_touched() {m_touched = false;}
0049 protected:
0050 bool m_touched;
0051 };
0052
0053 }}
0054
0055 #define TOOLS_FIELD_DESC_NODE_CLASS(a__class) \
0056 static const std::string s_node_class(#a__class);
0057
0058 #define TOOLS_ARG_FIELD_DESC(a__field) \
0059 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)
0060
0061 #define TOOLS_ARG_FIELD_DESC_NOT_EDITABLE(a__field) \
0062 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)
0063
0064 #define TOOLS_ARG_FIELD_DESC_ENUMS_BEG(a__field,a__num) \
0065 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,
0066 #define TOOLS_ARG_FIELD_DESC_ENUMS_END )
0067
0068 #define TOOLS_ARG_FIELD_DESC_NOT_EDITABLE_ENUMS_BEG(a__field,a__num) \
0069 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,
0070 #define TOOLS_ARG_FIELD_DESC_ENUMS_END )
0071
0072 #define TOOLS_ARG_ENUM(a__value) #a__value,a__value
0073
0074 #define TOOLS_ARG_FIELD_DESC_OPTS_BEG(a__field,a__num) \
0075 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,
0076 #define TOOLS_ARG_FIELD_DESC_OPTS_END )
0077
0078 #endif
0079