Jpp
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
JROOT::JRootDictionary Class Reference

Default implementation of ROOT based dictionary for ASCII I/O. More...

#include <JRootDictionary.hh>

Inheritance diagram for JROOT::JRootDictionary:
JROOT::JRootDictionary_t JLANG::JSingleton< T > std::map< std::string, JLANG::JSharedPointer< JROOT::JAbstractStreamer > >

Public Types

typedef T data_type
 

Public Member Functions

 JRootDictionary ()
 Default constructor. More...
 
template<class T >
void add ()
 Add ASCII I/O for given (list of) class(es) to dictionary. More...
 

Static Public Member Functions

template<class T >
static const char * getTypename ()
 Get typename for given template class. More...
 
static data_typegetInstance ()
 Get unique instance of template class. More...
 

Protected Member Functions

template<class T >
void add (const JType< T > &type)
 Addition of class. More...
 
template<class JElement_t , class JAllocator_t >
void add (const JType< std::vector< JElement_t, JAllocator_t > > &type)
 Addition of std::vector. More...
 
template<class JHead_t , class JTail_t >
void add (const JType< JTypeList< JHead_t, JTail_t > > &typelist)
 Recursive addition of classes. More...
 
void add (const JType< JNullType > &type)
 Template specialisation to terminate addition of classes. More...
 

Detailed Description

Default implementation of ROOT based dictionary for ASCII I/O.

Definition at line 39 of file JRootDictionary.hh.

Member Typedef Documentation

◆ data_type

template<class T>
typedef T JLANG::JSingleton< T >::data_type
inherited

Definition at line 20 of file JSingleton.hh.

Constructor & Destructor Documentation

◆ JRootDictionary()

JROOT::JRootDictionary::JRootDictionary ( )
inline

Default constructor.

This constructor builds a default dictionary which includes all primitive data types and std::vector thereof.

Removed types:

  • long double (not supported by ROOT TDictionary)

Added STL type definitions:

  • std::string

Added ROOT type definitions:

  • [U]Char_t
  • [U]Short_t
  • [U]Int_t
  • [U]Long64_t
  • [U]Float_t
  • [U]Double_t

Definition at line 63 of file JRootDictionary.hh.

63  :
65  {
66 #define VALUE_TYPE(__TYPE__) value_type(#__TYPE__, new JObjectStreamer<__TYPE__>())
67 
68  using namespace JPP;
69 
70  this->add(JType<JRemove<JPrimitiveTypes_t, long double>::typelist>());
71  this->add(JType<std::string>());
72 
73  this->insert(VALUE_TYPE(Char_t));
74  this->insert(VALUE_TYPE(UChar_t));
75  this->insert(VALUE_TYPE(Short_t));
76  this->insert(VALUE_TYPE(UShort_t));
77  this->insert(VALUE_TYPE(Int_t));
78  this->insert(VALUE_TYPE(UInt_t));
79  this->insert(VALUE_TYPE(Long64_t));
80  this->insert(VALUE_TYPE(ULong64_t));
81  this->insert(VALUE_TYPE(Float_t));
82  this->insert(VALUE_TYPE(Double_t));
83 
84 #undef VALUE_TYPE
85  }

Member Function Documentation

◆ getTypename()

template<class T >
static const char* JROOT::JRootDictionary::getTypename ( )
inlinestatic

Get typename for given template class.

This method uses the TDictionary class to get the name of the given class.

Returns
type name

Definition at line 96 of file JRootDictionary.hh.

97  {
98  const TDictionary* pDictionary = TDictionary::GetDictionary(typeid(T));
99 
100  if (pDictionary != NULL)
101  return pDictionary->GetName();
102  else
103  THROW(JException, "Data type not implemented.");
104  }

◆ add() [1/5]

template<class T >
void JROOT::JRootDictionary::add ( )
inline

Add ASCII I/O for given (list of) class(es) to dictionary.

Definition at line 111 of file JRootDictionary.hh.

112  {
113  add(JType<T>());
114  }

◆ add() [2/5]

template<class T >
void JROOT::JRootDictionary::add ( const JType< T > &  type)
inlineprotected

Addition of class.

Parameters
typedata type

Definition at line 124 of file JRootDictionary.hh.

125  {
126  this->insert(value_type(getTypename<T>(), new JObjectStreamer<T>()));
127 
128  try {
129  this->insert(value_type(getTypename< std::vector<T> >(), new JObjectStreamer< std::vector<T> >()));
130  }
131  catch(const JException& error) {};
132  }

◆ add() [3/5]

template<class JElement_t , class JAllocator_t >
void JROOT::JRootDictionary::add ( const JType< std::vector< JElement_t, JAllocator_t > > &  type)
inlineprotected

Addition of std::vector.

Parameters
typedata type

Definition at line 141 of file JRootDictionary.hh.

142  {
144 
145  this->insert(value_type(getTypename<data_type>(), new JObjectStreamer<data_type>()));
146  }

◆ add() [4/5]

template<class JHead_t , class JTail_t >
void JROOT::JRootDictionary::add ( const JType< JTypeList< JHead_t, JTail_t > > &  typelist)
inlineprotected

Recursive addition of classes.

Parameters
typelisttype list

Definition at line 155 of file JRootDictionary.hh.

156  {
157  add(JType<JHead_t>());
158  add(JType<JTail_t>());
159  }

◆ add() [5/5]

void JROOT::JRootDictionary::add ( const JType< JNullType > &  type)
inlineprotected

Template specialisation to terminate addition of classes.

Parameters
typenull type

Definition at line 167 of file JRootDictionary.hh.

168  {}

◆ getInstance()

template<class T>
static data_type& JLANG::JSingleton< T >::getInstance ( )
inlinestaticinherited

Get unique instance of template class.

Returns
object

Definition at line 27 of file JSingleton.hh.

28  {
29  static data_type value;
30 
31  return value;
32  }

The documentation for this class was generated from the following file:
JROOT::JRootDictionary::add
void add()
Add ASCII I/O for given (list of) class(es) to dictionary.
Definition: JRootDictionary.hh:111
std::vector< T >
JROOT::JRootDictionary::getTypename
static const char * getTypename()
Get typename for given template class.
Definition: JRootDictionary.hh:96
JLANG::JSingleton::data_type
T data_type
Definition: JSingleton.hh:20
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
VALUE_TYPE
#define VALUE_TYPE(__TYPE__)
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
JROOT::JRootDictionary_t
Type definition of ROOT based dictionary for ASCII O.
Definition: JRootDictionary_t.hh:30
JROOT::JObjectStreamer
JObjectStreamer class.
Definition: JRootStreamer.hh:748