|
DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
13 #ifndef DD4HEP_HANDLE_H
14 #define DD4HEP_HANDLE_H
22 #include <type_traits>
26 #define RAD_2_DEGREE 57.295779513082320876798154814105
29 #define DEGREE_2_RAD 0.0174532925199432957692369076848
33 #define M_PI 3.14159265358979323846
54 return 0xFEEDAFFEDEADFACEULL;
105 :
m_element(element ? detail::safe_cast<T>::cast(element) : 0)
145 operator T&()
const {
157 template <
typename Q> Q*
_ptr()
const {
161 template <
typename Q> Q*
data()
const {
165 template <
typename Q> Q&
object()
const {
175 void assign(
Object* n,
const std::string& nam,
const std::string& title);
179 static void bad_assignment(
const std::type_info& from,
const std::type_info& to);
186 deletePtr(
handle.m_element);
201 void operator()(
const std::pair<typename M::key_type, typename M::mapped_type>& arg)
const
212 releasePtr(
handle.m_element);
227 void operator()(
const std::pair<typename M::key_type, typename M::mapped_type>& arg)
const
243 std::string
_toString(
short value,
const char* fmt =
"%d");
245 std::string
_toString(
int value,
const char* fmt =
"%d");
247 std::string
_toString(
unsigned long value,
const char* fmt =
"%ld");
249 std::string
_toString(
float value,
const char* fmt =
"%.17e");
251 std::string
_toString(
double value,
const char* fmt =
"%.17e");
253 std::string
_ptrToString(
const void* p,
const char* fmt =
"%p");
255 template <
typename T> std::string
_toString(
const T* p,
const char* fmt =
"%p")
259 template <
typename T> T
_toType(
const std::string& value);
262 bool _toBool(
const std::string& value);
264 short _toShort(
const std::string& value);
266 int _toInt(
const std::string& value);
268 long _toLong(
const std::string& value);
270 unsigned short _toUShort(
const std::string& value);
272 unsigned int _toUInt(
const std::string& value);
274 unsigned long _toULong(
const std::string& value);
276 float _toFloat(
const std::string& value);
278 double _toDouble(
const std::string& value);
301 inline unsigned int _toUInt(
unsigned int value) {
305 inline unsigned long _toULong(
unsigned long value) {
318 template <
class T> T
_multiply(
const std::string& left, T right);
320 template <
class T> T
_multiply(T left,
const std::string& right);
322 template <
class T> T
_multiply(
const std::string& left,
const std::string& right);
325 template <>
char _multiply<char>(
const std::string& left,
const std::string& right);
329 return left *
_toInt(right);
333 return _toInt(left) * right;
341 return left *
_toInt(right);
345 return _toInt(left) * right;
349 template <>
short _multiply<short>(
const std::string& left,
const std::string& right);
352 return left *
_toInt(right);
356 return _toInt(left) * right;
364 return left *
_toInt(right);
368 return _toInt(left) * right;
372 template <>
int _multiply<int>(
const std::string& left,
const std::string& right);
376 return left *
_toInt(right);
380 return _toInt(left) * right;
388 return left *
_toInt(right);
392 return _toInt(left) * right;
396 template <>
long _multiply<long>(
const std::string& left,
const std::string& right);
420 template <>
float _multiply<float>(
const std::string& left,
const std::string& right);
432 template <>
double _multiply<double>(
const std::string& left,
const std::string& right);
444 void _toDictionary(
const std::string& name,
const std::string& value);
446 void _toDictionary(
const std::string& name,
const std::string& value,
const std::string& typ);
457 #endif // DD4HEP_HANDLE_H
bool set_allow_variable_redefine(bool value)
Steer redefinition of variable re-definition during expression evaluation. returns old value.
void releaseHandles(M &arg)
Functional created of map destruction functors.
short _toShort(const std::string &value)
String conversions: string to short value.
bool _toBool(const std::string &value)
String conversions: string to boolean value.
void warning_deprecated_xml_factory(const char *name)
Function tp print warning about deprecated factory usage. Used by Plugin mechanism.
DestroyHandles(M &obj)
Initializing constructor.
void increment_object_validations()
void destroyHandle(T &handle)
Helper to delete objects from heap and reset the handle.
M & object
Container reference.
map Functor to release handles
T Object
Extern accessible definition of the contained element type.
bool operator>(const Handle< T > &element) const
Boolean operator > used for RB tree insertions.
Q & object() const
Access to an unrelated object type.
void _toDictionary(const std::string &name, const std::string &value)
Enter name value pair to the dictionary. "value" must be a numerical expression, which is evaluated.
bool operator!() const
Check the validity of the object held by the handle.
unsigned int _multiply< unsigned int >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
Handle< T > & operator=(Handle< T > &&element)=default
Assignment move operator.
bool operator<(const Handle< T > &element) const
Boolean operator < used for RB tree insertions.
Handle(const Handle< T > &element)=default
Copy constructor.
bool isValid() const
Check the validity of the object held by the handle.
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
std::string _toString(bool value)
String conversions: boolean value to string.
short _multiply< short >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
unsigned long long int magic_word()
Access to the magic word, which is protecting some objects against memory corruptions.
int _toInt(const std::string &value)
String conversions: string to integer value.
unsigned long _multiply< unsigned long >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
void operator()(const std::pair< typename M::key_type, typename M::mapped_type > &arg) const
Action operator.
const char * name() const
Access the object name (or "" if not supported by the object)
int _multiply< int >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
unsigned long _toULong(const std::string &value)
String conversions: string to long integer value.
long _toLong(const std::string &value)
String conversions: string to long integer value.
Handle(const Handle< Q > &element)
Initializing constructor from unrelated handle with type checking.
T & operator*() const
Access the held object using the * operator.
unsigned short _toUShort(const std::string &value)
String conversions: string to unsigned short value.
Handle< T > & clear()
Release the object held by the handle.
float _multiply< float >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
std::string remove_whitespace(const std::string &v)
String manipulations: Remove unconditionally all white spaces.
T * operator->() const
Access the held object using the -> operator.
static void bad_assignment(const std::type_info &from, const std::type_info &to)
Helper routine called when unrelated types are assigned.
Handle()=default
Default constructor.
Handle(Q *element)
Initializing constructor from unrelated pointer with type checking.
void assign(Object *n, const std::string &nam, const std::string &title)
Assign a new named object. Note: object references must be managed by the user.
Q * data() const
Access to an unrelated object type.
unsigned short _multiply< unsigned short >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
unsigned char _multiply< unsigned char >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
long _multiply< long >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
void destroyHandles(M &arg)
Functional created of map destruction functors.
void operator()(T handle) const
void releaseHandle(T &handle)
Helper to delete objects from heap and reset the handle.
std::string _ptrToString(const void *p, const char *fmt="%p")
Pointer to text conversion.
map Functor to destroy handles and delete the cached object
T * m_element
Single and only data member: Reference to the actual element.
Q * _ptr() const
Access to an unrelated object type.
bool operator==(const Handle< T > &element) const
Boolean operator == used for RB tree insertions.
long num_object_validations()
char _multiply< char >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
void destroy()
Destroy the underlying object (be careful here: things are not reference counted)!
Handle(T *element)
Initializing constructor from pointer.
Handle< T > Base
Self type: used by sub-classes.
void operator()(T ptr) const
Functor to destroy handles and delete the cached object.
Handle< NamedObject > Ref_t
Default Ref_t definition describing named objects.
M & object
Container reference.
float _toFloat(const std::string &value)
String conversions: string to float value.
double _toDouble(const std::string &value)
String conversions: string to double value.
T _multiply(const std::string &left, T right)
Generic multiplication using the evaluator: result = left * right.
Handle< T > & operator=(const Handle< T > &element)=default
Assignment copy operator.
T * access() const
Checked object access. Throws invalid handle runtime exception if invalid handle.
T * ptr() const
Access to the held object.
double _multiply< double >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
Namespace for the AIDA detector description toolkit.
T _toType(const std::string &value)
Generic type conversion from string to primitive value.
Functor to destroy handles and delete the cached object.
ReleaseHandles(M &obj)
Initializing constructor.
void operator()(const std::pair< typename M::key_type, typename M::mapped_type > &arg) const
Action operator.
void handle(const O *o, const C &c, F pmf)
unsigned int _toUInt(const std::string &value)
String conversions: string to unsigned integer value.
Handle(Handle< T > &&element)=default
Copy constructor.