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