Jpp  17.1.0
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::JRootWriter Class Reference

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

#include <JRootStreamer.hh>

Inheritance diagram for JROOT::JRootWriter:
JLANG::JStreamState JAANET::JHeadWriter

Public Member Functions

 JRootWriter (std::ostream &out, const JEquationParameters &parameters, const JRootDictionary_t &dictionary)
 Constructor. More...
 
const JRootDictionary_tgetDictionary () const
 Get dictictionary. More...
 
template<class T >
JRootWriterput (const T &object)
 Write object according equation format. More...
 
template<class T >
JRootWriterput (const std::string &key, const T &value)
 Write given key and value according equation format. More...
 
JRootWriterput (const JRootWritableClass &cls)
 Write ROOT class according equation format. More...
 
JRootWriterput (JRootWritableClass &cls)
 Write ROOT class according equation format. More...
 
JRootWriterput (const std::string &prefix, const JRootWritableClass &cls, bool eol)
 Write ROOT class according equation format. More...
 
virtual JRootWriterput (const JEquation &equation)
 Write equation. More...
 
template<class T >
JRootWriterputObject (const T &object)
 Write object. More...
 
JRootWriterputObject (const JRootWritableClass &cls)
 Write ROOT class. More...
 

Private Member Functions

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

Private Attributes

const JRootDictionary_tdictionary
 

Detailed Description

Implementation for ASCII output of objects with ROOT dictionary.

The method JRootWriter::put 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 JRootWriter::putObject relates to simple formatting, i.e:

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

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

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

Definition at line 291 of file JRootStreamer.hh.

Constructor & Destructor Documentation

JROOT::JRootWriter::JRootWriter ( std::ostream &  out,
const JEquationParameters parameters,
const JRootDictionary_t dictionary 
)
inline

Constructor.

Parameters
outoutput stream
parametersequation parameters
dictionarydictionary

Definition at line 303 of file JRootStreamer.hh.

305  :
306  std::ostream(out.rdbuf()),
307  JStreamState(out, static_cast<std::ostream&>(*this)),
308  dictionary(dictionary)
309  {
310  imbue(std::locale(out.getloc(), new JLANG::JEquationFacet(parameters)));
311 
312  flags (out.flags());
313  width (out.width());
314  precision(out.precision());
315  }
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

Member Function Documentation

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

Get dictictionary.

Returns
dictionary

Definition at line 323 of file JRootStreamer.hh.

324  {
325  return dictionary;
326  }
const JRootDictionary_t & dictionary
template<class T >
JRootWriter& JROOT::JRootWriter::put ( const T object)
inline

Write object according equation format.

Parameters
objectobject
Returns
this ROOT writer

Definition at line 336 of file JRootStreamer.hh.

337  {
338  return this->put(JRootWritableClass(object));
339  }
JRootWriter & put(const T &object)
Write object according equation format.
ROOT class for writing object.
Definition: JRootClass.hh:589
template<class T >
JRootWriter& JROOT::JRootWriter::put ( const std::string &  key,
const T value 
)
inline

Write given key and value according equation format.

Parameters
keykey
valuevalue
Returns
this ROOT writer

Definition at line 350 of file JRootStreamer.hh.

351  {
352  using namespace std;
353  using namespace JPP;
354 
355  ostringstream os;
356 
357  {
358  JRedirectStream redirect(*this, os);
359 
360  this->putObject(value);
361  }
362 
363  return this->put(JEquation(key, os.str()));
364  }
JRootWriter & putObject(const T &object)
Write object.
JRootWriter & put(const T &object)
Write object according equation format.
JRootWriter& JROOT::JRootWriter::put ( const JRootWritableClass cls)
inline

Write ROOT class according equation format.

Parameters
clsROOT class
Returns
this ROOT writer

Definition at line 373 of file JRootStreamer.hh.

374  {
375  return this->put("", cls, false);
376  }
JRootWriter & put(const T &object)
Write object according equation format.
JRootWriter& JROOT::JRootWriter::put ( JRootWritableClass cls)
inline

Write ROOT class according equation format.

Parameters
clsROOT class
Returns
this ROOT writer

Definition at line 385 of file JRootStreamer.hh.

386  {
387  return this->put(const_cast<const JRootWritableClass&>(cls));
388  }
JRootWriter & put(const T &object)
Write object according equation format.
JRootWriter& JROOT::JRootWriter::put ( const std::string &  prefix,
const JRootWritableClass cls,
bool  eol 
)
inline

Write ROOT class according equation format.

Parameters
prefixprefix
clsROOT class
eolend-of-line
Returns
object output

Definition at line 399 of file JRootStreamer.hh.

400  {
401  using namespace std;
402  using namespace JPP;
403 
404  if (cls.is_valid()) {
405 
406  const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
407 
408  JRootDictionary_t::const_iterator i = this->getDictionary().find(cls.getTypename());
409 
410  if (i != this->getDictionary().end()) {
411 
412  i->second->put(*this, prefix, cls.getAddress());
413 
414  } else if (eol) {
415 
416  ostringstream os;
417 
418  {
419  JRedirectStream redirect(*this, os);
420 
421  this->putObject(cls);
422  }
423 
424  this->put(JEquation(prefix, os.str()));
425 
426  } else if (cls.getClass() != NULL) {
427 
428  if (cls.getClass()->GetListOfBases() != NULL) {
429 
430  TIterator* i = cls.getClass()->GetListOfBases()->MakeIterator();
431 
432  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
433  this->put(prefix, cls.get(*p), false);
434  }
435  }
436 
437  if (cls.getClass()->GetListOfDataMembers() != NULL) {
438 
439  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
440 
441  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
442  if (!JRootClass::is_static(*p)) {
443  this->put(facet.getPrefix(prefix,p->GetName()), cls.get(*p), false);
444  }
445  }
446  }
447  }
448  }
449 
450  return *this;
451  }
const JRootDictionary_t & getDictionary() const
Get dictictionary.
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:195
JRootWriter & putObject(const T &object)
Write object.
pointer_type getAddress() const
Get address.
Definition: JRootClass.hh:451
JRootAddressableClass get(const TDataMember &data_member) const
Get addressable class of given data member.
Definition: JRootClass.hh:484
bool is_valid() const
Check validity of this addressable class.
Definition: JRootClass.hh:462
TClass * getClass() const
Get class.
Definition: JRootClass.hh:184
JRootWriter & put(const T &object)
Write object according equation format.
static bool is_static(const TDataMember &data_member)
Check if data member is static.
Definition: JRootClass.hh:127
virtual JRootWriter& JROOT::JRootWriter::put ( const JEquation equation)
inlinevirtual

Write equation.

Parameters
equationequation
Returns
this ROOT writer

Reimplemented in JAANET::JHeadWriter.

Definition at line 460 of file JRootStreamer.hh.

461  {
462  *this << equation;
463 
464  return *this;
465  }
template<class T >
JRootWriter& JROOT::JRootWriter::putObject ( const T object)
inline

Write object.

Parameters
objectobject
Returns
this ROOT writer

Definition at line 475 of file JRootStreamer.hh.

476  {
477  return this->putObject(object, JBool<JStreamAvailable<T>::has_ostream>());
478  }
JRootWriter & putObject(const T &object)
Write object.
Test availability of stream operators.
JRootWriter& JROOT::JRootWriter::putObject ( const JRootWritableClass cls)
inline

Write ROOT class.

Parameters
clsROOT class
Returns
object output

Definition at line 487 of file JRootStreamer.hh.

488  {
489  using namespace std;
490 
491  if (cls.is_valid()) {
492 
493  JRootDictionary_t::const_iterator i = this->getDictionary().find(cls.getTypename());
494 
495  if (i != this->getDictionary().end()) {
496 
497  i->second->putObject(*this, cls.getAddress());
498 
499  } else if (cls.getClass() != NULL) {
500 
501  if (cls.getClass()->GetListOfBases() != NULL) {
502 
503  TIterator* i = cls.getClass()->GetListOfBases()->MakeIterator();
504 
505  for (const TBaseClass* p; (p = (const TBaseClass*) i->Next()) != NULL; ) {
506  this->putObject(cls.get(*p));
507  }
508  }
509 
510  if (cls.getClass()->GetListOfDataMembers() != NULL) {
511 
512  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
513 
514  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
515  if (!JRootClass::is_static(*p)) {
516  this->putObject(cls.get(*p));
517  }
518  }
519  }
520  }
521  }
522 
523  return *this;
524  }
const JRootDictionary_t & getDictionary() const
Get dictictionary.
const char * getTypename() const
Get type name.
Definition: JRootClass.hh:195
JRootWriter & putObject(const T &object)
Write object.
pointer_type getAddress() const
Get address.
Definition: JRootClass.hh:451
JRootAddressableClass get(const TDataMember &data_member) const
Get addressable class of given data member.
Definition: JRootClass.hh:484
bool is_valid() const
Check validity of this addressable class.
Definition: JRootClass.hh:462
TClass * getClass() const
Get class.
Definition: JRootClass.hh:184
static bool is_static(const TDataMember &data_member)
Check if data member is static.
Definition: JRootClass.hh:127
template<class T >
JRootWriter& JROOT::JRootWriter::putObject ( const T object,
const JBool< true > &  option 
)
inlineprivate

Write object.

Parameters
objectobject
optiontrue
Returns
this ROOT writer

Definition at line 535 of file JRootStreamer.hh.

536  {
537  using namespace JPP;
538 
539  *this << white_space;
540  *this << object;
541 
542  return *this;
543  }
std::ostream & white_space(std::ostream &out)
Print white space.
template<class T >
JRootWriter& JROOT::JRootWriter::putObject ( const T object,
const JBool< false > &  option 
)
inlineprivate

Write object.

Parameters
objectobject
optionfalse
Returns
this ROOT writer

Definition at line 554 of file JRootStreamer.hh.

555  {
556  return this->putObject(JRootWritableClass(object));
557  }
JRootWriter & putObject(const T &object)
Write object.
ROOT class for writing object.
Definition: JRootClass.hh:589
template<class JElement_t , class JAllocator_t >
JRootWriter& JROOT::JRootWriter::putObject ( const std::vector< JElement_t, JAllocator_t > &  object,
const JBool< false >  option 
)
inlineprivate

Write object.

Parameters
objectobject
optionfalse
Returns
this ROOT writer

Definition at line 568 of file JRootStreamer.hh.

569  {
570  this->putObject(object.size());
571 
572  for (typename std::vector<JElement_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
573  this->putObject(*i);
574  }
575 
576  return *this;
577  }
JRootWriter & putObject(const T &object)
Write object.

Member Data Documentation

const JRootDictionary_t& JROOT::JRootWriter::dictionary
private

Definition at line 580 of file JRootStreamer.hh.


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