g4tools  5.4.0
info
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_wroot_info
5 #define tools_wroot_info
6 
7 #include "buffer"
8 #include "element"
9 #include "named"
10 
11 namespace tools {
12 namespace wroot {
13 
14 // sizeof(vtbl) = 4
15 // sizeof(unsigned int) = 4
16 // sizeof(TObject) = 12 = 2 * (unsigned int) + vtbl.
17 // sizeof(TString) = 8 = char* + vtbl.
18 // sizeof(TNamed) = 28 = TObject + 2 * TString.
19 // sizeof(TObjArray) = 40
20 
21 class streamer_info : public virtual ibo {
22  static const std::string& s_class() {
23  static const std::string s_v("tools::wroot::streamer_info");
24  return s_v;
25  }
26 public: //ibo
27  virtual const std::string& store_cls() const {
28  static const std::string s_v("TStreamerInfo");
29  return s_v;
30  }
31  virtual bool stream(buffer& a_buffer) const {
32  unsigned int c;
33  if(!a_buffer.write_version(2,c)) return false;
34 
35  if(!Named_stream(a_buffer,fName,fTitle)) return false;
36  if(!a_buffer.write(fCheckSum)) return false;
37  if(!a_buffer.write(fStreamedClassVersion)) return false;
38 
39  //ObjArray
40  if(!a_buffer.write_object(fElements)) return false;
41 
42  if(!a_buffer.set_byte_count(c)) return false;
43 
44  return true;
45  }
46 public:
47  virtual void out(std::ostream& a_out) const {
48  a_out << "streamer_info for class :"
49  << " " << fName << ", version=" << fStreamedClassVersion
50  << std::endl;
51  tools_vforcit(streamer_element*,fElements,it) (*it)->out(a_out);
52  }
53 public:
54  streamer_info(const std::string& a_cls_store_name,int a_cls_vers,unsigned int a_cls_check_sum)
55  :fName(a_cls_store_name)
56  ,fTitle("")
57  ,fCheckSum(a_cls_check_sum)
58  ,fStreamedClassVersion(a_cls_vers)
59  {
60 #ifdef TOOLS_MEM
61  mem::increment(s_class().c_str());
62 #endif
63  }
64  virtual ~streamer_info(){
65 #ifdef TOOLS_MEM
66  mem::decrement(s_class().c_str());
67 #endif
68  }
69 protected:
71  :ibo(a_from)
72  ,fName(a_from.fName)
73  ,fTitle(a_from.fName)
74  ,fCheckSum(a_from.fCheckSum)
76  ,fElements(a_from.fElements)
77  {
78 #ifdef TOOLS_MEM
79  mem::increment(s_class().c_str());
80 #endif
81  }
83  fName = a_from.fName;
84  fTitle = a_from.fName;
85  fCheckSum = a_from.fCheckSum;
87  fElements = a_from.fElements;
88  return *this;
89  }
90 public:
91  void add(streamer_element* a_elem){fElements.push_back(a_elem);}
92 protected: //Named
93  std::string fName;
94  std::string fTitle;
95 protected:
96  unsigned int fCheckSum; //checksum of original class
97  int fStreamedClassVersion; //Class version identifier
98  //int fNumber; //!Unique identifier
99  obj_array<streamer_element> fElements; //Array of TStreamerElements
100 };
101 
102 }}
103 
104 #endif
tools::wroot::streamer_info::fElements
obj_array< streamer_element > fElements
Definition: info:99
tools::wroot::streamer_info::~streamer_info
virtual ~streamer_info()
Definition: info:64
tools::wroot::streamer_element
Definition: element:54
buffer
tools::wroot::ibo
Definition: ibo:17
tools::wroot::buffer::write_object
bool write_object(const ibo &a_obj)
Definition: buffer:231
tools::wroot::streamer_info::fTitle
std::string fTitle
Definition: info:94
named
tools::wroot::buffer::set_byte_count
bool set_byte_count(uint32 a_pos)
Definition: buffer:199
tools::wroot::obj_array
Definition: named:34
tools::wroot::streamer_info
Definition: info:21
tools::wroot::Named_stream
bool Named_stream(buffer &a_buffer, const std::string &a_name, const std::string &a_title)
Definition: named:23
element
tools::wroot::streamer_info::streamer_info
streamer_info(const std::string &a_cls_store_name, int a_cls_vers, unsigned int a_cls_check_sum)
Definition: info:54
tools::wroot::buffer::write_version
bool write_version(short a_version)
Definition: buffer:169
tools::wroot::streamer_info::out
virtual void out(std::ostream &a_out) const
Definition: info:47
tools::wroot::buffer::write
bool write(T x)
Definition: buffer:97
tools::wroot::streamer_info::fCheckSum
unsigned int fCheckSum
Definition: info:96
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::wroot::streamer_info::streamer_info
streamer_info(const streamer_info &a_from)
Definition: info:70
tools::wroot::buffer
Definition: buffer:28
tools::wroot::streamer_info::stream
virtual bool stream(buffer &a_buffer) const
Definition: info:31
tools::wroot::streamer_info::operator=
streamer_info & operator=(const streamer_info &a_from)
Definition: info:82
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::wroot::streamer_info::fName
std::string fName
Definition: info:93
tools::wroot::streamer_info::add
void add(streamer_element *a_elem)
Definition: info:91
tools::wroot::streamer_info::fStreamedClassVersion
int fStreamedClassVersion
Definition: info:97
tools::wroot::streamer_info::store_cls
virtual const std::string & store_cls() const
Definition: info:27