g4tools  5.4.0
vector3
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
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::vector3");
24  return s_v;
25  }
26 public: //iro
27  virtual void* cast(const std::string& a_class) const {
28  if(void* p = cmp_cast<vector3>(this,a_class)) return p;
29  return 0;
30  }
31  virtual const std::string& s_cls() const {return s_class();}
32  virtual iro* copy() const {return new vector3(*this);}
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_class)) {return p;}
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 false;
44 
45  //printf("debug : tools::rroot::vector3::stream : version %d\n",v);
46 
47  {uint32 id,bits;
48  if(!Object_stream(a_buffer,id,bits)) return false;}
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_store_class())) return false;
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.m_z)
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
tools::rroot::vector3::stream
virtual bool stream(buffer &a_buffer)
Definition: vector3:40
tools::rroot::vector3::id_class
static cid id_class()
Definition: vector3:34
tools::rroot::Object_stream
bool Object_stream(buffer &a_buffer, uint32 &a_id, uint32 &a_bits)
Definition: object:12
tools::rroot::vector3::operator=
vector3 & operator=(const vector3 &a_from)
Definition: vector3:74
tools::rroot::vector3::s_class
static const std::string & s_class()
Definition: vector3:22
tools::rroot::buffer::check_byte_count
bool check_byte_count(uint32 a_start_pos, uint32 a_byte_count, const std::string &a_store_cls)
Definition: buffer:568
tools::rroot::vector3::y
double y() const
Definition: vector3:82
tools::rroot::vector3::vector3
vector3()
Definition: vector3:59
tools::rroot::vector3::cast
virtual void * cast(cid a_class) const
Definition: vector3:35
tools::rroot::buffer::read_version
bool read_version(short &a_version)
Definition: buffer:503
tools::rroot::vector3_cid
cid vector3_cid()
Definition: cids:51
tools::rroot::vector3
Definition: vector3:14
tools::rroot::vector3::~vector3
virtual ~vector3()
Definition: vector3:64
tools::rroot::vector3::copy
virtual iro * copy() const
Definition: vector3:32
tools::rroot::vector3::z
double z() const
Definition: vector3:83
tools::rroot::vector3::s_cls
virtual const std::string & s_cls() const
Definition: vector3:31
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::rroot::vector3::vector3
vector3(const vector3 &a_from)
Definition: vector3:70
tools::rroot::buffer
Definition: buffer:43
tools::rroot::vector3::x
double x() const
Definition: vector3:81
tools::rroot::rbuf::read
bool read(unsigned char &a_x)
Definition: rbuf:146
tools::rroot::iro
Definition: iro:19
cids
tools::rroot::vector3::cast
virtual void * cast(const std::string &a_class) const
Definition: vector3:27
object
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::cid
unsigned short cid
Definition: cid:9