Warning, /include/Geant4/tools/wroot/base_leaf 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_wroot_base_leaf
0005 #define tools_wroot_base_leaf
0006
0007 #include "named"
0008
0009 #include "cids"
0010 #include "../scast"
0011
0012 namespace tools {
0013 namespace wroot {
0014
0015 class base_leaf : public virtual ibo {
0016 static unsigned int kNullTag() {return 0;}
0017 public:
0018 static cid id_class() {return base_leaf_cid();}
0019 virtual void* cast(cid a_class) const {
0020 if(void* p = cmp_cast<base_leaf>(this,a_class)) {return p;}
0021 else return 0;
0022 }
0023 virtual cid id_cls() const {return id_class();}
0024 public: //ibo
0025 virtual bool stream(buffer& a_buffer) const {
0026 unsigned int c;
0027 if(!a_buffer.write_version(2,c)) return false;
0028 if(!Named_stream(a_buffer,m_name,m_title)) return false;
0029 if(!a_buffer.write(m_length)) return false;
0030 if(!a_buffer.write(m_length_type)) return false;
0031 uint32 fOffset = 0;
0032 if(!a_buffer.write(fOffset)) return false;
0033 if(!a_buffer.write(m_is_range)) return false;
0034 bool fIsUnsigned = false;
0035 if(!a_buffer.write(fIsUnsigned)) return false;
0036
0037 if(m_leaf_count) {
0038 if(!a_buffer.write_object(*m_leaf_count)) return false;
0039 } else {
0040 if(!a_buffer.write(kNullTag())) return false;
0041 }
0042
0043 if(!a_buffer.set_byte_count(c)) return false;
0044 return true;
0045 }
0046 public:
0047 virtual bool fill_buffer(buffer&) const = 0;
0048 public:
0049 base_leaf(std::ostream& a_out,const std::string& a_name,const std::string& a_title)
0050 :m_out(a_out)
0051 ,m_name(a_name)
0052 ,m_title(a_title)
0053
0054 ,m_length(0)
0055 ,m_length_type(0)
0056 ,m_leaf_count(0)
0057 ,m_is_range(false)
0058 {
0059 }
0060 virtual ~base_leaf(){
0061 }
0062 protected:
0063 base_leaf(const base_leaf& a_from)
0064 :ibo(a_from)
0065 ,m_out(a_from.m_out)
0066 ,m_length(0)
0067 ,m_length_type(0)
0068 ,m_leaf_count(0)
0069 ,m_is_range(false)
0070 {}
0071 base_leaf& operator=(const base_leaf&){return *this;}
0072 public:
0073 const std::string& name() const {return m_name;}
0074 void set_title(const std::string& a_value) {m_title = a_value;}
0075 uint32 length() const {return m_length;}
0076 void set_length(uint32 a_value) {m_length = a_value;}
0077 void set_is_range(bool a_value) {m_is_range = a_value;}
0078 protected:
0079 std::ostream& m_out;
0080 protected: //Named
0081 std::string m_name;
0082 std::string m_title;
0083 uint32 m_length; // Number of fixed length elements
0084 uint32 m_length_type; // Number of bytes for this data type
0085 ibo* m_leaf_count;
0086 bool m_is_range;
0087 };
0088
0089 }}
0090
0091 #endif