g4tools  5.4.0
member_reader
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_member_reader
5 #define tools_rroot_member_reader
6 
7 #include "../store/iobj_visitor"
8 
9 #include "buffer"
10 
11 namespace tools {
12 namespace rroot {
13 
14 class member_reader : public virtual iobj_visitor {
15 public:
16  virtual std::ostream& out() const {return m_buf.out();}
17 
18  virtual bool visit(bool& a_v){return m_buf.read(a_v);}
19  virtual bool visit(char& a_v){return m_buf.read(a_v);}
20  virtual bool visit(short& a_v){return m_buf.read(a_v);}
21  virtual bool visit(int& a_v){return m_buf.read(a_v);}
22 
23  virtual bool visit(unsigned int& a_v){return m_buf.read(a_v);}
24 
25  virtual bool visit(int64&){
26  m_buf.out() << "tools::rroot::member_reader::visit(int64) :"
27  << " dummy." << std::endl;
28  return false; //FIXME
29  }
30 
31  virtual bool visit(uint64&){
32  m_buf.out() << "tools::rroot::member_reader::visit(uint64) :"
33  << " dummy." << std::endl;
34  return false; //FIXME
35  }
36 
37  virtual bool visit(float& a_v){return m_buf.read(a_v);}
38  virtual bool visit(double& a_v){return m_buf.read(a_v);}
39 
40  virtual bool visit(std::string& a_v){return m_buf.read(a_v);}
41 
42 //virtual bool visit(const char* a_v){
43 // return m_buf.read(std::string(a_v));
44 //}
45 
46  virtual bool visit(std::vector<bool>& a_v){
47  std::vector<unsigned char> data;
48  if(!m_buf.read_array(data)) {a_v.clear();return false;}
49  size_t number = data.size();
50  a_v.resize(number);
51  for(size_t index=0;index<number;index++) {
52  a_v[index] = (data[index]==1?true:false);
53  }
54  return true;
55  }
56 
57  virtual bool visit(std::vector<char>& a_v){return m_buf.read_array(a_v);}
58 
59  virtual bool visit(std::vector<short>& a_v){return m_buf.read_array(a_v);}
60 
61  virtual bool visit(std::vector<int>& a_v){return m_buf.read_array(a_v);}
62 
63  virtual bool visit(std::vector<int64>& /*a_v*/){
64  //FIXME return ::Rio::writeArray<Slash::int64>(fBuffer,a_v);
65  m_buf.out() << "tools::rroot::member_reader::visit(vector<int64>) :"
66  << " dummy." << std::endl;
67  return false;
68  }
69 
70  virtual bool visit(std::vector<float>& a_v){return m_buf.read_array(a_v);}
71 
72  virtual bool visit(std::vector<double>& a_v){return m_buf.read_array(a_v);}
73 
74  virtual bool visit(std::vector<unsigned char>& a_v){
75  return m_buf.read_array(a_v);
76  }
77 
78  virtual bool visit(std::vector<std::string>& a_v){return m_buf.read(a_v);}
79 
80  virtual bool visit(std::vector< std::vector<double> >& a_v){
81  return m_buf.read_array2(a_v);
82  }
83 
84 public:
85  member_reader(buffer& a_buf):m_buf(a_buf){}
86  virtual ~member_reader(){}
87 private:
88  member_reader(const member_reader& a_from)
89  :iobj_visitor(a_from)
90  ,m_buf(a_from.m_buf)
91  {}
92  member_reader& operator=(const member_reader&){return *this;}
93 protected:
95 };
96 
97 }}
98 
99 #endif
tools::rroot::member_reader::~member_reader
virtual ~member_reader()
Definition: member_reader:86
tools::rroot::member_reader::visit
virtual bool visit(int64 &)
Definition: member_reader:25
tools::rroot::member_reader::visit
virtual bool visit(std::vector< char > &a_v)
Definition: member_reader:57
tools::uint64
unsigned long long uint64
Definition: typedefs:72
tools::rroot::member_reader::visit
virtual bool visit(std::vector< std::string > &a_v)
Definition: member_reader:78
tools::int64
long long int64
Definition: typedefs:67
tools::rroot::member_reader::visit
virtual bool visit(int &a_v)
Definition: member_reader:21
tools::rroot::member_reader::visit
virtual bool visit(short &a_v)
Definition: member_reader:20
tools::rroot::member_reader::visit
virtual bool visit(std::vector< float > &a_v)
Definition: member_reader:70
buffer
tools::rroot::member_reader::visit
virtual bool visit(std::vector< double > &a_v)
Definition: member_reader:72
tools::rroot::rbuf::read_array2
bool read_array2(std::vector< std::vector< T > > &a_v)
Definition: rbuf:365
tools::rroot::member_reader::m_buf
buffer & m_buf
Definition: member_reader:94
tools::rroot::member_reader::visit
virtual bool visit(std::vector< int > &a_v)
Definition: member_reader:61
tools::rroot::member_reader::visit
virtual bool visit(std::string &a_v)
Definition: member_reader:40
tools::rroot::member_reader::visit
virtual bool visit(unsigned int &a_v)
Definition: member_reader:23
tools::rroot::rbuf::read_array
bool read_array(uint32 a_sz, T *&a_a, uint32 &a_n)
Definition: rbuf:314
tools::rroot::rbuf::out
std::ostream & out() const
Definition: rbuf:125
tools::rroot::member_reader::visit
virtual bool visit(float &a_v)
Definition: member_reader:37
tools::rroot::member_reader::visit
virtual bool visit(std::vector< short > &a_v)
Definition: member_reader:59
tools::rroot::member_reader::out
virtual std::ostream & out() const
Definition: member_reader:16
tools::rroot::member_reader
Definition: member_reader:14
tools::rroot::member_reader::visit
virtual bool visit(std::vector< bool > &a_v)
Definition: member_reader:46
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::rroot::buffer
Definition: buffer:43
tools::rroot::member_reader::visit
virtual bool visit(double &a_v)
Definition: member_reader:38
tools::rroot::member_reader::visit
virtual bool visit(char &a_v)
Definition: member_reader:19
tools::iobj_visitor
Definition: iobj_visitor:15
tools::rroot::member_reader::visit
virtual bool visit(uint64 &)
Definition: member_reader:31
tools::rroot::rbuf::read
bool read(unsigned char &a_x)
Definition: rbuf:146
tools::rroot::member_reader::visit
virtual bool visit(std::vector< std::vector< double > > &a_v)
Definition: member_reader:80
tools::rroot::member_reader::visit
virtual bool visit(std::vector< int64 > &)
Definition: member_reader:63
tools::rroot::member_reader::visit
virtual bool visit(bool &a_v)
Definition: member_reader:18
tools::rroot::member_reader::visit
virtual bool visit(std::vector< unsigned char > &a_v)
Definition: member_reader:74
tools::rroot::member_reader::member_reader
member_reader(buffer &a_buf)
Definition: member_reader:85