diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h index ed538b79b0a7b1a504b8b6426e9d9b971c0e39dc..2ea2eb462022e5b692748e6b4dd7b2ec75e8c4a3 100644 --- a/DDCore/include/DD4hep/OpaqueData.h +++ b/DDCore/include/DD4hep/OpaqueData.h @@ -13,7 +13,10 @@ #ifndef DD4HEP_OPAQUEDATA_H #define DD4HEP_OPAQUEDATA_H +#include "DD4hep/detail/Grammar.h" + // C/C++ include files +#include <ostream> #include <typeinfo> #include <vector> #include <string> @@ -104,7 +107,6 @@ namespace dd4hep { /// Data buffer type: Must be a bitmap of enum _DataTypes! unsigned int type; - public: /// Standard initializing constructor OpaqueDataBlock(); /// Copy constructor @@ -140,6 +142,50 @@ namespace dd4hep { std::ostream& operator<< (std::ostream& s, const OpaqueDataBlock& data); } /* End namespace dd4hep */ +/// Generic getter. Specify the exact type, not a polymorph type +template <typename T> T& dd4hep::OpaqueData::get() { + if (!grammar || !grammar->equals(typeid(T))) { throw std::bad_cast(); } + return *(T*)pointer; +} + +/// Generic getter (const version). Specify the exact type, not a polymorph type +template <typename T> const T& dd4hep::OpaqueData::get() const { + if (!grammar || !grammar->equals(typeid(T))) { throw std::bad_cast(); } + return *(T*)pointer; +} + +/// Bind data value +template <typename T> T& dd4hep::OpaqueDataBlock::bind() { + this->bind(&BasicGrammar::instance<T>()); + return *(new(this->pointer) T()); +} + +/// Bind data value +template <typename T> T& dd4hep::OpaqueDataBlock::bind(void* ptr, size_t len) { + this->bind(ptr,len,&BasicGrammar::instance<T>()); + return *(new(this->pointer) T()); +} + +/// Bind grammar and assign value +template <typename T> T& dd4hep::OpaqueDataBlock::bind(const std::string& value) { + T& ret = this->bind<T>(); + if ( !value.empty() && !this->fromString(value) ) { + throw std::runtime_error("OpaqueDataBlock::set> Failed to bind type "+ + typeName(typeid(T))+" to condition data block."); + } + return ret; +} + +/// Bind grammar and assign value +template <typename T> T& dd4hep::OpaqueDataBlock::bind(void* ptr, size_t len, const std::string& value) { + T& ret = this->bind<T>(ptr, len); + if ( !value.empty() && !this->fromString(value) ) { + throw std::runtime_error("OpaqueDataBlock::set> Failed to bind type "+ + typeName(typeid(T))+" to condition data block."); + } + return ret; +} + #include "DD4hep/BasicGrammar.h" /// Namespace for the AIDA detector description toolkit diff --git a/DDCore/include/DD4hep/detail/ConditionsInterna.h b/DDCore/include/DD4hep/detail/ConditionsInterna.h index c5764e2cbcc2dc43a9c89b54b3ffb663b910f014..fe948b6a507965abf001ff5f800ccff724a678de 100644 --- a/DDCore/include/DD4hep/detail/ConditionsInterna.h +++ b/DDCore/include/DD4hep/detail/ConditionsInterna.h @@ -26,7 +26,6 @@ #include "DD4hep/Conditions.h" #include "DD4hep/BasicGrammar.h" #include "DD4hep/NamedObject.h" -#include "DD4hep/detail/OpaqueData_inl.h" // C/C++ include files #include <map> @@ -140,53 +139,4 @@ namespace dd4hep { } /* End namespace dd4hep */ -#define DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ - DD4HEP_DEFINE_OPAQUEDATA_TYPE(x) \ - namespace dd4hep { \ - template x& Condition::bind<x>(const std::string& val); \ - template x& Condition::bind<x>(); \ - template x& Condition::get<x>(); \ - template const x& Condition::get<x>() const; \ - } - -#define DD4HEP_DEFINE_CONDITIONS_TYPE_DUMMY(x) \ - namespace dd4hep{namespace Parsers{int parse(x&, const std::string&){return 1;}}} \ - DD4HEP_DEFINE_CONDITIONS_TYPE(x) - -#define DD4HEP_DEFINE_EXTERNAL_CONDITIONS_TYPE(x) \ - namespace dd4hep { \ - template <> x& Condition::bind<x>(const std::string& val); \ - template <> x& Condition::bind<x>(); \ - template <> x& Condition::get<x>(); \ - template <> const x& Condition::get<x>() const; \ - } - -#if defined(DD4HEP_HAVE_ALL_PARSERS) -#define DD4HEP_DEFINE_CONDITIONS_CONT(x) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::vector<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::list<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::set<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::deque<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(dd4hep::detail::Primitive<x>::int_map_t) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(dd4hep::detail::Primitive<x>::ulong_map_t) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(dd4hep::detail::Primitive<x>::string_map_t) - -#define DD4HEP_DEFINE_CONDITIONS_U_CONT(x) \ - DD4HEP_DEFINE_CONDITIONS_CONT(x) \ - DD4HEP_DEFINE_CONDITIONS_CONT(unsigned x) - -#else - -#define DD4HEP_DEFINE_CONDITIONS_CONT(x) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(x) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::vector<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::list<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(std::set<x>) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(dd4hep::detail::Primitive<x>::int_map_t) \ - DD4HEP_DEFINE_CONDITIONS_TYPE(dd4hep::detail::Primitive<x>::string_map_t) - -#define DD4HEP_DEFINE_CONDITIONS_U_CONT(x) DD4HEP_DEFINE_CONDITIONS_CONT(x) - -#endif // DD4HEP_HAVE_ALL_PARSERS #endif /* DD4HEP_DDCORE_CONDITIONINTERNA_H */ diff --git a/DDCore/include/DD4hep/detail/OpaqueData_inl.h b/DDCore/include/DD4hep/detail/OpaqueData_inl.h deleted file mode 100644 index 21397a6f627b5fc5514c612d7d09daa9acdb2d16..0000000000000000000000000000000000000000 --- a/DDCore/include/DD4hep/detail/OpaqueData_inl.h +++ /dev/null @@ -1,84 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -// Author : M.Frank -// -//========================================================================== -// -// NOTE: -// -// This is an internal include file. It should only be included to -// instantiate code. Otherwise the OpaqueData include file should be -// sufficient for all practical purposes. -// -//========================================================================== -#ifndef DD4HEP_OPAQUEDATA_INL_H -#define DD4HEP_OPAQUEDATA_INL_H - -// Framework include files -#include "DD4hep/Primitives.h" -#include "DD4hep/OpaqueData.h" -#include "DD4hep/BasicGrammar.h" - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - /// Generic getter. Specify the exact type, not a polymorph type - template <typename T> T& OpaqueData::get() { - if (!grammar || !grammar->equals(typeid(T))) { throw std::bad_cast(); } - return *(T*)pointer; - } - - /// Generic getter (const version). Specify the exact type, not a polymorph type - template <typename T> const T& OpaqueData::get() const { - if (!grammar || !grammar->equals(typeid(T))) { throw std::bad_cast(); } - return *(T*)pointer; - } - - /// Bind data value - template <typename T> T& OpaqueDataBlock::bind() { - this->bind(&BasicGrammar::instance<T>()); - return *(new(this->pointer) T()); - } - - /// Bind data value - template <typename T> T& OpaqueDataBlock::bind(void* ptr, size_t len) { - this->bind(ptr,len,&BasicGrammar::instance<T>()); - return *(new(this->pointer) T()); - } - - /// Bind grammar and assign value - template <typename T> T& OpaqueDataBlock::bind(const std::string& value) { - T& ret = this->bind<T>(); - if ( !value.empty() && !this->fromString(value) ) { - throw std::runtime_error("OpaqueDataBlock::set> Failed to bind type "+ - typeName(typeid(T))+" to condition data block."); - } - return ret; - } - - /// Bind grammar and assign value - template <typename T> T& OpaqueDataBlock::bind(void* ptr, size_t len, const std::string& value) { - T& ret = this->bind<T>(ptr, len); - if ( !value.empty() && !this->fromString(value) ) { - throw std::runtime_error("OpaqueDataBlock::set> Failed to bind type "+ - typeName(typeid(T))+" to condition data block."); - } - return ret; - } - -} /* End namespace dd4hep */ - -#define DD4HEP_DEFINE_OPAQUEDATA_TYPE(x) \ - namespace dd4hep { \ - template x& OpaqueDataBlock::bind<x>(); \ - template x& OpaqueDataBlock::bind<x>(const std::string& val); \ - } - -#endif /* DD4HEP_OPAQUEDATA_INL_H */ diff --git a/DDCore/src/AlignmentData.cpp b/DDCore/src/AlignmentData.cpp index 57fa9b16565a29815c3c22dc5a10de9145c70184..f1162a52354022ffb2773944de2de697cce691f5 100644 --- a/DDCore/src/AlignmentData.cpp +++ b/DDCore/src/AlignmentData.cpp @@ -246,7 +246,3 @@ DD4HEP_DEFINE_PARSER_GRAMMAR(Delta,eval_none<Delta>) DD4HEP_DEFINE_PARSER_GRAMMAR(DeltaMap,eval_none<DeltaMap>) DD4HEP_DEFINE_PARSER_GRAMMAR(AlignmentData,eval_none<AlignmentData>) -DD4HEP_DEFINE_CONDITIONS_TYPE(Delta) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeltaMap) -DD4HEP_DEFINE_CONDITIONS_TYPE(AlignmentData) - diff --git a/DDCore/src/AlignmentsCalculator.cpp b/DDCore/src/AlignmentsCalculator.cpp index 90f44e11b07a768aa5b9ec6c48f26a90e7e5ee6e..c6ac6762cefded47b6c20bc71eb1ec526fdcb64e 100644 --- a/DDCore/src/AlignmentsCalculator.cpp +++ b/DDCore/src/AlignmentsCalculator.cpp @@ -331,4 +331,3 @@ DD4HEP_DEFINE_PARSER_DUMMY(OrderedMap) #include "DD4hep/detail/BasicGrammar_inl.h" #include "DD4hep/detail/ConditionsInterna.h" DD4HEP_DEFINE_PARSER_GRAMMAR(OrderedMap,eval_none<OrderedMap>) -DD4HEP_DEFINE_CONDITIONS_TYPE(OrderedMap) diff --git a/DDCore/src/AlignmentsInterna.cpp b/DDCore/src/AlignmentsInterna.cpp index 6f777e159054f10ad692d481798df0b82303359d..fb1b917f8467dbd70ff4890c66ca43f6ad0fbf53 100644 --- a/DDCore/src/AlignmentsInterna.cpp +++ b/DDCore/src/AlignmentsInterna.cpp @@ -81,5 +81,4 @@ namespace dd4hep { } } DD4HEP_DEFINE_PARSER_GRAMMAR(AlignmentObject,eval_none<AlignmentObject>) -DD4HEP_DEFINE_CONDITIONS_TYPE(AlignmentObject) diff --git a/DDCore/src/ConditionsData.cpp b/DDCore/src/ConditionsData.cpp index 507e90407618d503f6ee84ccf998c33d21c29563..6620ba83250bf25af8fe8cad0d77ed2ac3bef07c 100644 --- a/DDCore/src/ConditionsData.cpp +++ b/DDCore/src/ConditionsData.cpp @@ -82,4 +82,3 @@ DD4HEP_DEFINE_PARSER_DUMMY(AbstractMap) #include "DD4hep/detail/BasicGrammar_inl.h" #include "DD4hep/detail/ConditionsInterna.h" DD4HEP_DEFINE_PARSER_GRAMMAR(AbstractMap,eval_none<AbstractMap>) -DD4HEP_DEFINE_CONDITIONS_TYPE(AbstractMap) diff --git a/DDCore/src/ConditonsTypes.cpp b/DDCore/src/ConditonsTypes.cpp deleted file mode 100644 index 9187fe96ebc08e99ffbad690771782161036c6df..0000000000000000000000000000000000000000 --- a/DDCore/src/ConditonsTypes.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -// Author : M.Frank -// -//========================================================================== - -// Framework include files -#include "DD4hep/Primitives.h" -#include "DD4hep/detail/ConditionsInterna.h" -#include "DD4hep/detail/ComponentProperties_inl.h" - -#include "Math/Point3D.h" -#include "Math/Vector3D.h" -#include "Math/Vector4D.h" - -// C/C++ include files -#include <string> -#include <vector> -#include <list> -#include <set> -#include <map> -#include <deque> - -#if defined(DD4HEP_HAVE_ALL_PARSERS) -DD4HEP_DEFINE_CONDITIONS_U_CONT(char) -DD4HEP_DEFINE_CONDITIONS_U_CONT(short) -DD4HEP_DEFINE_CONDITIONS_U_CONT(long long) -#endif // DD4HEP_HAVE_ALL_PARSERS - -DD4HEP_DEFINE_CONDITIONS_U_CONT(int) -DD4HEP_DEFINE_CONDITIONS_U_CONT(long) - -DD4HEP_DEFINE_CONDITIONS_CONT(bool) -DD4HEP_DEFINE_CONDITIONS_CONT(float) -DD4HEP_DEFINE_CONDITIONS_CONT(double) -DD4HEP_DEFINE_CONDITIONS_CONT(std::string) - -// ROOT::Math Object instances -DD4HEP_DEFINE_CONDITIONS_CONT(ROOT::Math::XYZPoint) -DD4HEP_DEFINE_CONDITIONS_CONT(ROOT::Math::XYZVector) -DD4HEP_DEFINE_CONDITIONS_CONT(ROOT::Math::PxPyPzEVector) diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp index 97368d273fc4f3b0859c7a84549675ce6328c969..fc70b7276d0610505546e2bd6d852e167fe90f24 100644 --- a/DDCore/src/OpaqueData.cpp +++ b/DDCore/src/OpaqueData.cpp @@ -16,7 +16,6 @@ #include "DD4hep/Primitives.h" #include "DD4hep/OpaqueData.h" #include "DD4hep/InstanceCount.h" -#include "DD4hep/detail/OpaqueData_inl.h" // C/C++ header files #include <cstring> @@ -207,5 +206,4 @@ DD4HEP_DEFINE_PARSER_DUMMY(OpaqueDataBlock) #include "DD4hep/detail/BasicGrammar_inl.h" #include "DD4hep/detail/ConditionsInterna.h" DD4HEP_DEFINE_PARSER_GRAMMAR(OpaqueDataBlock,eval_none<OpaqueDataBlock>) -DD4HEP_DEFINE_CONDITIONS_TYPE(OpaqueDataBlock) diff --git a/DDCore/src/OpaqueDataBinder.cpp b/DDCore/src/OpaqueDataBinder.cpp index 7d30173f5688f9740e4104b75cec9a74127eedb4..e509f146b6c4d5615a66ebe658a518929eea82ca 100644 --- a/DDCore/src/OpaqueDataBinder.cpp +++ b/DDCore/src/OpaqueDataBinder.cpp @@ -14,7 +14,7 @@ // Framework include files #include "DD4hep/OpaqueDataBinder.h" #include "DD4hep/Conditions.h" -#include "DD4hep/detail/OpaqueData_inl.h" +#include "DD4hep/OpaqueData.h" #include "DD4hep/detail/ConditionsInterna.h" // C/C++ include files diff --git a/DDCore/src/XML/XMLParsers.cpp b/DDCore/src/XML/XMLParsers.cpp index f3228de0fdecc8a1f477deb4cf67464f05a46b57..321c19e2945d03aa25275f23046f7eab10919f0e 100644 --- a/DDCore/src/XML/XMLParsers.cpp +++ b/DDCore/src/XML/XMLParsers.cpp @@ -16,6 +16,7 @@ // Framework include files #include "DD4hep/Objects.h" +#include "DD4hep/Conditions.h" #include "DD4hep/Printout.h" #include "DD4hep/OpaqueData.h" #include "DD4hep/OpaqueDataBinder.h" diff --git a/examples/DDDB/src/Detector/DeHandles.cpp b/examples/DDDB/src/Detector/DeHandles.cpp index a0d7dc3fa8c0f1a986ad771859a70e71baa18815..ae8f7cf6d85e80b48941391510096fd7a10ec93b 100644 --- a/examples/DDDB/src/Detector/DeHandles.cpp +++ b/examples/DDDB/src/Detector/DeHandles.cpp @@ -60,10 +60,4 @@ DD4HEP_DEFINE_PARSER_GRAMMAR(DeVPObject,eval_none<DeVPObject>) DD4HEP_DEFINE_PARSER_GRAMMAR(DeVPSensorObject,eval_none<DeVPSensorObject>) DD4HEP_DEFINE_PARSER_GRAMMAR(DeVPGenericObject,eval_none<DeVPGenericObject>) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeVPStaticObject) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeVPSensorStaticObject) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeVPGenericStaticObject) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeVPObject) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeVPSensorObject) -DD4HEP_DEFINE_CONDITIONS_TYPE(DeVPGenericObject) #endif