 |
DD4hep
1.32.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
13 #ifndef DD4HEP_OPAQUEDATA_H
14 #define DD4HEP_OPAQUEDATA_H
62 std::string
str()
const;
64 const std::type_info&
typeInfo()
const;
72 template <
typename T> T&
get();
74 template <
typename T>
const T&
get()
const;
76 template <
typename T> T&
as();
78 template <
typename T>
const T&
as()
const;
140 template <
typename T,
typename... Args> T&
construct(Args... args);
142 template <
typename T> T&
bind();
144 template <
typename T> T&
bind(
void*
ptr,
size_t len);
146 template <
typename T> T&
bind(
const std::string& value);
148 template <
typename T> T&
bind(
void*
ptr,
size_t len,
const std::string& value);
150 template <
typename T> T&
bind(T&&
data);
171 if ( obj )
return *obj;
173 throw std::bad_cast();
179 const T* obj = (
const T*)(
grammar->
cast().apply_dynCast(Cast::instance<T>(), this->
pointer));
180 if ( obj )
return *obj;
182 throw std::bad_cast();
187 this->
bind(&BasicGrammar::instance<OBJECT>());
188 new(this->
pointer) OBJECT(std::move(obj));
193 this->
bind(&BasicGrammar::instance<T>());
194 return *(
new(this->
pointer) T(std::forward<Args>(args)...));
199 this->
bind(&BasicGrammar::instance<T>());
200 return *(
new(this->
pointer) T());
205 this->
bind(&BasicGrammar::instance<T>());
206 new(this->
pointer) T(std::move(obj));
211 this->
bind(ptr,len,&BasicGrammar::instance<T>());
212 return *(
new(this->
pointer) T());
217 T& ret = this->bind<T>();
218 if ( !value.empty() && !this->fromString(value) ) {
219 throw std::runtime_error(
"OpaqueDataBlock::set> Failed to bind type "+
220 typeName(
typeid(T))+
" to condition data block.");
227 T& ret = this->bind<T>(
ptr, len);
228 if ( !value.empty() && !this->fromString(value) ) {
229 throw std::runtime_error(
"OpaqueDataBlock::set> Failed to bind type "+
230 typeName(
typeid(T))+
" to condition data block.");
240 #endif // DD4HEP_OPAQUEDATA_H
virtual ~OpaqueData()=default
Standard Destructor.
virtual bool equals(const std::type_info &other_type) const =0
Access to the type information.
OpaqueData()=default
Standard initializing constructor.
constexpr static const size_t BUFFER_SIZE
Buffer size of the in-place data buffer.
T & construct(Args... args)
Construct conditions object and bind the data.
unsigned int type
Data buffer type: Must be a bitmap of enum _DataTypes!
OpaqueData(const OpaqueData ©)=default
Copy constructor.
unsigned char data[BUFFER_SIZE]
Data buffer: plain data are allocated directly on this buffer.
Class describing an opaque conditions data block.
bool fromString(const std::string &rep)
No ROOT persistency.
bool is_bound() const
Check if object is already bound....
OpaqueDataBlock()
Standard initializing constructor.
T & as()
Generic getter. Resolves polymorph types. It is mandatory that the datatype is polymorph!
Base class describing string evaluation to C++ objects using boost::spirit.
OpaqueData & operator=(const OpaqueData ©)=default
Assignment operator.
Class describing an opaque data block.
T & get()
Generic getter. Specify the exact type, not a polymorph type.
void * ptr() const
Write access to the data buffer. Is only valid after call to bind<T>()
T & bind()
Bind data value.
const void * ptr() const
Access to the data buffer (read only!). Is only valid after call to bind<T>()
const std::type_info & typeInfo() const
Access type id of the condition.
OpaqueDataBlock & operator=(const OpaqueDataBlock ©)
Assignment operator (Required by ROOT dictionaries)
Namespace for the AIDA detector description toolkit.
virtual const Cast & cast() const
Access ABI object cast.
void bindExtern(void *ptr, const BasicGrammar *grammar)
Bind external data value to the pointer.
const BasicGrammar * grammar
Data type.
const std::string & dataType() const
Access type name of the condition data block.
std::string str() const
Create string representation of the data block.
void * pointer
No ROOT persistency.
~OpaqueDataBlock()
Standard Destructor.