Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_rroot_graph 4 #ifndef tools_rroot_graph 5 #define tools_rroot_graph 5 #define tools_rroot_graph 6 6 7 #include "../scast" 7 #include "../scast" 8 #include "buffer" 8 #include "buffer" 9 9 10 #include "cids" 10 #include "cids" 11 11 12 namespace tools { 12 namespace tools { 13 namespace rroot { 13 namespace rroot { 14 14 15 class graph : public virtual iro { 15 class graph : public virtual iro { 16 static const std::string& s_store_class() { 16 static const std::string& s_store_class() { 17 static const std::string s_v("TGraph"); 17 static const std::string s_v("TGraph"); 18 return s_v; 18 return s_v; 19 } 19 } 20 public: 20 public: 21 static const std::string& s_class() { 21 static const std::string& s_class() { 22 static const std::string s_v("tools::rroot 22 static const std::string s_v("tools::rroot::graph"); 23 return s_v; 23 return s_v; 24 } 24 } 25 public: //iro 25 public: //iro 26 virtual void* cast(const std::string& a_clas 26 virtual void* cast(const std::string& a_class) const { 27 if(void* p = cmp_cast<graph>(this,a_class) 27 if(void* p = cmp_cast<graph>(this,a_class)) return p; 28 return 0; 28 return 0; 29 } 29 } 30 virtual const std::string& s_cls() const {re 30 virtual const std::string& s_cls() const {return s_class();} 31 public: 31 public: 32 static cid id_class() {return graph_cid();} 32 static cid id_class() {return graph_cid();} 33 virtual void* cast(cid a_class) const { 33 virtual void* cast(cid a_class) const { 34 if(void* p = cmp_cast<graph>(this,a_class) 34 if(void* p = cmp_cast<graph>(this,a_class)) {return p;} 35 else return 0; 35 else return 0; 36 } 36 } 37 public: 37 public: 38 virtual iro* copy() const {return new graph( 38 virtual iro* copy() const {return new graph(*this);} 39 virtual bool stream(buffer& a_buffer) { 39 virtual bool stream(buffer& a_buffer) { 40 uint32 startpos = a_buffer.length(); 40 uint32 startpos = a_buffer.length(); 41 short v; 41 short v; 42 unsigned int _s,_c; << 42 unsigned int s,c; 43 if(!a_buffer.read_version(v,_s,_c)) return << 43 if(!a_buffer.read_version(v,s,c)) return false; 44 a_buffer.set_offset(startpos+_c+sizeof(uns << 44 a_buffer.set_offset(startpos+c+sizeof(unsigned int)); 45 if(!a_buffer.check_byte_count(_s,_c,s_stor << 45 if(!a_buffer.check_byte_count(s,c,s_store_class())) return false; 46 return true; 46 return true; 47 } 47 } 48 public: 48 public: 49 graph(){ 49 graph(){ 50 #ifdef TOOLS_MEM 50 #ifdef TOOLS_MEM 51 mem::increment(s_class().c_str()); 51 mem::increment(s_class().c_str()); 52 #endif 52 #endif 53 } 53 } 54 virtual ~graph(){ 54 virtual ~graph(){ 55 #ifdef TOOLS_MEM 55 #ifdef TOOLS_MEM 56 mem::decrement(s_class().c_str()); 56 mem::decrement(s_class().c_str()); 57 #endif 57 #endif 58 } 58 } 59 protected: 59 protected: 60 graph(const graph& a_from): iro(a_from){} 60 graph(const graph& a_from): iro(a_from){} 61 graph& operator=(const graph&){return *this; 61 graph& operator=(const graph&){return *this;} 62 }; 62 }; 63 63 64 }} 64 }} 65 65 66 #endif 66 #endif