g4tools  5.4.0
dummy
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_dummy
5 #define tools_rroot_dummy
6 
7 // dummy class with a generic streamer.
8 // It is used within the reading of a tree
9 // to create some generic object when we get
10 // from the file a class name which is unknown
11 // from the tree factory.
12 
13 #include "iro"
14 
15 #include "buffer"
16 #include "../scast"
17 #include "cids"
18 
19 namespace tools {
20 namespace rroot {
21 
22 class dummy : public virtual iro {
23 public:
24  static const std::string& s_class() {
25  static const std::string s_v("tools::rroot::dummy");
26  return s_v;
27  }
28 public: //iro
29  virtual void* cast(const std::string& a_class) const {
30  if(void* p = cmp_cast<dummy>(this,a_class)) return p;
31  return 0;
32  }
33  virtual const std::string& s_cls() const {return s_class();}
34 public:
35  static cid id_class() {return dummy_cid();}
36  virtual void* cast(cid a_class) const {
37  if(void* p = cmp_cast<dummy>(this,a_class)) {return p;}
38  return 0;
39  }
40 public:
41  virtual iro* copy() const {return new dummy(*this);}
42  virtual bool stream(buffer& a_buffer) {
43  //the below code skips correctly the data in the file.
44  uint32 startpos = a_buffer.length();
45  short v;
46  unsigned int s,c;
47  if(!a_buffer.read_version(v,s,c)) return false;
48  a_buffer.set_offset(startpos+c+sizeof(unsigned int));
49  if(!a_buffer.check_byte_count(s,c,"dummy")) return false;
50  return true;
51  }
52 public:
53  dummy(){
54 #ifdef TOOLS_MEM
55  mem::increment(s_class().c_str());
56 #endif
57  }
58  virtual ~dummy(){
59 #ifdef TOOLS_MEM
60  mem::decrement(s_class().c_str());
61 #endif
62  }
63 public:
64  dummy(const dummy& a_from): iro(a_from){
65 #ifdef TOOLS_MEM
66  mem::increment(s_class().c_str());
67 #endif
68  }
69  dummy& operator=(const dummy&){return *this;}
70 };
71 
72 }}
73 
74 #endif
tools::rroot::dummy::~dummy
virtual ~dummy()
Definition: dummy:58
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
buffer
tools::rroot::dummy::dummy
dummy()
Definition: dummy:53
tools::rroot::dummy_cid
cid dummy_cid()
Definition: cids:21
iro
tools::rroot::dummy::cast
virtual void * cast(const std::string &a_class) const
Definition: dummy:29
tools::rroot::dummy
Definition: dummy:22
tools::rroot::dummy::s_cls
virtual const std::string & s_cls() const
Definition: dummy:33
tools::rroot::buffer::read_version
bool read_version(short &a_version)
Definition: buffer:503
tools::rroot::dummy::dummy
dummy(const dummy &a_from)
Definition: dummy:64
tools::rroot::buffer::length
uint32 length() const
Definition: buffer:120
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::rroot::dummy::operator=
dummy & operator=(const dummy &)
Definition: dummy:69
tools::rroot::buffer::set_offset
void set_offset(unsigned int a_off)
Definition: buffer:117
tools::rroot::buffer
Definition: buffer:43
tools::rroot::dummy::copy
virtual iro * copy() const
Definition: dummy:41
tools::rroot::dummy::stream
virtual bool stream(buffer &a_buffer)
Definition: dummy:42
tools::rroot::iro
Definition: iro:19
cids
tools::rroot::dummy::cast
virtual void * cast(cid a_class) const
Definition: dummy:36
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::rroot::dummy::id_class
static cid id_class()
Definition: dummy:35
tools::cid
unsigned short cid
Definition: cid:9
tools::rroot::dummy::s_class
static const std::string & s_class()
Definition: dummy:24