DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
dd4hep::BasicGrammar Class Referenceabstract

Base class describing string evaluation to C++ objects using boost::spirit. More...

#include <Grammar.h>

Inheritance diagram for dd4hep::BasicGrammar:
dd4hep::Grammar< TYPE >

Classes

struct  specialization_t
 Structure to be filled if automatic object parsing from string is supposed to be supported. More...
 

Public Types

typedef unsigned long long int key_type
 

Public Member Functions

key_type hash () const
 Access the hash value for this grammar type. More...
 
const std::string & type_name () const
 Access to the type information name. More...
 
int data_type () const
 Access ROOT data type for fundamentals. More...
 
TClass * clazz () const
 Access the ROOT class for complex objects. More...
 
virtual void setCast (const Cast *cast) const
 Set cast structure. More...
 
virtual const Cast & cast () const
 Access ABI object cast. More...
 
virtual bool equals (const std::type_info &other_type) const =0
 Access to the type information. More...
 
virtual const std::type_info & type () const =0
 Access to the type information. More...
 
virtual size_t sizeOf () const =0
 Access the object size (sizeof operator) More...
 
virtual void destruct (void *pointer) const =0
 Opaque object destructor. More...
 
virtual std::string str (const void *ptr) const
 Serialize an opaque value to a string. More...
 
virtual bool fromString (void *ptr, const std::string &value) const
 Set value from serialized string. On successful data conversion TRUE is returned. More...
 
virtual int evaluate (void *ptr, const std::string &value) const
 Evaluate string value if possible before calling boost::spirit. More...
 

Static Public Member Functions

template<typename TYPE >
static const BasicGrammarinstance ()
 Instance factory. More...
 
static const BasicGrammarget (const std::type_info &info)
 Access grammar by type info. More...
 
static const BasicGrammarget (unsigned long long int hash_code)
 Lookup existing grammar using the grammar's hash code/hash64(type-name) (used for reading objects) More...
 
static void invalidConversion (const std::type_info &from, const std::type_info &to)
 Error callback on invalid conversion. More...
 
static void invalidConversion (const std::string &value, const std::type_info &to)
 Error callback on invalid conversion. More...
 

Public Attributes

const std::string name
 Instance type name. More...
 
const key_type hash_value = 0
 Instance hash code. More...
 
TClass * root_class = 0
 Cached TClass reference for speed improvements. More...
 
int root_data_type = -1
 Cached TDataType information for fundamental types. More...
 
bool inited = false
 Initialization flag. More...
 
struct dd4hep::BasicGrammar::specialization_t specialization
 

Protected Member Functions

 BasicGrammar (const std::string &typ)
 Default constructor. More...
 
virtual ~BasicGrammar ()
 Default destructor. More...
 
void initialize () const
 Second step initialization after the virtual table is fixed. More...
 
int initialized_data_type () const
 Access ROOT data type for fundamentals. More...
 
TClass * initialized_clazz () const
 Access the ROOT class for complex objects. More...
 

Static Protected Member Functions

static void pre_note (const std::type_info &info, const BasicGrammar &(*fcn)(), specialization_t specs)
 Instance factory. More...
 

Friends

class GrammarRegistry
 

Detailed Description

Base class describing string evaluation to C++ objects using boost::spirit.

Grammar object handle the boost::spirit conversion between strings and numeric values/objects. Numeric objects could be atomic (int, long, float, double, etc) or complex (vector<int>, vector<float>...). This way e.g. a vector<int> may be converted into a list<double>. The conversion though requires an intermediate string representation. For this reason the conversion mechanism is relatively slow and hence should not be used inside number-crunching algorithms.

Author
M.Frank
Version
1.0
Date
13.08.2013

Definition at line 56 of file Grammar.h.

Member Typedef Documentation

◆ key_type

typedef unsigned long long int dd4hep::BasicGrammar::key_type

Definition at line 59 of file Grammar.h.

Constructor & Destructor Documentation

◆ BasicGrammar()

dd4hep::BasicGrammar::BasicGrammar ( const std::string &  typ)
protected

Default constructor.

Definition at line 102 of file Grammar.cpp.

◆ ~BasicGrammar()

dd4hep::BasicGrammar::~BasicGrammar ( )
protectedvirtual

Default destructor.

Definition at line 115 of file Grammar.cpp.

Member Function Documentation

◆ cast()

const dd4hep::Cast & dd4hep::BasicGrammar::cast ( ) const
virtual

Access ABI object cast.

Definition at line 253 of file Grammar.cpp.

◆ clazz()

TClass* dd4hep::BasicGrammar::clazz ( ) const
inline

Access the ROOT class for complex objects.

Definition at line 137 of file Grammar.h.

◆ data_type()

int dd4hep::BasicGrammar::data_type ( ) const
inline

Access ROOT data type for fundamentals.

Definition at line 132 of file Grammar.h.

◆ destruct()

virtual void dd4hep::BasicGrammar::destruct ( void *  pointer) const
pure virtual

Opaque object destructor.

Implemented in dd4hep::Grammar< TYPE >.

◆ equals()

virtual bool dd4hep::BasicGrammar::equals ( const std::type_info &  other_type) const
pure virtual

Access to the type information.

Implemented in dd4hep::Grammar< TYPE >.

◆ evaluate()

int dd4hep::BasicGrammar::evaluate ( void *  ptr,
const std::string &  value 
) const
virtual

Evaluate string value if possible before calling boost::spirit.

Definition at line 278 of file Grammar.cpp.

◆ fromString()

bool dd4hep::BasicGrammar::fromString ( void *  ptr,
const std::string &  value 
) const
virtual

Set value from serialized string. On successful data conversion TRUE is returned.

Definition at line 269 of file Grammar.cpp.

◆ get() [1/2]

const dd4hep::BasicGrammar & dd4hep::BasicGrammar::get ( const std::type_info &  info)
static

Access grammar by type info.

Lookup existing grammar using hash code (reading objects)

Definition at line 184 of file Grammar.cpp.

◆ get() [2/2]

const dd4hep::BasicGrammar & dd4hep::BasicGrammar::get ( unsigned long long int  hash_code)
static

Lookup existing grammar using the grammar's hash code/hash64(type-name) (used for reading objects)

Lookup existing grammar using hash code (reading objects)

Definition at line 153 of file Grammar.cpp.

◆ hash()

key_type dd4hep::BasicGrammar::hash ( ) const
inline

Access the hash value for this grammar type.

Definition at line 128 of file Grammar.h.

◆ initialize()

void dd4hep::BasicGrammar::initialize ( ) const
protected

Second step initialization after the virtual table is fixed.

Definition at line 198 of file Grammar.cpp.

◆ initialized_clazz()

TClass * dd4hep::BasicGrammar::initialized_clazz ( ) const
protected

Access the ROOT class for complex objects.

Definition at line 224 of file Grammar.cpp.

◆ initialized_data_type()

int dd4hep::BasicGrammar::initialized_data_type ( ) const
protected

Access ROOT data type for fundamentals.

Definition at line 218 of file Grammar.cpp.

◆ instance()

template<typename TYPE >
const BasicGrammar & dd4hep::BasicGrammar::instance
static

Instance factory.

Standarsd constructor.

Definition at line 274 of file GrammarParsed.h.

◆ invalidConversion() [1/2]

void dd4hep::BasicGrammar::invalidConversion ( const std::string &  value,
const std::type_info &  to 
)
static

Error callback on invalid conversion.

Definition at line 230 of file Grammar.cpp.

◆ invalidConversion() [2/2]

void dd4hep::BasicGrammar::invalidConversion ( const std::type_info &  from,
const std::type_info &  to 
)
static

Error callback on invalid conversion.

Definition at line 238 of file Grammar.cpp.

◆ pre_note()

void dd4hep::BasicGrammar::pre_note ( const std::type_info &  info,
const BasicGrammar &(*)()  fcn,
specialization_t  specs 
)
staticprotected

Instance factory.

Prenote loadable grammar.

If the grammer was instantiated before the pre-note: update the grammar...

Definition at line 119 of file Grammar.cpp.

◆ setCast()

void dd4hep::BasicGrammar::setCast ( const Cast *  cast) const
virtual

Set cast structure.

Definition at line 247 of file Grammar.cpp.

◆ sizeOf()

virtual size_t dd4hep::BasicGrammar::sizeOf ( ) const
pure virtual

Access the object size (sizeof operator)

Implemented in dd4hep::Grammar< TYPE >.

◆ str()

std::string dd4hep::BasicGrammar::str ( const void *  ptr) const
virtual

Serialize an opaque value to a string.

Definition at line 261 of file Grammar.cpp.

◆ type()

virtual const std::type_info& dd4hep::BasicGrammar::type ( ) const
pure virtual

Access to the type information.

Implemented in dd4hep::Grammar< TYPE >.

◆ type_name()

const std::string& dd4hep::BasicGrammar::type_name ( ) const
inline

Access to the type information name.

Definition at line 130 of file Grammar.h.

Friends And Related Function Documentation

◆ GrammarRegistry

friend class GrammarRegistry
friend

Definition at line 57 of file Grammar.h.

Member Data Documentation

◆ hash_value

const key_type dd4hep::BasicGrammar::hash_value = 0

Instance hash code.

Definition at line 63 of file Grammar.h.

◆ inited

bool dd4hep::BasicGrammar::inited = false
mutable

Initialization flag.

Definition at line 69 of file Grammar.h.

◆ name

const std::string dd4hep::BasicGrammar::name

Instance type name.

Definition at line 61 of file Grammar.h.

◆ root_class

TClass* dd4hep::BasicGrammar::root_class = 0
mutable

Cached TClass reference for speed improvements.

Definition at line 65 of file Grammar.h.

◆ root_data_type

int dd4hep::BasicGrammar::root_data_type = -1
mutable

Cached TDataType information for fundamental types.

Definition at line 67 of file Grammar.h.

◆ specialization

struct dd4hep::BasicGrammar::specialization_t dd4hep::BasicGrammar::specialization

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