g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::rroot::iros Class Reference
Inheritance diagram for tools::rroot::iros:
Inheritance graph
[legend]
Collaboration diagram for tools::rroot::iros:
Collaboration graph
[legend]

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const
 
virtual void * cast (cid a_class) const
 
virtual irocopy () const
 
virtual bool stream (buffer &a_buffer)
 
 iros (ifac &a_fac)
 
virtual ~iros ()
 
 iros (const iros &a_from)
 
irosoperator= (const iros &a_from)
 
parent::const_iterator begin () const
 
parent::iterator begin ()
 
parent::const_iterator end () const
 
parent::iterator end ()
 
parent::size_type size () const
 
void cleanup ()
 
void dump (std::ostream &a_out)
 
bool stream (buffer &a_buffer, const ifac::args &a_args, bool a_accept_null=false)
 
- Public Member Functions inherited from tools::rroot::iro
virtual ~iro ()
 

Static Public Member Functions

static const std::string & s_store_class ()
 
static const std::string & s_class ()
 
static cid id_class ()
 

Protected Member Functions

void _clear ()
 

Protected Attributes

ifacm_fac
 
std::vector< bool > m_owns
 

Detailed Description

Definition at line 17 of file iros.

Constructor & Destructor Documentation

◆ iros() [1/2]

tools::rroot::iros::iros ( ifac a_fac)
inline

Definition at line 49 of file iros.

50  :m_fac(a_fac)
51  {
52 #ifdef TOOLS_MEM
53  mem::increment(s_class().c_str());
54 #endif
55  }

◆ ~iros()

virtual tools::rroot::iros::~iros ( )
inlinevirtual

Definition at line 56 of file iros.

56  {
57  _clear();
58 #ifdef TOOLS_MEM
59  mem::decrement(s_class().c_str());
60 #endif
61  }

◆ iros() [2/2]

tools::rroot::iros::iros ( const iros a_from)
inline

Definition at line 63 of file iros.

64  :iro(a_from)
65  ,parent()
66  ,m_fac(a_from.m_fac)
67  {
68 #ifdef TOOLS_MEM
69  mem::increment(s_class().c_str());
70 #endif
71  tools_vforcit(iro*,a_from,it) {
72  parent::push_back((*it)->copy());
73  m_owns.push_back(true);
74  }
75  }

Member Function Documentation

◆ _clear()

void tools::rroot::iros::_clear ( )
inlineprotected

Definition at line 154 of file iros.

154  {
155  typedef parent::iterator it_t;
156  typedef std::vector<bool>::iterator itb_t;
157  while(!parent::empty()) {
158  it_t it = parent::begin();
159  itb_t itb = m_owns.begin();
160  iro* entry = (*it);
161  bool own = (*itb);
162  parent::erase(it);
163  m_owns.erase(itb);
164  if(own) delete entry;
165  }
166  }

◆ begin() [1/2]

parent::iterator tools::rroot::iros::begin ( )
inline

Definition at line 90 of file iros.

90 {return parent::begin();}

◆ begin() [2/2]

parent::const_iterator tools::rroot::iros::begin ( ) const
inline

Definition at line 89 of file iros.

89 {return parent::begin();}

◆ cast() [1/2]

virtual void* tools::rroot::iros::cast ( cid  a_class) const
inlinevirtual

Implements tools::rroot::iro.

Definition at line 37 of file iros.

37  {
38  if(void* p = cmp_cast<iros>(this,a_class)) {return p;}
39  else return 0;
40  }

◆ cast() [2/2]

virtual void* tools::rroot::iros::cast ( const std::string &  a_class) const
inlinevirtual

Implements tools::rroot::iro.

Definition at line 30 of file iros.

30  {
31  if(void* p = cmp_cast<iros>(this,a_class)) return p;
32  return 0;
33  }

◆ cleanup()

void tools::rroot::iros::cleanup ( )
inline

Definition at line 95 of file iros.

95 {_clear();} //warning : clear is a function of the parent std::vector.

◆ copy()

virtual iro* tools::rroot::iros::copy ( ) const
inlinevirtual

Implements tools::rroot::iro.

Definition at line 42 of file iros.

42 {return new iros(*this);}

◆ dump()

void tools::rroot::iros::dump ( std::ostream &  a_out)
inline

Definition at line 96 of file iros.

96  {
97  a_out << " iros : size " << size() << std::endl;
98  tools_vforcit(iro*,*this,it) {
99  a_out << " class " << (*it)->s_cls() << std::endl;
100  }
101  }

◆ end() [1/2]

parent::iterator tools::rroot::iros::end ( )
inline

Definition at line 92 of file iros.

92 {return parent::end();}

◆ end() [2/2]

parent::const_iterator tools::rroot::iros::end ( ) const
inline

Definition at line 91 of file iros.

91 {return parent::end();}

◆ id_class()

static cid tools::rroot::iros::id_class ( )
inlinestatic

Definition at line 36 of file iros.

36 {return obj_list_cid();}

◆ operator=()

iros& tools::rroot::iros::operator= ( const iros a_from)
inline

Definition at line 76 of file iros.

76  {
77  if(&a_from==this) return *this;
78 
79  _clear();
80 
81  tools_vforcit(iro*,a_from,it) {
82  parent::push_back((*it)->copy());
83  m_owns.push_back(true);
84  }
85 
86  return *this;
87  }

◆ s_class()

static const std::string& tools::rroot::iros::s_class ( )
inlinestatic

Definition at line 25 of file iros.

25  {
26  static const std::string s_v("tools::rroot::iros");
27  return s_v;
28  }

◆ s_cls()

virtual const std::string& tools::rroot::iros::s_cls ( ) const
inlinevirtual

Implements tools::rroot::iro.

Definition at line 34 of file iros.

34 {return s_class();}

◆ s_store_class()

static const std::string& tools::rroot::iros::s_store_class ( )
inlinestatic

Definition at line 20 of file iros.

20  {
21  static const std::string s_v("TObjArray");
22  return s_v;
23  }

◆ size()

parent::size_type tools::rroot::iros::size ( ) const
inline

Definition at line 93 of file iros.

93 {return parent::size();}

◆ stream() [1/2]

virtual bool tools::rroot::iros::stream ( buffer a_buffer)
inlinevirtual

Implements tools::rroot::iro.

Definition at line 43 of file iros.

43  {
44  ifac::args args;
45  bool accept_null = false;
46  return stream(a_buffer,args,accept_null);
47  }

◆ stream() [2/2]

bool tools::rroot::iros::stream ( buffer a_buffer,
const ifac::args a_args,
bool  a_accept_null = false 
)
inline

Definition at line 103 of file iros.

103  {
104  _clear();
105 
106  short v;
107  unsigned int s, c;
108  if(!a_buffer.read_version(v,s,c)) return false;
109 
110  //::printf("debug : iros::stream : version %d, byte count %d\n",v,c);
111 
112  {uint32 id,bits;
113  if(!Object_stream(a_buffer,id,bits)) return false;}
114  std::string name;
115  if(!a_buffer.read(name)) return false;
116  int nobjects;
117  if(!a_buffer.read(nobjects)) return false;
118  int lowerBound;
119  if(!a_buffer.read(lowerBound)) return false;
120 
121  //::printf("debug : iros : name \"%s\", nobject %d, lowerBound %d\n",
122  // name.c_str(),nobjects,lowerBound);
123 
124  for (int i=0;i<nobjects;i++) {
125  //::printf("debug : iros : n=%d i=%d ...\n",nobjects,i);
126 
127  iro* obj;
128  bool created;
129  if(!a_buffer.read_object(m_fac,a_args,obj,created)){
130  a_buffer.out() << "tools::rroot::iros::stream : can't read object." << std::endl;
131  return false;
132  }
133  //::printf("debug : iros : n=%d i=%d : ok\n",nobjects,i);
134  if(obj) {
135  if(created) {
136  parent::push_back(obj);
137  m_owns.push_back(true);
138  } else { //someone else manage this object.
139  parent::push_back(obj);
140  m_owns.push_back(false);
141  }
142  } else {
143  //a_accept_null for branch::stream m_baskets.
144  if(a_accept_null) {
145  parent::push_back(0);
146  m_owns.push_back(false);
147  }
148  }
149  }
150 
151  return a_buffer.check_byte_count(s,c,s_store_class());
152  }

Member Data Documentation

◆ m_fac

ifac& tools::rroot::iros::m_fac
protected

Definition at line 168 of file iros.

◆ m_owns

std::vector<bool> tools::rroot::iros::m_owns
protected

Definition at line 169 of file iros.


The documentation for this class was generated from the following file:
tools::rroot::Object_stream
bool Object_stream(buffer &a_buffer, uint32 &a_id, uint32 &a_bits)
Definition: object:12
tools::rroot::iros::size
parent::size_type size() const
Definition: iros:93
tools::waxml::begin
void begin(std::ostream &a_writer)
Definition: begend:15
tools::rroot::iros::m_fac
ifac & m_fac
Definition: iros:168
tools::rroot::iros::m_owns
std::vector< bool > m_owns
Definition: iros:169
tools::rroot::iros::s_store_class
static const std::string & s_store_class()
Definition: iros:20
tools::file::size
bool size(const std::string &a_file, long &a_size)
Definition: fsize:13
tools::rroot::iros::iros
iros(ifac &a_fac)
Definition: iros:49
tools::rroot::iros::s_class
static const std::string & s_class()
Definition: iros:25
tools::rroot::iros::_clear
void _clear()
Definition: iros:154
tools::waxml::end
void end(std::ostream &a_writer)
Definition: begend:31
tools::rroot::ifac::args
std::map< char, void * > args
Definition: ifac:21
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::rroot::iros::stream
virtual bool stream(buffer &a_buffer)
Definition: iros:43
tools::rroot::obj_list_cid
cid obj_list_cid()
Definition: cids:17
tools::uint32
unsigned int uint32
Definition: typedefs:71