DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpaqueData.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_OPAQUEDATA_H
14 #define DD4HEP_OPAQUEDATA_H
15 
16 // C/C++ include files
17 #include <typeinfo>
18 #include <vector>
19 #include <string>
20 
22 namespace DD4hep {
23 
24  // Forward declarations
25  class BasicGrammar;
26 
28 
36  class OpaqueData {
37  private:
38  protected:
40  OpaqueData();
42  virtual ~OpaqueData();
44  OpaqueData(const OpaqueData& c);
46  OpaqueData& operator=(const OpaqueData& c);
47 
48  public:
51 
52  protected:
54  void* pointer;
55 
56  public:
58  bool fromString(const std::string& rep);
60  std::string str() const;
62  const std::type_info& typeInfo() const;
64  const std::string& dataType() const;
66  bool is_bound() const { return 0 != pointer; }
68  template <typename T> T& get();
70  template <typename T> const T& get() const;
71  };
72 
73 
75 
81  class OpaqueDataBlock : public OpaqueData {
82 
83  protected:
84  enum {
85  PLAIN_DATA = 1<<0,
86  ALLOC_DATA = 1<<1,
87  BOUND_DATA = 1<<2
88  } _DataTypes;
90 
91  unsigned char data[sizeof(std::vector<void*>)];
93  void (*destruct)(void*);
95  void (*copy)(void*,const void*);
96 
97  public:
99  unsigned int type;
101  OpaqueDataBlock();
109  bool move(OpaqueDataBlock& from);
111  bool bind(const BasicGrammar* grammar,
112  void (*ctor)(void*,const void*),
113  void (*dtor)(void*));
115  template <typename T> T& bind();
117  template <typename T> T& bind(const std::string& value);
119  void assign(const void* ptr,const std::type_info& typ);
121  template<typename T> T& set(const std::string& value);
122  };
123 
124 } /* End namespace DD4hep */
125 #endif /* DD4HEP_OPAQUEDATA_H */
Class describing an opaque conditions data block.
Definition: OpaqueData.h:81
OpaqueDataBlock & operator=(const OpaqueDataBlock &clone)
Assignment operator.
Definition: OpaqueData.cpp:125
enum DD4hep::OpaqueDataBlock::@4 _DataTypes
T & set(const std::string &value)
Bind grammar and assign value.
Base class describing string evaluation to C++ objects using boost::spirit.
Definition: BasicGrammar.h:37
Class describing an opaque data block.
Definition: OpaqueData.h:36
OpaqueDataBlock()
Standard initializing constructor.
Definition: OpaqueData.cpp:82
void(* copy)(void *, const void *)
Constructor function – only set if the object is valid.
Definition: OpaqueData.h:95
std::string str() const
Create string representation of the data block.
Definition: OpaqueData.cpp:58
bool move(OpaqueDataBlock &from)
Move the data content: 'from' will be reset to NULL.
Definition: OpaqueData.cpp:108
virtual ~OpaqueData()
Standard Destructor.
Definition: OpaqueData.cpp:37
OpaqueData()
Standard initializing constructor.
Definition: OpaqueData.cpp:29
bool is_bound() const
Check if object is already bound....
Definition: OpaqueData.h:66
bool fromString(const std::string &rep)
Create data block from string representation.
Definition: OpaqueData.cpp:50
const std::string & dataType() const
Access type name of the condition data block.
Definition: OpaqueData.cpp:74
void * pointer
Pointer to object data.
Definition: OpaqueData.h:54
unsigned char data[sizeof(std::vector< void * >)]
Data buffer: plain data are allocated directly on this buffer.
Definition: OpaqueData.h:91
void assign(const void *ptr, const std::type_info &typ)
Set data value.
Definition: OpaqueData.cpp:172
const BasicGrammar * grammar
Data type.
Definition: OpaqueData.h:50
T & bind()
Bind data value.
OpaqueData & operator=(const OpaqueData &c)
Assignment operator.
Definition: OpaqueData.cpp:41
const std::type_info & typeInfo() const
Access type id of the condition.
Definition: OpaqueData.cpp:66
~OpaqueDataBlock()
Standard Destructor.
Definition: OpaqueData.cpp:97
unsigned int type
Data buffer type: Must be a bitmap!
Definition: OpaqueData.h:99
void(* destruct)(void *)
Destructor function – only set if the object is valid.
Definition: OpaqueData.h:93