13 #ifndef DD4HEP_HANDLE_H
14 #define DD4HEP_HANDLE_H
26 #define RAD_2_DEGREE 57.295779513082320876798154814105
29 #define DEGREE_2_RAD 0.0174532925199432957692369076848
39 #define M_PI 3.14159265358979323846
56 return 0xFEEDAFFEDEADFACEULL;
116 bool operator<(const Handle<T>&
e)
const {
141 operator T&()
const {
153 template <
typename Q> Q*
_ptr()
const {
157 template <
typename Q> Q*
data()
const {
161 template <
typename Q> Q&
object()
const {
169 const char*
name()
const;
173 static void bad_assignment(
const std::type_info& from,
const std::type_info& to);
195 void operator()(
const std::pair<typename M::key_type, typename M::mapped_type>& p)
const
221 void operator()(
const std::pair<typename M::key_type, typename M::mapped_type>& p)
const
233 std::string
_toString(
short value,
const char* fmt =
"%d");
235 std::string
_toString(
int value,
const char* fmt =
"%d");
237 std::string
_toString(
float value,
const char* fmt =
"%.17e");
239 std::string
_toString(
double value,
const char* fmt =
"%.17e");
241 std::string
_ptrToString(
const void* p,
const char* fmt =
"%p");
243 template <
typename T> std::string
_toString(
const T* p,
const char* fmt =
"%p")
247 bool _toBool(
const std::string& value);
249 short _toShort(
const std::string& value);
251 int _toInt(
const std::string& value);
253 long _toLong(
const std::string& value);
255 float _toFloat(
const std::string& value);
257 double _toDouble(
const std::string& value);
280 inline unsigned int _toUInt(
unsigned int value) {
284 inline unsigned long _toULong(
unsigned long value) {
297 template <
class T>
T _multiply(
const std::string& left,
T right);
299 template <
class T>
T _multiply(
T left,
const std::string& right);
301 template <
class T>
T _multiply(
const std::string& left,
const std::string& right);
304 template <>
char _multiply<char>(
const std::string& left,
const std::string& right);
308 return left *
_toInt(right);
312 return _toInt(left) * right;
320 return left *
_toInt(right);
324 return _toInt(left) * right;
328 template <>
short _multiply<short>(
const std::string& left,
const std::string& right);
331 return left *
_toInt(right);
335 return _toInt(left) * right;
343 return left *
_toInt(right);
347 return _toInt(left) * right;
351 template <>
int _multiply<int>(
const std::string& left,
const std::string& right);
355 return left *
_toInt(right);
359 return _toInt(left) * right;
367 return left *
_toInt(right);
371 return _toInt(left) * right;
375 template <>
long _multiply<long>(
const std::string& left,
const std::string& right);
399 template <>
float _multiply<float>(
const std::string& left,
const std::string& right);
411 template <>
double _multiply<double>(
const std::string& left,
const std::string& right);
423 void _toDictionary(
const std::string& name,
const std::string& value);
425 void _toDictionary(
const std::string& name,
const std::string& value,
const std::string& typ);
map Functor to release handles
bool operator!() const
Check the validity of the object held by the handle.
Handle(const Handle< Q > &e)
Initializing constructor from unrelated handle with type checking.
void warning_deprecated_xml_factory(const char *name)
Function tp print warning about deprecated factory usage. Used by Plugin mechanism.
void operator()(T p) const
unsigned long _multiply< unsigned long >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
void destroyHandle(T &h)
Helper to delete objects from heap and reset the handle.
bool operator==(const Handle< T > &e) const
Boolean operator == used for RB tree insertions.
long _multiply< long >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
const char * name() const
Access the object name (or "" if not supported by the object)
void deletePtr(T *&p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
bool isValid() const
Check the validity of the object held by the handle.
DestroyHandles(M &m)
Initializing constructor.
Handle< T > & clear()
Release the object held by the handle.
short _toShort(const std::string &value)
String conversions: string to integer value.
T & operator*() const
Access the held object using the * operator.
Q * data() const
Access to an unrelated object type.
Functor to destroy handles and delete the cached object.
std::string _toString(bool value)
String conversions: boolean value to string.
unsigned long _toULong(unsigned long value)
Void helper function to support formalisms.
short _multiply< short >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
unsigned short _multiply< unsigned short >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
Handle()=default
Defaulot constructor.
unsigned char _multiply< unsigned char >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
Handle(Q *e)
Initializing constructor from unrelated pointer with type checking.
T Implementation
Extern accessible definition of the contained element type.
ReleaseHandles(M &m)
Initializing constructor.
T _multiply(const std::string &left, T right)
Generic multiplication using the evaluator: result = left * right.
Handle(T *e)
Initializing constructor from pointer.
unsigned int _toUInt(unsigned int value)
Void helper function to support formalisms.
double _multiply< double >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
map Functor to destroy handles and delete the cached object
T * ptr() const
Access to the held object.
void operator()(const std::pair< typename M::key_type, typename M::mapped_type > &p) const
Action operator.
float _multiply< float >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
Handle< T > & operator=(const Handle< T > &e)=default
Assignment operator.
void releasePtr(T &p)
Helper to delete objects from heap and reset the pointer. Saves many many lines of code...
void verifyObject() const
Verify the object type after a (re-)assignment.
Functor to destroy handles and delete the cached object.
M & object
Container reference.
Q * _ptr() const
Access to an unrelated object type.
void assign(Implementation *n, const std::string &nam, const std::string &title)
Assign a new named object. Note: object references must be managed by the user.
T * access() const
Checked object access. Throws invalid handle runtime exception.
Q & object() const
Access to an unrelated object type.
unsigned short _toUShort(unsigned short value)
Void helper function to support formalisms.
void releaseHandles(M &m)
Functional created of map destruction functors.
bool _toBool(const std::string &value)
String conversions: string to boolean value.
char _multiply< char >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
void releaseHandle(T &h)
Helper to delete objects from heap and reset the handle.
int _multiply< int >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
Handle< NamedObject > Ref_t
Default Ref_t definition describing named objects.
Handle< Implementation > handle_t
Declaration of 'self'.
unsigned int _multiply< unsigned int >(const std::string &left, const std::string &right)
Generic multiplication using the evaluator: result = left * right.
int _toInt(const std::string &value)
String conversions: string to integer value.
double _toDouble(const std::string &value)
String conversions: string to double value.
M & object
Container reference.
void increment_object_validations()
float _toFloat(const std::string &value)
String conversions: string to float value.
T * operator->() const
Access the held object using the -> operator.
std::string _ptrToString(const void *p, const char *fmt="%p")
Pointer to text conversion.
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
long num_object_validations()
void destroyHandles(M &m)
Functional created of map destruction functors.
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...
T * m_element
Single and only data member: Reference to the actual element.
void operator()(const std::pair< typename M::key_type, typename M::mapped_type > &p) const
Action operator.
long _toLong(const std::string &value)
String conversions: string to long integer value.
void operator()(T p) const
bool operator>(const Handle< T > &e) const
Boolean operator > used for RB tree insertions.
static void bad_assignment(const std::type_info &from, const std::type_info &to)
Helper routine called when unrelated types are assigned.
unsigned long long int magic_word()
Access to the magic word, which is protecting some objects against memory corruptions.