Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_rroot_vector3 5 #define tools_rroot_vector3 6 7 #include "../scast" 8 #include "object" 9 #include "cids" 10 11 namespace tools { 12 namespace rroot { 13 14 class vector3 : public virtual iro { 15 typedef iro parent; 16 private: 17 static const std::string& s_store_class() { 18 static const std::string s_v("TVector3"); 19 return s_v; 20 } 21 public: 22 static const std::string& s_class() { 23 static const std::string s_v("tools::rroot 24 return s_v; 25 } 26 public: //iro 27 virtual void* cast(const std::string& a_clas 28 if(void* p = cmp_cast<vector3>(this,a_clas 29 return 0; 30 } 31 virtual const std::string& s_cls() const {re 32 virtual iro* copy() const {return new vector 33 public: 34 static cid id_class() {return vector3_cid(); 35 virtual void* cast(cid a_class) const { 36 if(void* p = cmp_cast<vector3>(this,a_clas 37 else return 0; 38 } 39 public: 40 virtual bool stream(buffer& a_buffer) { 41 unsigned int _s,_c; 42 short v; 43 if(!a_buffer.read_version(v,_s,_c)) return 44 45 //printf("debug : tools::rroot::vector3::s 46 47 {uint32 id,bits; 48 if(!Object_stream(a_buffer,id,bits)) retur 49 50 if(!a_buffer.read(m_x)) return false; 51 if(!a_buffer.read(m_y)) return false; 52 if(!a_buffer.read(m_z)) return false; 53 54 if(!a_buffer.check_byte_count(_s,_c,s_stor 55 return true; 56 } 57 58 public: 59 vector3():m_x(0),m_y(0),m_z(0){ 60 #ifdef TOOLS_MEM 61 mem::increment(s_class().c_str()); 62 #endif 63 } 64 virtual ~vector3(){ 65 #ifdef TOOLS_MEM 66 mem::decrement(s_class().c_str()); 67 #endif 68 } 69 public: 70 vector3(const vector3& a_from) 71 :parent(a_from) 72 ,m_x(a_from.m_x),m_y(a_from.m_y),m_z(a_from. 73 {} 74 vector3& operator=(const vector3& a_from){ 75 m_x = a_from.m_x; 76 m_y = a_from.m_y; 77 m_z = a_from.m_z; 78 return *this; 79 } 80 public: 81 double x() const {return m_x;} 82 double y() const {return m_y;} 83 double z() const {return m_z;} 84 private: 85 double m_x,m_y,m_z; 86 }; 87 88 }} 89 90 #endif