Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JROOT::JRootReader Class Reference

Implementation for ASCII input of objects with ROOT dictionary. More...

#include <JRootStreamer.hh>

Inheritance diagram for JROOT::JRootReader:
JLANG::JStreamState

Classes

struct  JDefaultHelper
 Default helper class for formatting. More...
 
struct  JHelper
 Helper class for user formatting. More...
 

Public Member Functions

 JRootReader (std::istream &in, const JEquationParameters &parameters, const JRootDictionary_t &dictionary)
 Constructor. More...
 
const JRootDictionary_tgetDictionary () const
 Get dictionary. More...
 
template<class T >
JRootReaderget (T &object)
 Read object according equation format. More...
 
template<class T >
JRootReadergetObject (T &object)
 Read object. More...
 
JRootReaderget (const JRootReadableClass &cls)
 Read ROOT class according equation format. More...
 
JRootReadergetObject (const JRootReadableClass &cls)
 Read ROOT class. More...
 
JRootReadergetObject (JRootReadableClass &cls)
 Read ROOT class according equation format. More...
 

Static Public Member Functions

template<class T >
static JRootReadergetObject (JRootReader &reader, T &object)
 Read object. More...
 

Protected Member Functions

template<class T >
JRootReadergetObject (T &object, const JBool< true > &option)
 Read object. More...
 
template<class T >
JRootReadergetObject (T &object, const JBool< false > &option)
 Read object. More...
 
template<class JElement_t , class JAllocator_t >
JRootReadergetObject (std::vector< JElement_t, JAllocator_t > &object, const JBool< false > &option)
 Read object. More...
 

Protected Attributes

const JRootDictionary_tdictionary
 

Detailed Description

Implementation for ASCII input of objects with ROOT dictionary.

The method JRootReader::get is compatible with equation formatting, i.e:

<key><separator><value>[<white space><value>]*<end of line>

and method JRootReader::getObject with simple formatting, i.e:

<value>[<white space><value>]*

The default format for input of std::vector<T> is

<number of elements>[<white space><value>]*

Definition at line 52 of file JRootStreamer.hh.

Constructor & Destructor Documentation

JROOT::JRootReader::JRootReader ( std::istream &  in,
const JEquationParameters parameters,
const JRootDictionary_t dictionary 
)
inline

Constructor.

Parameters
ininput stream
parametersequation parameters
dictionarydictionary

Definition at line 96 of file JRootStreamer.hh.

98  :
99  std::istream(in.rdbuf()),
100  JStreamState(in, static_cast<std::istream&>(*this)),
101  dictionary(dictionary)
102  {
103  imbue(std::locale(in.getloc(), new JLANG::JEquationFacet(parameters)));
104  }
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JStreamState(std::ostream &from, std::ostream &to)
Constructor.
Definition: JStreamState.hh:32
const JRootDictionary_t & dictionary

Member Function Documentation

const JRootDictionary_t& JROOT::JRootReader::getDictionary ( ) const
inline

Get dictionary.

Returns
dictionary

Definition at line 112 of file JRootStreamer.hh.

113  {
114  return dictionary;
115  }
const JRootDictionary_t & dictionary
template<class T >
static JRootReader& JROOT::JRootReader::getObject ( JRootReader reader,
T object 
)
inlinestatic

Read object.

This method transfers the reading of the given object to the template JHelper class so that the default format can be changed through specialisation of this class.

Parameters
readerROOT reader
objectobject
Returns
ROOT reader

Definition at line 129 of file JRootStreamer.hh.

130  {
131  return JRootReader::JHelper<T>::getObject(reader, object);
132  }
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
template<class T >
JRootReader& JROOT::JRootReader::get ( T object)
inline

Read object according equation format.

Parameters
objectobject
Returns
this ROOT reader

Definition at line 142 of file JRootStreamer.hh.

143  {
144  return this->get(JRootReadableClass(object));
145  }
ROOT class for reading object.
Definition: JRootClass.hh:526
template<class T >
JRootReader& JROOT::JRootReader::getObject ( T object)
inline

Read object.

Parameters
objectobject
Returns
this ROOT reader

Definition at line 155 of file JRootStreamer.hh.

156  {
157  return this->getObject(object, JBool<JStreamAvailable<T>::has_istream>());
158  }
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
Test availability of stream operators.
Auxiliary template class for type bool.
Definition: JBool.hh:20
JRootReader& JROOT::JRootReader::get ( const JRootReadableClass cls)
inline

Read ROOT class according equation format.

Parameters
clsROOT class
Returns
this ROOT reader

Definition at line 167 of file JRootStreamer.hh.

168  {
169  using namespace std;
170  using namespace JLANG;
171 
172  if (cls.is_valid()) {
173 
174  const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
175 
176  for (JEquation equation; *this >> equation; ) {
177 
178  const JRootReadableClass abc = cls.find(equation.getKey().c_str());
179 
180  bool okay = abc.is_valid();
181 
182  if (okay) {
183 
184  JRedirectString redirect(*this, equation.getValue());
185 
186  if (facet.isDivision (equation.getSeparator()))
187  this->get(abc);
188  else if (facet.isSeparator(equation.getSeparator()))
189  this->getObject(abc);
190  else
191  okay = false;
192 
193  okay &= (!this->fail() || this->eof());
194  }
195 
196  if (!okay) {
197  throw JException("Error parsing: " + equation.toString());
198  }
199  }
200  }
201 
202  return *this;
203  }
General exception.
Definition: JException.hh:23
ROOT class for reading object.
Definition: JRootClass.hh:526
JRootAddressableClass find(const char *name) const
Find addressable base class or data member with given name within current class.
Definition: JRootClass.hh:470
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
General purpose equation class.
Definition: JEquation.hh:47
bool fail(std::istream &in)
Check for stream state.
Definition: JParser.hh:93
bool is_valid() const
Check validity of this addressable class.
Definition: JRootClass.hh:459
bool isSeparator(const char c) const
Test for separator character.
bool isDivision(const char c) const
Test for division character.
This class can be used to temporarily redirect an input stream to an input string.
JRootReader& JROOT::JRootReader::getObject ( const JRootReadableClass cls)
inline

Read ROOT class.

Parameters
clsROOT class
Returns
this ROOT reader

Definition at line 212 of file JRootStreamer.hh.

213  {
214  if (cls.is_valid()) {
215 
216  JRootDictionary_t::const_iterator i = this->getDictionary().find(cls.getTypename());
217 
218  if (i != this->getDictionary().end()) {
219 
220  i->second->getObject(*this, cls.getAddress());
221 
222  } else if (cls.getClass() != NULL) {
223 
224  if (cls.getClass()->GetListOfBases() != NULL) {
225 
226  TIterator* i = cls.getClass()->GetListOfBases()->MakeIterator();
227 
228  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL && (bool) (*this); ) {
229  this->getObject(cls.get(*p));
230  }
231  }
232 
233  if (cls.getClass()->GetListOfDataMembers() != NULL) {
234 
235  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
236 
237  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL && (bool) (*this); ) {
238  this->getObject(cls.get(*p));
239  }
240  }
241  }
242  }
243 
244  return *this;
245  }
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:192
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
pointer_type getAddress() const
Get address.
Definition: JRootClass.hh:448
JRootAddressableClass get(const TDataMember &data_member) const
Get addressable class of given data member.
Definition: JRootClass.hh:481
bool is_valid() const
Check validity of this addressable class.
Definition: JRootClass.hh:459
TClass * getClass() const
Get class.
Definition: JRootClass.hh:181
const JRootDictionary_t & getDictionary() const
Get dictionary.
JRootReader& JROOT::JRootReader::getObject ( JRootReadableClass cls)
inline

Read ROOT class according equation format.

Parameters
clsROOT class
Returns
this ROOT reader

Definition at line 254 of file JRootStreamer.hh.

255  {
256  return getObject(const_cast<const JRootReadableClass&>(cls));
257  }
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
template<class T >
JRootReader& JROOT::JRootReader::getObject ( T object,
const JBool< true > &  option 
)
inlineprotected

Read object.

Parameters
objectobject
optiontrue
Returns
this ROOT reader

Definition at line 269 of file JRootStreamer.hh.

270  {
271  *this >> object;
272 
273  return *this;
274  }
template<class T >
JRootReader& JROOT::JRootReader::getObject ( T object,
const JBool< false > &  option 
)
inlineprotected

Read object.

Parameters
objectobject
optionfalse
Returns
this ROOT reader

Definition at line 285 of file JRootStreamer.hh.

286  {
287  return this->getObject(JRootReadableClass(object));
288  }
ROOT class for reading object.
Definition: JRootClass.hh:526
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
template<class JElement_t , class JAllocator_t >
JRootReader& JROOT::JRootReader::getObject ( std::vector< JElement_t, JAllocator_t > &  object,
const JBool< false > &  option 
)
inlineprotected

Read object.

Parameters
objectobject
optionfalse
Returns
this ROOT reader

Definition at line 299 of file JRootStreamer.hh.

300  {
301  int n = 0;
302 
303  this->getObject(n);
304 
305  for (JElement_t element; n != 0 && this->getObject(element); --n) {
306  object.push_back(element);
307  }
308 
309  return *this;
310  }
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
alias put_queue eval echo n
Definition: qlib.csh:19

Member Data Documentation

const JRootDictionary_t& JROOT::JRootReader::dictionary
protected

Definition at line 313 of file JRootStreamer.hh.


The documentation for this class was generated from the following file: