Jpp  18.2.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private 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 JDATABASE::JDBReader< T >

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...
 
JRootReaderget (const JRootReadableClass &cls)
 Read ROOT class according equation format. More...
 
template<class T >
JRootReadergetObject (T &object)
 Read object. More...
 
JRootReadergetObject (const JRootReadableClass &cls)
 Read ROOT class. More...
 
JRootReadergetObject (JRootReadableClass &cls)
 Read ROOT class. More...
 

Private 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...
 

Private 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>[<division><key>]<separator><value>[<white space><value>]*<end of line>

In this, the key corresponds to the name of a data member, which can be recursively parsed via a division character.

The method JRootReader::getObject relates to 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 59 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 71 of file JRootStreamer.hh.

73  :
74  std::istream(in.rdbuf()),
75  JStreamState(in, static_cast<std::istream&>(*this)),
76  dictionary(dictionary)
77  {
78  imbue(std::locale(in.getloc(), new JLANG::JEquationFacet(parameters)));
79  }
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
JStreamState(std::ostream &from, std::ostream &to)
Constructor.
Definition: JStreamState.hh:32
const JRootDictionary_t & dictionary
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46

Member Function Documentation

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

Get dictionary.

Returns
dictionary

Definition at line 87 of file JRootStreamer.hh.

88  {
89  return dictionary;
90  }
const JRootDictionary_t & dictionary
template<class T >
JRootReader& JROOT::JRootReader::get ( T object)
inline

Read object according equation format.

Parameters
objectobject
Returns
this ROOT reader

Definition at line 100 of file JRootStreamer.hh.

101  {
102  return this->get(JRootReadableClass(object));
103  }
ROOT class for reading object.
Definition: JRootClass.hh:533
JRootReader& JROOT::JRootReader::get ( const JRootReadableClass cls)
inline

Read ROOT class according equation format.

Parameters
clsROOT class
Returns
this ROOT reader

Definition at line 112 of file JRootStreamer.hh.

113  {
114  using namespace std;
115  using namespace JPP;
116 
117  if (cls.is_valid()) {
118 
119  const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
120 
121  for (JEquation equation; *this >> equation; ) {
122 
123  const JRootReadableClass abc = cls.find(equation.getKey().c_str());
124 
125  bool status = abc.is_valid();
126 
127  if (status) {
128 
129  JRedirectString redirect(*this, equation.getValue());
130 
131  if (facet.isDivision (equation.getSeparator()))
132  this->get(abc);
133  else if (facet.isSeparator(equation.getSeparator()))
134  this->getObject(abc);
135  else
136  status = false;
137 
138  status &= (!this->fail() || this->eof());
139  }
140 
141  if (!status) {
142  THROW(JException, "Error parsing: " << equation);
143  }
144  }
145  }
146 
147  return *this;
148  }
ROOT class for reading object.
Definition: JRootClass.hh:533
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JRootReader & getObject(T &object)
Read object.
bool fail(std::istream &in)
Check for stream state.
Definition: JParser.hh:113
bool is_valid() const
Check validity of this addressable class.
Definition: JRootClass.hh:462
JRootAddressableClass find(const char *const name) const
Find addressable base class or data member with given name within current class.
Definition: JRootClass.hh:474
template<class T >
JRootReader& JROOT::JRootReader::getObject ( T object)
inline

Read object.

Parameters
objectobject
Returns
this ROOT reader

Definition at line 158 of file JRootStreamer.hh.

159  {
160  return this->getObject(object, JBool<JStreamAvailable<T>::has_istream>());
161  }
Test availability of stream operators.
JRootReader & getObject(T &object)
Read object.
JRootReader& JROOT::JRootReader::getObject ( const JRootReadableClass cls)
inline

Read ROOT class.

Parameters
clsROOT class
Returns
this ROOT reader

Definition at line 170 of file JRootStreamer.hh.

171  {
172  if (cls.is_valid()) {
173 
174  JRootDictionary_t::const_iterator i = this->getDictionary().find(cls.getTypename());
175 
176  if (i != this->getDictionary().end()) {
177 
178  i->second->getObject(*this, cls.getAddress());
179 
180  } else if (cls.getClass() != NULL) {
181 
182  if (cls.getClass()->GetListOfBases() != NULL) {
183 
184  std::unique_ptr<TIterator> i(cls.getClass()->GetListOfBases()->MakeIterator());
185 
186  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL && (bool) (*this); ) {
187  this->getObject(cls.get(*p));
188  }
189  }
190 
191  if (cls.getClass()->GetListOfDataMembers() != NULL) {
192 
193  std::unique_ptr<TIterator> i(cls.getClass()->GetListOfDataMembers()->MakeIterator());
194 
195  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL && (bool) (*this); ) {
196  this->getObject(cls.get(*p));
197  }
198  }
199  }
200  }
201 
202  return *this;
203  }
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:196
pointer_type getAddress() const
Get address.
Definition: JRootClass.hh:451
JRootReader & getObject(T &object)
Read object.
JRootAddressableClass get(const TDataMember &data_member) const
Get addressable class of given data member.
Definition: JRootClass.hh:486
bool is_valid() const
Check validity of this addressable class.
Definition: JRootClass.hh:462
TClass * getClass() const
Get class.
Definition: JRootClass.hh:185
const JRootDictionary_t & getDictionary() const
Get dictionary.
JRootReader& JROOT::JRootReader::getObject ( JRootReadableClass cls)
inline

Read ROOT class.

Parameters
clsROOT class
Returns
this ROOT reader

Definition at line 212 of file JRootStreamer.hh.

213  {
214  return getObject(const_cast<const JRootReadableClass&>(cls));
215  }
JRootReader & getObject(T &object)
Read object.
template<class T >
JRootReader& JROOT::JRootReader::getObject ( T object,
const JBool< true > &  option 
)
inlineprivate

Read object.

Parameters
objectobject
optiontrue
Returns
this ROOT reader

Definition at line 226 of file JRootStreamer.hh.

227  {
228  *this >> object;
229 
230  return *this;
231  }
template<class T >
JRootReader& JROOT::JRootReader::getObject ( T object,
const JBool< false > &  option 
)
inlineprivate

Read object.

Parameters
objectobject
optionfalse
Returns
this ROOT reader

Definition at line 242 of file JRootStreamer.hh.

243  {
244  return this->getObject(JRootReadableClass(object));
245  }
ROOT class for reading object.
Definition: JRootClass.hh:533
JRootReader & getObject(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 
)
inlineprivate

Read object.

Parameters
objectobject
optionfalse
Returns
this ROOT reader

Definition at line 256 of file JRootStreamer.hh.

257  {
258  int n = 0;
259 
260  this->getObject(n);
261 
262  for (JElement_t element; n != 0 && this->getObject(element); --n) {
263  object.push_back(element);
264  }
265 
266  return *this;
267  }
const int n
Definition: JPolint.hh:786
JRootReader & getObject(T &object)
Read object.

Member Data Documentation

const JRootDictionary_t& JROOT::JRootReader::dictionary
private

Definition at line 270 of file JRootStreamer.hh.


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