From ada85c4438c243f21a05aeaaf86651f5222477b4 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Mon, 5 Feb 2018 22:23:13 +0100 Subject: [PATCH] Restructure DD4hep parsers and spirit utilities --- DDCMS/src/plugins/DDDefinitions2Objects.cpp | 13 +- DDCore/CMakeLists.txt | 7 +- DDCore/include/DD4hep/BasicGrammar.h | 3 + DDCore/include/DD4hep/ComponentProperties.h | 5 + DDCore/include/DD4hep/DD4hepUnits.h | 2 +- DDCore/include/DD4hep/Exceptions.h | 43 +- DDCore/include/DD4hep/Plugins.h | 3 + DDCore/include/DD4hep/Primitives.h | 625 +---------------- DDCore/include/DD4hep/Printout.h | 313 +-------- DDCore/include/DD4hep/config.h | 19 +- .../include/DD4hep/detail/BasicGrammar_inl.h | 10 +- DDCore/include/JSON/ChildValue.h | 2 +- DDCore/include/JSON/ChildValue.inl | 2 +- DDCore/include/JSON/Conversions.h | 2 +- DDCore/include/JSON/Detector.h | 2 +- DDCore/include/JSON/Dimension.h | 2 +- DDCore/include/JSON/Dimension.inl | 2 +- DDCore/include/JSON/Evaluator.h | 2 +- DDCore/include/JSON/Printout.h | 8 +- DDCore/include/JSON/config.h | 2 + DDCore/include/Parsers/Exceptions.h | 55 ++ DDCore/include/Parsers/Primitives.h | 630 ++++++++++++++++++ DDCore/include/Parsers/Printout.h | 319 +++++++++ .../{XML => Parsers}/detail/ChildValue.h | 0 .../{XML => Parsers}/detail/ChildValue.imp | 0 .../{XML => Parsers}/detail/ChildValue.inl | 0 .../{XML => Parsers}/detail/Conversions.h | 5 +- .../{XML => Parsers}/detail/Detector.h | 0 .../{XML => Parsers}/detail/Detector.imp | 0 .../{XML => Parsers}/detail/Dimension.h | 0 .../{XML => Parsers}/detail/Dimension.imp | 0 .../{XML => Parsers}/detail/Dimension.inl | 0 .../{XML => Parsers}/detail/README.txt | 4 +- DDCore/include/XML/Conversions.h | 2 +- DDCore/include/XML/Evaluator.h | 24 + DDCore/include/XML/Printout.h | 10 +- DDCore/include/XML/XMLChildValue.h | 2 +- DDCore/include/XML/XMLChildValue.inl | 2 +- DDCore/include/XML/XMLDetector.h | 2 +- DDCore/include/XML/XMLDimension.h | 2 +- DDCore/include/XML/XMLDimension.inl | 2 +- DDCore/include/XML/XMLElements.h | 1 - DDCore/include/XML/config.h | 4 +- DDCore/src/AlignmentData.cpp | 3 +- DDCore/src/AlignmentsInterna.cpp | 3 +- DDCore/src/AlignmentsPrinter.cpp | 2 +- DDCore/src/ConditionsData.cpp | 3 +- DDCore/src/ConditionsPrinter.cpp | 2 +- DDCore/src/Handle.cpp | 2 +- DDCore/src/JSON/Detector.cpp | 23 + DDCore/src/JSON/Elements.cpp | 1 - DDCore/src/JSON/Helpers.cpp | 6 +- DDCore/src/OpaqueData.cpp | 4 +- DDCore/src/Parsers/Exceptions.cpp | 29 + DDCore/src/Parsers/Primitives.cpp | 531 +++++++++++++++ DDCore/src/Parsers/Printout.cpp | 414 ++++++++++++ DDCore/src/RootDictionary.h | 2 +- DDCore/src/XML/Detector.cpp | 23 + DDCore/src/XML/Layering.cpp | 3 +- DDCore/src/XML/Utilities.cpp | 2 + DDCore/src/XML/XMLElements.cpp | 2 +- DDCore/src/XML/XMLHelpers.cpp | 6 +- DDCore/src/XML/XMLParsers.cpp | 3 + DDG4/CMakeLists.txt | 1 + DDG4/include/DDG4/Geant4InputAction.h | 24 +- DDParsers/CMakeLists.txt | 10 +- .../{DDParsers => Evaluator}/DD4hepUnits.h | 0 .../{DDParsers => Evaluator}/Evaluator.h | 0 DDParsers/include/Parsers/Parsers.h | 24 + DDParsers/include/Parsers/config.h | 22 + .../Parsers/spirit}/GrammarsV2.h | 0 .../{DDParsers => Parsers/spirit}/Parsers.h | 1 + .../Parsers/spirit}/ParsersFactory.h | 5 +- .../spirit}/ParsersStandardListCommon.h | 7 +- .../spirit}/ParsersStandardMiscCommon.h | 4 +- .../{DDParsers => Parsers/spirit}/ToStream.h | 1 + .../Parsers/spirit}/UsedParser.h | 11 +- DDParsers/src/Evaluator/Evaluator.cpp | 2 +- .../src/Evaluator/ExpressionEvaluator.cpp | 7 +- DDParsers/src/Evaluator/setStdMath.cpp | 4 +- DDParsers/src/Evaluator/setSystemOfUnits.cpp | 2 +- DDParsers/src/ParsersDictionary.h | 19 + .../src/{parsers => Spirit}/Evaluators.cpp | 7 +- DDParsers/src/Spirit/ExtraParsers.cpp | 31 + .../ParserStandardList_Mapint_bool.cpp | 2 +- .../ParserStandardList_Mapint_double.cpp | 2 +- .../ParserStandardList_Mapint_float.cpp | 2 +- .../ParserStandardList_Mapint_int.cpp | 2 +- .../ParserStandardList_Mapint_long.cpp | 2 +- .../ParserStandardList_Mapint_string.cpp | 2 +- .../ParserStandardList_Mapped_bool.cpp | 2 +- .../ParserStandardList_Mapped_double.cpp | 2 +- .../ParserStandardList_Mapped_float.cpp | 2 +- .../ParserStandardList_Mapped_int.cpp | 2 +- .../ParserStandardList_Mapped_long.cpp | 3 +- .../ParserStandardList_Mapped_string.cpp | 2 +- .../ParserStandardList_Mapstring_bool.cpp | 2 +- .../ParserStandardList_Mapstring_double.cpp | 2 +- .../ParserStandardList_Mapstring_float.cpp | 2 +- .../ParserStandardList_Mapstring_int.cpp | 2 +- .../ParserStandardList_Mapstring_long.cpp | 2 +- .../ParserStandardList_Mapstring_string.cpp | 2 +- .../ParserStandardList_list_bool.cpp | 2 +- .../ParserStandardList_list_double.cpp | 2 +- .../ParserStandardList_list_float.cpp | 2 +- .../ParserStandardList_list_int.cpp | 2 +- .../ParserStandardList_list_long.cpp | 2 +- .../ParserStandardList_list_string.cpp | 2 +- .../ParserStandardList_set_bool.cpp | 2 +- .../ParserStandardList_set_double.cpp | 2 +- .../ParserStandardList_set_float.cpp | 2 +- .../ParserStandardList_set_int.cpp | 2 +- .../ParserStandardList_set_long.cpp | 2 +- .../ParserStandardList_set_string.cpp | 2 +- .../ParserStandardList_vector_bool.cpp | 2 +- .../ParserStandardList_vector_double.cpp | 2 +- .../ParserStandardList_vector_float.cpp | 2 +- .../ParserStandardList_vector_int.cpp | 2 +- .../ParserStandardList_vector_long.cpp | 2 +- .../ParserStandardList_vector_string.cpp | 2 +- .../ParsersObjects_PxPyPzEVector.cpp | 2 +- .../ParsersObjects_XYZPoint.cpp | 2 +- .../ParsersObjects_XYZVector.cpp | 2 +- .../ParsersStandardMisc1.cpp | 2 +- .../ParsersStandardMisc2.cpp | 2 +- .../ParsersStandardMisc3.cpp | 2 +- .../ParsersStandardMisc4.cpp | 2 +- .../ParsersStandardMisc5.cpp | 2 +- .../ParsersStandardSingle.cpp | 2 +- DDParsers/src/{ => Spirit}/ToStream.cpp | 2 +- 130 files changed, 2356 insertions(+), 1114 deletions(-) create mode 100644 DDCore/include/Parsers/Exceptions.h create mode 100644 DDCore/include/Parsers/Primitives.h create mode 100644 DDCore/include/Parsers/Printout.h rename DDCore/include/{XML => Parsers}/detail/ChildValue.h (100%) rename DDCore/include/{XML => Parsers}/detail/ChildValue.imp (100%) rename DDCore/include/{XML => Parsers}/detail/ChildValue.inl (100%) rename DDCore/include/{XML => Parsers}/detail/Conversions.h (98%) rename DDCore/include/{XML => Parsers}/detail/Detector.h (100%) rename DDCore/include/{XML => Parsers}/detail/Detector.imp (100%) rename DDCore/include/{XML => Parsers}/detail/Dimension.h (100%) rename DDCore/include/{XML => Parsers}/detail/Dimension.imp (100%) rename DDCore/include/{XML => Parsers}/detail/Dimension.inl (100%) rename DDCore/include/{XML => Parsers}/detail/README.txt (97%) create mode 100644 DDCore/include/XML/Evaluator.h create mode 100644 DDCore/src/JSON/Detector.cpp create mode 100755 DDCore/src/Parsers/Exceptions.cpp create mode 100755 DDCore/src/Parsers/Primitives.cpp create mode 100755 DDCore/src/Parsers/Printout.cpp create mode 100644 DDCore/src/XML/Detector.cpp rename DDParsers/include/{DDParsers => Evaluator}/DD4hepUnits.h (100%) rename DDParsers/include/{DDParsers => Evaluator}/Evaluator.h (100%) create mode 100644 DDParsers/include/Parsers/Parsers.h create mode 100644 DDParsers/include/Parsers/config.h rename DDParsers/{src/parsers => include/Parsers/spirit}/GrammarsV2.h (100%) mode change 100644 => 100755 rename DDParsers/include/{DDParsers => Parsers/spirit}/Parsers.h (99%) mode change 100644 => 100755 rename DDParsers/{src/parsers => include/Parsers/spirit}/ParsersFactory.h (97%) rename DDParsers/{src/parsers => include/Parsers/spirit}/ParsersStandardListCommon.h (95%) mode change 100644 => 100755 rename DDParsers/{src/parsers => include/Parsers/spirit}/ParsersStandardMiscCommon.h (90%) mode change 100644 => 100755 rename DDParsers/include/{DDParsers => Parsers/spirit}/ToStream.h (99%) rename DDParsers/{src/parsers => include/Parsers/spirit}/UsedParser.h (76%) mode change 100644 => 100755 create mode 100644 DDParsers/src/ParsersDictionary.h rename DDParsers/src/{parsers => Spirit}/Evaluators.cpp (94%) mode change 100644 => 100755 create mode 100755 DDParsers/src/Spirit/ExtraParsers.cpp rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapint_bool.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapint_double.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapint_float.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapint_int.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapint_long.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapint_string.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapped_bool.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapped_double.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapped_float.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapped_int.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapped_long.cpp (75%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapped_string.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapstring_bool.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapstring_double.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapstring_float.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapstring_int.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapstring_long.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_Mapstring_string.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_list_bool.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_list_double.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_list_float.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_list_int.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_list_long.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_list_string.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_set_bool.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_set_double.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_set_float.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_set_int.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_set_long.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_set_string.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_vector_bool.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_vector_double.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_vector_float.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_vector_int.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_vector_long.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParserStandardList_vector_string.cpp (91%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersObjects_PxPyPzEVector.cpp (97%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersObjects_XYZPoint.cpp (97%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersObjects_XYZVector.cpp (97%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersStandardMisc1.cpp (95%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersStandardMisc2.cpp (92%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersStandardMisc3.cpp (92%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersStandardMisc4.cpp (93%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersStandardMisc5.cpp (96%) mode change 100644 => 100755 rename DDParsers/src/{parsers => Spirit}/ParsersStandardSingle.cpp (96%) mode change 100644 => 100755 rename DDParsers/src/{ => Spirit}/ToStream.cpp (98%) mode change 100644 => 100755 diff --git a/DDCMS/src/plugins/DDDefinitions2Objects.cpp b/DDCMS/src/plugins/DDDefinitions2Objects.cpp index a8c4e48b3..7fff4a4b9 100644 --- a/DDCMS/src/plugins/DDDefinitions2Objects.cpp +++ b/DDCMS/src/plugins/DDDefinitions2Objects.cpp @@ -30,6 +30,7 @@ #include "DDCMS/DDCMS.h" // Root/TGeo include files +#include "TSystem.h" #include "TGeoManager.h" #include "TGeoMaterial.h" @@ -636,10 +637,16 @@ template <> void Converter<box>::operator()(xml_h element) const { /// DD4hep specific Converter for <Include/> tags: process only the constants template <> void Converter<include_load>::operator()(xml_h element) const { - xml::Document doc = xml::DocumentHandler().load(element, element.attr_value(_U(ref))); - string fname = xml::DocumentHandler::system_path(doc.root()); + TString fname = element.attr<string>(_U(ref)).c_str(); + const char* path = gSystem->Getenv("DDCMS_XML_PATH"); + xml::Document doc; + if ( path && gSystem->FindFile(path,fname) ) + doc = xml::DocumentHandler().load(fname.Data()); + else + doc = xml::DocumentHandler().load(element, element.attr_value(_U(ref))); + fname = xml::DocumentHandler::system_path(doc.root()); printout(_param<ParsingContext>()->debug_includes ? ALWAYS : DEBUG, - "DDCMS","+++ Processing the CMS detector description %s",fname.c_str()); + "DDCMS","+++ Processing the CMS detector description %s",fname.Data()); _option<resolve>()->includes.push_back(doc); } diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index be14e7eb0..0f322b261 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -12,16 +12,17 @@ dd4hep_package( DDCore USES [ROOT REQUIRED COMPONENTS Geom GenVector] DDParsers - OPTIONAL XERCESC + #OPTIONAL XERCESC INCLUDE_DIRS include - INSTALL_INCLUDES include/DDSegmentation include/DD4hep include/XML include/JSON) + INSTALL_INCLUDES include/DDSegmentation include/DD4hep include/Parsers include/XML include/JSON) #---Generate ROOT dictionary------------------------------------------------------ dd4hep_add_dictionary( G__DD4hep SOURCES include/ROOT/Warnings.h + include/XML/Helper.h +# include/JSON/Helper.h include/DD4hep/*.h include/DD4hep/detail/*.h - include/XML/*.h src/DetectorImp.h src/RootDictionary.h EXCLUDE include/DD4hep/DetFactoryHelper.h diff --git a/DDCore/include/DD4hep/BasicGrammar.h b/DDCore/include/DD4hep/BasicGrammar.h index 561a4c0cb..b28b1c6fd 100644 --- a/DDCore/include/DD4hep/BasicGrammar.h +++ b/DDCore/include/DD4hep/BasicGrammar.h @@ -13,6 +13,9 @@ #ifndef DD4HEP_DDG4_BASICGRAMMAR_H #define DD4HEP_DDG4_BASICGRAMMAR_H +// Framework include files +#include "DD4hep/config.h" + // C/C++ include files #include <string> #include <typeinfo> diff --git a/DDCore/include/DD4hep/ComponentProperties.h b/DDCore/include/DD4hep/ComponentProperties.h index 1d6587e5f..797f23b10 100644 --- a/DDCore/include/DD4hep/ComponentProperties.h +++ b/DDCore/include/DD4hep/ComponentProperties.h @@ -14,6 +14,7 @@ #define DD4HEP_DDG4_COMPONENTPROPERTIES_H // Framework include files +#include "DD4hep/config.h" // C/C++ include files #include <algorithm> @@ -205,6 +206,10 @@ namespace dd4hep { size_t size() const; /// Check for existence bool exists(const std::string& name) const; + /// Access to the property container + Properties& properties() { return m_properties; } + /// Access to the property container + const Properties& properties() const { return m_properties; } /// Access property by name (CONST) const Property& property(const std::string& name) const; /// Access property by name diff --git a/DDCore/include/DD4hep/DD4hepUnits.h b/DDCore/include/DD4hep/DD4hepUnits.h index a89869a53..53258ca2c 100644 --- a/DDCore/include/DD4hep/DD4hepUnits.h +++ b/DDCore/include/DD4hep/DD4hepUnits.h @@ -1 +1 @@ -#include "DDParsers/DD4hepUnits.h" +#include "Evaluator/DD4hepUnits.h" diff --git a/DDCore/include/DD4hep/Exceptions.h b/DDCore/include/DD4hep/Exceptions.h index 50f11ba92..d367779f9 100644 --- a/DDCore/include/DD4hep/Exceptions.h +++ b/DDCore/include/DD4hep/Exceptions.h @@ -7,47 +7,18 @@ // For the licensing terms see $DD4hepINSTALL/LICENSE. // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // -// Author : M.Frank +// \author Markus Frank +// \date 2016-02-02 +// \version 1.0 // //========================================================================== - #ifndef DD4HEP_DDCORE_EXCEPTIONS_H #define DD4HEP_DDCORE_EXCEPTIONS_H -// C/C++ include files -#include <string> -#include <typeinfo> -#include <stdexcept> - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - /// Exception class to signal operations on unrelated classes - /** - * \author M.Frank - * \date 13.08.2013 - * \ingroup DD4HEP - */ - struct unrelated_type_error : public std::runtime_error { - static std::string msg(const std::type_info& typ1, const std::type_info& typ2, const std::string& text); - unrelated_type_error(const std::type_info& typ1, const std::type_info& typ2, const std::string& text = "") - : std::runtime_error(msg(typ1, typ2, text)) { - } - }; +// Forward declaring header for package configuration - /// Exception class to signal operations on unrelated types of values - /** - * \author M.Frank - * \date 13.08.2013 - * \ingroup DD4HEP - */ - struct unrelated_value_error : public std::runtime_error { - static std::string msg(const std::type_info& typ, const std::string& text); - unrelated_value_error(const std::type_info& typ, const std::string& text = "") - : std::runtime_error(msg(typ, text)) { - } - }; +#include "DD4hep/config.h" +#include "Parsers/Exceptions.h" -} // End namespace dd4hep +#endif // DD4HEP_DDCORE_EXCEPTIONS_H -#endif /* DD4HEP_DDCORE_EXCEPTIONS_H */ diff --git a/DDCore/include/DD4hep/Plugins.h b/DDCore/include/DD4hep/Plugins.h index ceb6c62a9..5c7acba74 100644 --- a/DDCore/include/DD4hep/Plugins.h +++ b/DDCore/include/DD4hep/Plugins.h @@ -13,6 +13,9 @@ #ifndef DD4HEP_PLUGINS_H #define DD4HEP_PLUGINS_H +// Framework include files +#include "DD4hep/config.h" + // ROOT include files #ifndef __CINT__ #include <string> diff --git a/DDCore/include/DD4hep/Primitives.h b/DDCore/include/DD4hep/Primitives.h index 95900fa7d..42ef39cef 100644 --- a/DDCore/include/DD4hep/Primitives.h +++ b/DDCore/include/DD4hep/Primitives.h @@ -7,624 +7,17 @@ // For the licensing terms see $DD4hepINSTALL/LICENSE. // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // -// Author : M.Frank +// \author Markus Frank +// \date 2016-02-02 +// \version 1.0 // //========================================================================== -#ifndef DD4HEP_DD4HEP_PRIMITIVES_H -#define DD4HEP_DD4HEP_PRIMITIVES_H +#ifndef DD4HEP_DDCORE_PRIMITIVES_H +#define DD4HEP_DDCORE_PRIMITIVES_H -// Framework include files -#include "DD4hep/config.h" - -// C/C++ include files -#include <map> -#include <list> -#include <vector> -#include <string> -#include <limits> - -#include <typeinfo> -#include <algorithm> -#include <stdexcept> - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - /// Namespace describing generic detector segmentations - namespace DDSegmentation { - class BitFieldCoder; - class BitFieldElement; - /// Useful typedefs to differentiate cell IDs and volume IDs - typedef long long int CellID; - typedef long long int VolumeID; - } - - - // Put here global basic type definitions derived from primitive types of the dd4hep namespace -#ifdef __CINT__ - typedef DDSegmentation::CellID CellID; - typedef DDSegmentation::VolumeID VolumeID; - typedef DDSegmentation::BitFieldCoder BitFieldCoder; - typedef DDSegmentation::BitFieldElement BitFieldElement; -#else - using DDSegmentation::CellID; - using DDSegmentation::VolumeID; - using DDSegmentation::BitFieldCoder; - using DDSegmentation::BitFieldElement; -#endif - - /// Specialized exception to be thrown if invalid handles are accessed - class invalid_handle_exception : public std::runtime_error { - public: - /// Initializing constructor - invalid_handle_exception(const char* msg) : std::runtime_error(msg) {} - /// Initializing constructor - invalid_handle_exception(const std::string& msg) : std::runtime_error(msg) {} - /// Generic copy constructor - invalid_handle_exception(const std::exception& e) : std::runtime_error(e.what()) {} - /// Generic copy constructor - invalid_handle_exception(const invalid_handle_exception& e) : std::runtime_error(e.what()) {} - /// Default destructor of specialized exception - virtual ~invalid_handle_exception() = default; - }; - - /// Macro for deprecated functions. Prints once only. useage: deprecatedCall(__PRETTY_FUNCTION__); -#define DD4HEP_DEPRECATED_CALL(tag,replacement,func) \ - { static bool __dd4hep_first=true; \ - if ( __dd4hep_first ) { __dd4hep_first=false; \ - dd4hep::printout(dd4hep::WARNING,tag, \ - "Deprecated function: '%s' use '%s' instead.", \ - func,replacement); \ - }} - - /// ABI information about type names - std::string typeName(const std::type_info& type); - /// Check type infos for equivalence (dynamic casts) using ABI information - void typeinfoCheck(const std::type_info& typ1, const std::type_info& typ2, const std::string& text = ""); - /// Throw exception when handles are check for validity - void invalidHandleError(const std::type_info& type); - /// Throw exception when handles are badly assigned - void invalidHandleAssignmentError(const std::type_info& from, const std::type_info& to); - - /// Throw exception when handles are check for validity - template <typename T> void invalidHandleError() { - invalidHandleError(typeid(T)); - } - - /// Throw exception when handles are check for validity - void notImplemented(const std::string& msg); - - /// Class to perform dynamic casts using unknown pointers. - /** @class ComponentCast Primitives.h dd4hep/Primitives.h - * - * It is mandatory that the pointers referred do actually - * support the asked functionalty. - * Miracles also I cannot do..... - * - * @author M.Frank - * @date 13.08.2013 - */ - class ComponentCast { - public: - typedef void (*destroy_t)(void*); - typedef void* (*cast_t)(const void*); -#ifdef __CINT__ - const std::type_info* type; -#else - const std::type_info& type; -#endif - const void* abi_class; - destroy_t destroy; - cast_t cast; - - private: - /// Initializing Constructor - ComponentCast(const std::type_info& t, destroy_t d, cast_t c); - /// Defautl destructor - virtual ~ComponentCast(); - - public: - template <typename TYPE> static void _destroy(void* arg) { - TYPE* ptr = (TYPE*)arg; - if (ptr) delete ptr; - } - template <typename TYPE> static void* _cast(const void* arg) { - TYPE* ptr = (TYPE*)arg; - ptr = dynamic_cast<TYPE*>(ptr); - return (void*)ptr; - } - template <typename TYPE> static ComponentCast& instance() { - static ComponentCast c(typeid(TYPE),_destroy<TYPE>,_cast<TYPE>); - return c; - } - - /// Apply cast using typeinfo instead of dynamic_cast - void* apply_dynCast(const ComponentCast& to, const void* ptr) const; - /// Apply cast using typeinfo instead of dynamic_cast - void* apply_upCast(const ComponentCast& to, const void* ptr) const; - /// Apply cast using typeinfo instead of dynamic_cast - void* apply_downCast(const ComponentCast& to, const void* ptr) const; - }; - - /// Convert volumeID to string format (016X) - std::string volumeID(VolumeID vid); - - /// DD4hep internal namespace declaration for utilities and implementation details - namespace detail { - - /// We need it so often: one-at-time 64 bit hash function - unsigned long long int hash64(const char* key); - unsigned long long int hash64(const std::string& key); - template <typename T> unsigned long long int typeHash64() { - static unsigned long long int code = hash64(typeid(T).name()); - return code; - } - - /// We need it so often: one-at-time 32 bit hash function - inline unsigned int hash32(const char* key) { - unsigned int hash = 0; - const char* k = key; - for (; *k; k++) { - hash += *k; - hash += (hash << 10); - hash ^= (hash >> 6); - } - hash += (hash << 3); - hash ^= (hash >> 11); hash += (hash << 15); - return hash; - } - inline unsigned int hash32(const std::string& key) { - return hash32(key.c_str()); - } - - /// Convert date into epoch time (seconds since 1970) - long int makeTime(int year, int month, int day, - int hour=0, int minutes=0, int seconds=0); - - /// Convert date into epoch time (seconds since 1970) - long int makeTime(const std::string& date, const char* fmt="%d-%m-%Y %H:%M:%S"); - - - /// A bit of support for handling and printing primitives - /** - * - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP - */ - template<typename T> struct Primitive { - public: - /// Type decribed by th class - typedef T value_t; - /// Definition of the vector type - typedef std::vector<value_t> vector_t; - - /// Definition of the short integer mapped type - typedef std::pair<short,value_t> short_pair_t; - /// Definition of the unsigned short integer mapped type - typedef std::pair<unsigned short,value_t> ushort_pair_t; - /// Definition of the integer mapped type - typedef std::pair<int,value_t> int_pair_t; - /// Definition of the unsigned integer mapped type - typedef std::pair<unsigned int,value_t> uint_pair_t; - /// Definition of the long integer mapped type - typedef std::pair<long,value_t> long_pair_t; - /// Definition of the unsigned long integer mapped type - typedef std::pair<unsigned long,value_t> ulong_pair_t; - /// Definition of the size_t mapped type - typedef std::pair<size_t,value_t> size_pair_t; - /// Definition of the string mapped type - typedef std::pair<std::string,value_t> string_pair_t; - - /// Definition of the short integer mapped type - typedef std::map<short,value_t> short_map_t; - /// Definition of the unsigned short integer mapped type - typedef std::map<unsigned short,value_t> ushort_map_t; - /// Definition of the integer mapped type - typedef std::map<int,value_t> int_map_t; - /// Definition of the unsigned integer mapped type - typedef std::map<unsigned int,value_t> uint_map_t; - /// Definition of the long integer mapped type - typedef std::map<long,value_t> long_map_t; - /// Definition of the unsigned long integer mapped type - typedef std::map<unsigned long,value_t> ulong_map_t; - /// Definition of the size_t mapped type - typedef std::map<size_t,value_t> size_map_t; - /// Definition of the string mapped type - typedef std::map<std::string,value_t> string_map_t; - /// Definition of the limits - typedef std::numeric_limits<value_t> limits; - - /// Access to default printf format - static const char* default_format(); - /// Access to the specific printf format. May be overloaded by users - static const char* format() { return default_format(); } - /// Access to the RTTI data type - static const std::type_info& type() { return typeid(value_t); } - /// Access to the RTTI data type - static std::string type_name() { return typeName(type()); } - /// Auto conversion to string using the default format - static std::string toString(T value); - /// Get typed null pointer (for template selctions) - static const value_t* null_pointer() { return (value_t*)0; } - }; - - /// Safe cast mechanism using pre-linked conversions. - /** - * - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP - */ -#ifdef DD4HEP_USE_SAFE_CAST - template <typename TO> class safe_cast { - public: - template <typename FROM> static TO* cast(FROM* from); - template <typename FROM> static TO* cast(const FROM* from); - template <typename FROM> static TO* cast_non_null(FROM* from); - template <typename FROM> static TO* cast_non_null(const FROM* from); - }; -#else - template <typename TO> class safe_cast { - public: - static TO* cast(TO* from); - static TO* cast_non_null(TO* from); - template <typename FROM> static TO* cast(FROM* from) { return cast((TO*)from; } - template <typename FROM> static TO* cast(const FROM* from) { return cast((TO*)from; } - template <typename FROM> static TO* cast_non_null(FROM* from) { return cast_non_null((TO*)from; } - template <typename FROM> static TO* cast_non_null(const FROM* from) { return cast_non_null((TO*)from; } - }; -#endif - - /// Operator to clear containers when out of scope - /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_CORE - */ - template<typename C> struct ClearOnReturn { - C& container; - ClearOnReturn(C& c) : container(c) { } - ~ClearOnReturn() { container.clear(); } - }; - - /// Helper to copy objects. - template <typename T> inline void copyObject(void* target,const void* source) { - const T* src = (const T*)source; - ::new(target) T(*src); - } - /// Helper to destruct objects. Note: The memory is NOT released! - template <typename T> inline void destructObject(T* ptr) { - ptr->~T(); - } - /// Helper to delete objects from heap and reset the pointer. Saves many many lines of code - template <typename T> inline void deletePtr(T*& ptr) { - if (0 != ptr) - delete ptr; - ptr = 0; - } - /// Helper to delete objects from heap and reset the pointer. Saves many many lines of code - template <typename T> inline void deleteObject(T* ptr) { - if (0 != ptr) - delete ptr; - } - /// Helper to delete objects from heap and reset the pointer - template <typename T> inline void destroyObject(T*& ptr) { - deletePtr(ptr); - } - /// Functor to delete objects from heap and reset the pointer - template <typename T> class DestroyObject { - public: - void operator()(T& ptr) const { - destroyObject(ptr); - } - }; - - /// Operator to select second element of a pair - template <typename T> class Select2nd { - public: - typedef T arg_t; - typedef typename T::second_type result_t; - /// Operator function - const result_t& operator()(const arg_t &arg) const { return arg.second; } - }; - /// Generator to create Operator to select value elements of a map - template <typename T> Select2nd<typename T::value_type> select2nd(const T&) - { return Select2nd<typename T::value_type>(); } - - /// Operator to select the first element of a pair - template <typename T> class Select1st { - public: - typedef T arg_t; - typedef typename T::first_type result_t; - /// Operator function - const result_t& operator()(const arg_t &arg) const { return arg.first; } - }; - /// Generator to create Operator to select key values of a map - template <typename T> Select1st<typename T::value_type> select1st(const T&) - { return Select1st<typename T::value_type>(); } - - - /// map Functor to delete objects from heap - template <typename M> class DestroyObjects { - public: - M& object; - DestroyObjects(M& obj) : object(obj) { } - void operator()(std::pair<typename M::key_type, typename M::mapped_type> arg) const - { DestroyObject<typename M::mapped_type>()(arg.second); } - void operator()() const { - if ( !object.empty() ) for_each(object.begin(),object.end(),(*this)); - object.clear(); - } - }; - template <typename M> void destroyObjects(M& obj) - { DestroyObjects<M> del(obj); del(); } - template <typename M> DestroyObjects<M> destroy2nd(M& obj) - { DestroyObjects<M> del(obj); del(); } +// Forward declaring header for package configuration - /// map Functor to delete objects from heap - template <typename M> class DestroyFirst { - public: - M& object; - DestroyFirst(M& obj) : object(obj) { } - void operator()(std::pair<typename M::key_type, typename M::mapped_type> arg) const - { DestroyObject<typename M::key_type>()(arg.first); } - void operator()() const { - if ( !object.empty() ) for_each(object.begin(),object.end(),(*this)); - object.clear(); - } - }; - template <typename M> void destroyFirst(M& arg) - { DestroyFirst<M> del(arg); del(); } - template <typename M> void destroy1st(M& arg) - { DestroyFirst<M> del(arg); del(); } - - /// Helper to delete objects from heap and reset the pointer. Saves many many lines of code - template <typename T> inline void releasePtr(T& arg) { - if (0 != arg) - arg->release(); - arg = 0; - } - - /// Functor to release objects from heap and reset the pointer - template <typename T> class ReleaseObject { - public: - void operator()(T& arg) const { - releasePtr(arg); - } - }; - /// Map Functor to release objects from heap - template <typename M> class ReleaseObjects { - public: - M& object; - ReleaseObjects(M& arg) : object(arg) { } - void operator()(std::pair<typename M::key_type, typename M::mapped_type> arg) const - { ReleaseObject<typename M::mapped_type>()(arg.second); } - void operator()() const { - if ( !object.empty() ) for_each(object.begin(),object.end(),(*this)); - object.clear(); - } - }; - template <typename M> ReleaseObject<typename M::value_type> releaseObject(M&) { - return ReleaseObject<typename M::value_type>(); - } - template <typename M> void releaseObjects(M& arg) { - ReleaseObjects<M> rel(arg); rel(); - } - template <typename M> void release2nd(M& arg) { - ReleaseObjects<M> rel(arg); rel(); - } - - /// Functor to delete objects from heap and reset the pointer - template <typename T> class ReferenceObject { - public: - typedef T arg_t; - T operator()(T arg) const { - if ( arg ) arg->addRef(); - return arg; - } - }; - /// Functor to delete objects from heap and reset the pointer - template <typename M> class ReferenceObjects { - public: - typedef typename M::second_type result_t; - result_t operator()(const M& arg) const { - return ReferenceObject<result_t>()(arg.second); - } - }; - template <typename M> ReferenceObject<M> referenceObject(M&) { - return ReferenceObject<typename M::value_type>(); - } - template <typename M> ReferenceObjects<typename M::value_type> reference2nd(M&) { - return ReferenceObjects<typename M::value_type>(); - } - - /// Member function call-functor with no arguments - template <typename R, typename T> struct ApplyMemFunc { - typedef R (T::*memfunc_t)(); - memfunc_t func; - ApplyMemFunc(memfunc_t f) : func(f) {} - void operator()(T* arg) const { if (arg) { (arg->*func)(); } } - }; - - /// Member function call-functor with 1 argument - template <typename R, typename T, typename A1> struct ApplyMemFunc1 { - typedef R (T::*memfunc_t)(A1 a1); - memfunc_t func; - A1& arg1; - ApplyMemFunc1(memfunc_t f, A1& a1) : func(f), arg1(a1) {} - void operator()(T* arg) const { if ( arg ) { (arg->*func)(arg1); } } - }; - - /// Member function call-functor with 2 arguments - template <typename R, typename T, typename A1, typename A2> struct ApplyMemFunc2 { - typedef R (T::*memfunc_t)(A1 a1, A2 a2); - memfunc_t func; - A1& arg1; - A2& arg2; - ApplyMemFunc2(memfunc_t f, A1& a1, A2& a2) : func(f), arg1(a1), arg2(a2) {} - void operator()( T* arg) const { if ( arg ) { (arg->*func)(arg1, arg2); } } - }; - - /// Member function call-functor with no arguments (const version) - template <typename R, typename T> struct ApplyMemFuncConst { - typedef R (T::*memfunc_t)() const; - memfunc_t func; - ApplyMemFuncConst(memfunc_t f) : func(f) {} - void operator()(const T* arg) const { if ( arg ) { (arg->*func)(); } } - }; - - /// Member function call-functor with 1 argument (const version) - template <typename R, typename T, typename A1> struct ApplyMemFuncConst1 { - typedef R (T::*memfunc_t)(A1 a1) const; - memfunc_t func; - A1& arg1; - ApplyMemFuncConst1(memfunc_t f, A1& a1) : func(f), arg1(a1) {} - void operator()(const T* arg) const { if ( arg ) { (arg->*func)(arg1); } } - }; - - /// Member function call-functor with 2 arguments (const version) - template <typename R, typename T, typename A1, typename A2> struct ApplyMemFuncConst2 { - typedef R (T::*memfunc_t)(A1 a1, A2 a2) const; - memfunc_t func; - A1& arg1; - A2& arg2; - ApplyMemFuncConst2(memfunc_t f, A1& a1, A2& a2) : func(f), arg1(a1), arg2(a2) {} - void operator()(const T* arg) const { if ( arg ) { (arg->*func)(arg1, arg2); } } - }; - - template <typename C, typename R, typename T> - void call_member_func(C& object, R (T::*pmf)()) - { std::for_each(object.begin(),object.end(),ApplyMemFunc<R,T>(pmf)); } - - template <typename C, typename R, typename T> - void call_member_func(C& object, R (T::*pmf)() const) - { std::for_each(object.begin(),object.end(),ApplyMemFuncConst<R,T>(pmf)); } - - template <typename C, typename R, typename T, typename A1> - void call_member_func(C& object, R (T::*pmf)(A1 a1), A1 a1) - { std::for_each(object.begin(),object.end(),ApplyMemFunc1<R,T,A1>(pmf,a1)); } - - template <typename C, typename R, typename T, typename A1> - void call_member_func(C& object, R (T::*pmf)(A1 a1) const, A1 a1) - { std::for_each(object.begin(),object.end(),ApplyMemFuncConst1<R,T,A1>(pmf,a1)); } - - - template <typename C, typename R, typename T, typename A1, typename A2> - void call_member_func(C& object, R (T::*pmf)(A1 a1,A2 a2), A1 a1, A2 a2) - { std::for_each(object.begin(),object.end(),ApplyMemFunc2<R,T,A1,A2>(pmf,a1,a2)); } - - template <typename C, typename R, typename T, typename A1, typename A2> - void call_member_func(C& object, R (T::*pmf)(A1 a1,A2 a2) const, A1 a1, A2 a2) - { std::for_each(object.begin(),object.end(),ApplyMemFuncConst2<R,T,A1,A2>(pmf,a1,a2)); } - - - /// Generic map Functor to act on first element (key) - template <typename M, typename FCN> class Apply1rst { - public: - const FCN& func; - Apply1rst(const FCN& f) : func(f) { } - void operator()(std::pair<typename M::key_type const, typename M::mapped_type>& arg) const - { (func)(arg.first); } - void operator()(const std::pair<typename M::key_type const, typename M::mapped_type>& arg) const - { (func)(arg.first); } - }; - - template <typename C, typename FCN> Apply1rst<C,FCN> apply__1rst_value(C&,const FCN& func) - { return Apply1rst<C,FCN>(func); } - - template <typename C, typename FCN> void apply1rst(C& object,const FCN& func) - { std::for_each(object.begin(),object.end(),apply__1rst_value(object,func)); } - - template <typename C, typename R, typename T> - void apply1rst(C& object, R (T::*pmf)()) - { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFunc<R,T>(pmf))); } - - template <typename C, typename R, typename T, typename A1> - void apply1rst(C object, R (T::*pmf)(A1 a1), A1 a1) - { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFunc1<R,T,A1>(pmf,a1))); } - - template <typename C, typename R, typename T> - void apply1rst(C& object, R (T::*pmf)() const) - { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFuncConst<R,T>(pmf))); } - - template <typename C, typename R, typename T, typename A1> - void apply1rst(C object, R (T::*pmf)(A1 a1) const, A1 a1) - { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFuncConst1<R,T,A1>(pmf,a1))); } - - /// Generic map Functor to act on second element (mapped type) - template <typename M, typename FCN> class Apply2nd { - public: - const FCN& func; - Apply2nd(const FCN& f) : func(f) { } - void operator()(std::pair<typename M::key_type const, typename M::mapped_type>& arg) const - { (func)(arg.second); } - void operator()(const std::pair<typename M::key_type const, typename M::mapped_type>& arg) const - { (func)(arg.second); } - }; - - template <typename C, typename FCN> Apply2nd<C,FCN> apply__2nd_value(C&,const FCN& func) - { return Apply2nd<C,FCN>(func); } - - template <typename C, typename FCN> void apply2nd(C& object,const FCN& func) - { std::for_each(object.begin(),object.end(),apply__2nd_value(object,func)); } - - template <typename C, typename R, typename T> - void apply2nd(C& object, R (T::*pmf)()) - { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFunc<R,T>(pmf))); } - - template <typename C, typename R, typename T, typename A1> - void apply2nd(C object, R (T::*pmf)(A1 a1), A1 a1) - { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFunc1<R,T,A1>(pmf,a1))); } - - template <typename C, typename R, typename T> - void apply2nd(C& object, R (T::*pmf)() const) - { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFuncConst<R,T>(pmf))); } - - template <typename C, typename R, typename T, typename A1> - void apply2nd(C object, R (T::*pmf)(A1 a1) const, A1 a1) - { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFuncConst1<R,T,A1>(pmf,a1))); } - - /// Data structure to manipulate a bitmask held by reference and represented by an integer - /** - * @author M.Frank - * @version 1.0 - */ - template <typename T> class ReferenceBitMask { - public: - /// Reference to the data - T& mask; - /// Standard constructor - ReferenceBitMask(T& arg); - T value() const { - return mask; - } - void set(const T& arg) { - mask |= arg; - } - void clear(const T& arg) { - mask &= ~arg; - } - void clear() { - mask = 0; - } - bool isSet(const T& arg) const { - return (mask&arg) == arg; - } - bool anySet(const T& arg) const { - return (mask&arg) != 0; - } - bool testBit(int bit) const { - T arg = T(1)<<bit; - return isSet(arg); - } - bool isNull() const { - return mask == 0; - } - }; - /// Standard constructor - template <typename T> ReferenceBitMask<T>::ReferenceBitMask(T& arg) : mask(arg) {} +#include "DD4hep/config.h" +#include "Parsers/Primitives.h" - } // End namespace detail -} // End namespace dd4hep -#endif // DD4HEP_DD4HEP_PRIMITIVES_H +#endif // DD4HEP_DDCORE_PRIMITIVES_H diff --git a/DDCore/include/DD4hep/Printout.h b/DDCore/include/DD4hep/Printout.h index 2dd9afd8a..29caac569 100644 --- a/DDCore/include/DD4hep/Printout.h +++ b/DDCore/include/DD4hep/Printout.h @@ -7,312 +7,17 @@ // For the licensing terms see $DD4hepINSTALL/LICENSE. // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // -// Author : M.Frank +// \author Markus Frank +// \date 2016-02-02 +// \version 1.0 // //========================================================================== -#ifndef DD4HEP_PRINTOUT_H -#define DD4HEP_PRINTOUT_H +#ifndef DD4HEP_DDCORE_PRINTOUT_H +#define DD4HEP_DDCORE_PRINTOUT_H -// Framework include files +// Forward declaring header for package configuration -// C/C++ include files -#include <cstdio> -#include <cstdlib> -#include <cstdarg> -#include <map> -#include <string> -#include <sstream> -#include <iostream> +#include "DD4hep/config.h" +#include "Parsers/Printout.h" -/// Forward declarations -class TNamed; - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - // Forward declarations - class Detector; - class NamedObject; - template <typename T> class Handle; - - enum PrintLevel { - NOLOG = 0, - VERBOSE = 1, - DEBUG = 2, - INFO = 3, - WARNING = 4, - ERROR = 5, - FATAL = 6, - ALWAYS = 7 - }; - -#ifndef __CINT__ - typedef size_t (*output_function1_t)(void*, PrintLevel severity, const char*, const char*); - typedef size_t (*output_function2_t)(void*, PrintLevel severity, const char*, const char*, va_list& args); - - /// Helper function to serialize argument list to a single string - /** - * @arg argc [int,read-only] Number of arguments. - * @arg argv [char**,read-only] Argument strings - * @return String containing the concatenated arguments - */ - std::string arguments(int argc, char** argv); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg str [stringstream, RW] string stream containing data to be printed. - * Object is reset after use. - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const char* src, std::stringstream& str); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg str [stringstream, RW] string stream containing data to be printed. - * Object is reset after use. - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const std::string& src, std::stringstream& str); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const char* src, const char* fmt, ...); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const std::string& src, const char* fmt, ...); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const std::string& src, const std::string& fmt, ...); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const char* src, const std::string& fmt, ...); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const char* src, const char* fmt, va_list& args); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const std::string& src, const char* fmt, va_list& args); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const std::string& src, const std::string& fmt, va_list& args); - - /// Calls the display action with a given severity level - /** - * @arg severity [int,read-only] Display severity flag (see enum) - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - int printout(PrintLevel severity, const char* src, const std::string& fmt, va_list& args); - - /// Calls the display action with ERROR and throws an std::runtime_error exception - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - int except(const std::string& src, const std::string& fmt, ...); - - /// Calls the display action with ERROR and throws an std::runtime_error exception - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - int except(const char* src, const char* fmt, ...); - - /// Calls the display action with ERROR and throws an std::runtime_error exception - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - int except(const std::string& src, const std::string& fmt, va_list& args); - - /// Calls the display action with ERROR and throws an std::runtime_error exception - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - int except(const char* src, const char* fmt, va_list& args); - - /// Build formatted string - /* - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - std::string format(const std::string& src, const std::string& fmt, ...); - - /// Build exception string - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @return Status code indicating success or failure - */ - std::string format(const char* src, const char* fmt, ...); - - /// Build formatted string - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - std::string format(const std::string& src, const std::string& fmt, va_list& args); - - /// Build formatted string - /** - * @arg src [string,read-only] Information source (component, etc.) - * @arg fmt [string,read-only] Format string for ellipsis args - * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. - * @return Status code indicating success or failure - */ - std::string format(const char* src, const char* fmt, va_list& args); - - /// Customize printer function - void setPrinter(void* print_arg, output_function1_t fcn); - - /// Customize printer function - void setPrinter2(void* print_arg, output_function2_t fcn); - -#endif // __CINT__ - - /// Set new printout format for the 3 fields: source-level-message. All 3 are strings - std::string setPrintFormat(const std::string& new_format); - - /// Set new print level. Returns the old print level - PrintLevel setPrintLevel(PrintLevel new_level); - - /// Access the current printer level - PrintLevel printLevel(); - - /// Translate the printer level from string to value - PrintLevel printLevel(const char* value); - - /// Translate the printer level from string to value - PrintLevel printLevel(const std::string& value); - - /// Check if this print level would result in some output - bool isActivePrintLevel(int severity); - - /// Helper class template to implement ASCII object dumps - /** @class Printer Conversions.h dd4hep/compact/Conversions.h - * - * Small helper class to print objects - * - * @author M.Frank - * @version 1.0 - */ - template <typename T> struct Printer { - /// Reference to the detector description object - const Detector* description; - /// Reference to the output stream object, the Printer object should write - std::ostream& os; - /// Optional text prefix when formatting the output - std::string prefix; - /// Initializing constructor of the functor - Printer(const Detector* l, std::ostream& stream, const std::string& p = "") - : description(l), os(stream), prefix(p) { - } - /// Callback operator to be specialized depending on the element type - void operator()(const T& value) const; - }; - - template <typename T> inline std::ostream& print(const T& object, std::ostream& os = std::cout, - const std::string& indent = "") { - Printer<T>(0, os, indent)(object); - return os; - } - - /// Helper class template to implement ASCII dumps of named objects maps - /** @class PrintMap Conversions.h dd4hep/compact/Conversions.h - * - * Small helper class to print maps of objects - * - * @author M.Frank - * @version 1.0 - */ - template <typename T> struct PrintMap { - typedef T item_type; - typedef const std::map<std::string, Handle<NamedObject> > cont_type; - - /// Reference to the detector description object - const Detector* description; - /// Reference to the output stream object, the Printer object should write - std::ostream& os; - /// Optional text prefix when formatting the output - std::string text; - /// Reference to the container data of the map. - cont_type& cont; - /// Initializing constructor of the functor - PrintMap(const Detector* l, std::ostream& stream, cont_type& c, const std::string& t = "") - : description(l), os(stream), text(t), cont(c) { - } - /// Callback operator to be specialized depending on the element type - void operator()() const; - }; - - /// Helper function to print booleans in format YES/NO - inline const char* yes_no(bool value) { - return value ? "YES" : "NO "; - } - /// Helper function to print booleans in format true/false - inline const char* true_false(bool value) { - return value ? "true " : "false"; - } - -} /* End namespace dd4hep */ -#endif /* DD4HEP_PRINTOUT_H */ +#endif // DD4HEP_DDCORE_PRINTOUT_H diff --git a/DDCore/include/DD4hep/config.h b/DDCore/include/DD4hep/config.h index 87e602a26..6939acabf 100644 --- a/DDCore/include/DD4hep/config.h +++ b/DDCore/include/DD4hep/config.h @@ -10,9 +10,14 @@ // Author : M.Frank // //========================================================================== -#ifndef DD4HEP_CONFIG_H -#define DD4HEP_CONFIG_H +// +// Setup XML parsing for the use of Apache Xerces-C and TiXml +// +//========================================================================== +#ifndef DD4HEP_DDCORE_CONFIG_H +#define DD4HEP_DDCORE_CONFIG_H +#include "Parsers/config.h" #define DD4HEP_INSTANCE_COUNTS 1 #define DD4HEP_USE_SAFE_CAST 1 @@ -24,12 +29,4 @@ #define DECREMENT_COUNTER #endif -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - /// Namespace for implementation details of the AIDA detector description toolkit - namespace detail { - - } /* End namespace detail */ -} /* End namespace dd4hep */ -#endif /* DD4HEP_CONFIG_H */ +#endif // DD4HEP_DDCORE_CONFIG_H diff --git a/DDCore/include/DD4hep/detail/BasicGrammar_inl.h b/DDCore/include/DD4hep/detail/BasicGrammar_inl.h index 2de0631dc..47d8d8347 100644 --- a/DDCore/include/DD4hep/detail/BasicGrammar_inl.h +++ b/DDCore/include/DD4hep/detail/BasicGrammar_inl.h @@ -22,8 +22,12 @@ #define DD4HEP_DDCORE_BASICGRAMMAR_INL_H // Framework include files +#include "DD4hep/config.h" #include "DD4hep/Primitives.h" #include "DD4hep/detail/Grammar.h" +#include "Evaluator/Evaluator.h" +#include "Parsers/spirit/Parsers.h" +#include "Parsers/spirit/ToStream.h" #if defined(DD4HEP_PARSER_HEADER) @@ -32,13 +36,9 @@ // and the dd4hep namespace is renamed! #include DD4HEP_PARSER_HEADER -#else +#endif -#include "DDParsers/Parsers.h" -#include "DDParsers/ToStream.h" -#include "DDParsers/Evaluator.h" namespace dd4hep { XmlTools::Evaluator& g4Evaluator(); } -#endif namespace { static XmlTools::Evaluator& s__eval(dd4hep::g4Evaluator()); } // C/C++ include files diff --git a/DDCore/include/JSON/ChildValue.h b/DDCore/include/JSON/ChildValue.h index 80919af73..a3c6e8c83 100644 --- a/DDCore/include/JSON/ChildValue.h +++ b/DDCore/include/JSON/ChildValue.h @@ -17,7 +17,7 @@ #include "JSON/Dimension.h" #define DD4HEP_DIMENSION_NS json -#include "XML/detail/ChildValue.h" +#include "Parsers/detail/ChildValue.h" #undef DD4HEP_DIMENSION_NS diff --git a/DDCore/include/JSON/ChildValue.inl b/DDCore/include/JSON/ChildValue.inl index 7dee274ae..aa3785e3b 100644 --- a/DDCore/include/JSON/ChildValue.inl +++ b/DDCore/include/JSON/ChildValue.inl @@ -17,7 +17,7 @@ #include "JSON/ChildValue.h" #define DD4HEP_DIMENSION_NS json -#include "XML/detail/ChildValue.inl" +#include "Parsers/detail/ChildValue.inl" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_JSONCHILDVALUE_INL */ diff --git a/DDCore/include/JSON/Conversions.h b/DDCore/include/JSON/Conversions.h index c108665d4..394907fb8 100644 --- a/DDCore/include/JSON/Conversions.h +++ b/DDCore/include/JSON/Conversions.h @@ -14,7 +14,7 @@ #define DD4HEP_JSON_CONVERSIONS_H #define DD4HEP_CONVERSION_NS json -#include "XML/detail/Conversions.h" +#include "Parsers/detail/Conversions.h" #undef DD4HEP_CONVERSION_NS #endif /* DD4HEP_JSON_CONVERSIONS_H */ diff --git a/DDCore/include/JSON/Detector.h b/DDCore/include/JSON/Detector.h index 662196e30..117762044 100644 --- a/DDCore/include/JSON/Detector.h +++ b/DDCore/include/JSON/Detector.h @@ -18,7 +18,7 @@ /// Include the implementation in the proper namespace #define DD4HEP_DIMENSION_NS json -#include "XML/detail/Detector.h" +#include "Parsers/detail/Detector.h" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_JSON_DETECTOR_H */ diff --git a/DDCore/include/JSON/Dimension.h b/DDCore/include/JSON/Dimension.h index e92caee8b..3143b124b 100644 --- a/DDCore/include/JSON/Dimension.h +++ b/DDCore/include/JSON/Dimension.h @@ -18,7 +18,7 @@ #include "JSON/Tags.h" #define DD4HEP_DIMENSION_NS json -#include "XML/detail/Dimension.h" +#include "Parsers/detail/Dimension.h" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_JSON_DIMENSION_H */ diff --git a/DDCore/include/JSON/Dimension.inl b/DDCore/include/JSON/Dimension.inl index 602b86658..2380b8ac5 100644 --- a/DDCore/include/JSON/Dimension.inl +++ b/DDCore/include/JSON/Dimension.inl @@ -17,7 +17,7 @@ #include "JSON/Dimension.h" #define DD4HEP_DIMENSION_NS json -#include "XML/detail/Dimension.inl" +#include "Parsers/detail/Dimension.inl" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_JSONDIMENSION_INL */ diff --git a/DDCore/include/JSON/Evaluator.h b/DDCore/include/JSON/Evaluator.h index 4c3f19915..8e395fb59 100644 --- a/DDCore/include/JSON/Evaluator.h +++ b/DDCore/include/JSON/Evaluator.h @@ -19,6 +19,6 @@ * * See the externalized header in doc/externalize for details. */ -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" #endif /* DD4HEP_DDCORE_JSON_EVALUATOR_H */ diff --git a/DDCore/include/JSON/Printout.h b/DDCore/include/JSON/Printout.h index 30a81ddd1..da8c23f56 100644 --- a/DDCore/include/JSON/Printout.h +++ b/DDCore/include/JSON/Printout.h @@ -10,8 +10,8 @@ // Author : M.Frank // //========================================================================== -#ifndef DD4HEP_DDCORE_JSON_PRINTOUT_H -#define DD4HEP_DDCORE_JSON_PRINTOUT_H +#ifndef DD4HEP_JSON_PRINTOUT_H +#define DD4HEP_JSON_PRINTOUT_H // Forwarding printout functionality to dd4hep /** Note: This is necessary to use the JSON functionality as a standalone @@ -19,6 +19,6 @@ * * See the externalized header in doc/externalize for details. */ -#include "DD4hep/Printout.h" +#include "Parsers/Printout.h" -#endif /* DD4HEP_DDCORE_JSON_PRINTOUT_H */ +#endif /* DD4HEP_JSON_PRINTOUT_H */ diff --git a/DDCore/include/JSON/config.h b/DDCore/include/JSON/config.h index c9d657da1..0fea92935 100644 --- a/DDCore/include/JSON/config.h +++ b/DDCore/include/JSON/config.h @@ -13,6 +13,8 @@ #ifndef DD4HEP_DDCORE_JSON_CONFIG_H #define DD4HEP_DDCORE_JSON_CONFIG_H +#include "Parsers/config.h" + #define DD4HEP_USE_BOOST_JSON 1 #include "boost/property_tree/ptree.hpp" diff --git a/DDCore/include/Parsers/Exceptions.h b/DDCore/include/Parsers/Exceptions.h new file mode 100644 index 000000000..7191969d6 --- /dev/null +++ b/DDCore/include/Parsers/Exceptions.h @@ -0,0 +1,55 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_PARSERS_EXCEPTIONS_H +#define DD4HEP_PARSERS_EXCEPTIONS_H + +// Framework include files +#include "Parsers/config.h" + +// C/C++ include files +#include <string> +#include <typeinfo> +#include <stdexcept> + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + + /// Exception class to signal operations on unrelated classes + /** + * \author M.Frank + * \date 13.08.2013 + * \ingroup DD4HEP + */ + struct unrelated_type_error : public std::runtime_error { + static std::string msg(const std::type_info& typ1, const std::type_info& typ2, const std::string& text); + unrelated_type_error(const std::type_info& typ1, const std::type_info& typ2, const std::string& text = "") + : std::runtime_error(msg(typ1, typ2, text)) { + } + }; + + /// Exception class to signal operations on unrelated types of values + /** + * \author M.Frank + * \date 13.08.2013 + * \ingroup DD4HEP + */ + struct unrelated_value_error : public std::runtime_error { + static std::string msg(const std::type_info& typ, const std::string& text); + unrelated_value_error(const std::type_info& typ, const std::string& text = "") + : std::runtime_error(msg(typ, text)) { + } + }; + +} // End namespace dd4hep + +#endif /* DD4HEP_PARSERS_EXCEPTIONS_H */ diff --git a/DDCore/include/Parsers/Primitives.h b/DDCore/include/Parsers/Primitives.h new file mode 100644 index 000000000..c4c3b41a6 --- /dev/null +++ b/DDCore/include/Parsers/Primitives.h @@ -0,0 +1,630 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_PARSERS_PRIMITIVES_H +#define DD4HEP_PARSERS_PRIMITIVES_H + +// Framework include files +#include "Parsers/config.h" + +// C/C++ include files +#include <map> +#include <list> +#include <vector> +#include <string> +#include <limits> + +#include <typeinfo> +#include <algorithm> +#include <stdexcept> + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + + /// Namespace describing generic detector segmentations + namespace DDSegmentation { + class BitFieldCoder; + class BitFieldElement; + /// Useful typedefs to differentiate cell IDs and volume IDs + typedef long long int CellID; + typedef long long int VolumeID; + } + + + // Put here global basic type definitions derived from primitive types of the dd4hep namespace +#ifdef __CINT__ + typedef DDSegmentation::CellID CellID; + typedef DDSegmentation::VolumeID VolumeID; + typedef DDSegmentation::BitFieldCoder BitFieldCoder; + typedef DDSegmentation::BitFieldElement BitFieldElement; +#else + using DDSegmentation::CellID; + using DDSegmentation::VolumeID; + using DDSegmentation::BitFieldCoder; + using DDSegmentation::BitFieldElement; +#endif + + /// Specialized exception to be thrown if invalid handles are accessed + class invalid_handle_exception : public std::runtime_error { + public: + /// Initializing constructor + invalid_handle_exception(const char* msg) : std::runtime_error(msg) {} + /// Initializing constructor + invalid_handle_exception(const std::string& msg) : std::runtime_error(msg) {} + /// Generic copy constructor + invalid_handle_exception(const std::exception& e) : std::runtime_error(e.what()) {} + /// Generic copy constructor + invalid_handle_exception(const invalid_handle_exception& e) : std::runtime_error(e.what()) {} + /// Default destructor of specialized exception + virtual ~invalid_handle_exception() = default; + }; + + /// Macro for deprecated functions. Prints once only. useage: deprecatedCall(__PRETTY_FUNCTION__); +#define DD4HEP_DEPRECATED_CALL(tag,replacement,func) \ + { static bool __dd4hep_first=true; \ + if ( __dd4hep_first ) { __dd4hep_first=false; \ + dd4hep::printout(dd4hep::WARNING,tag, \ + "Deprecated function: '%s' use '%s' instead.", \ + func,replacement); \ + }} + + /// ABI information about type names + std::string typeName(const std::type_info& type); + /// Check type infos for equivalence (dynamic casts) using ABI information + void typeinfoCheck(const std::type_info& typ1, const std::type_info& typ2, const std::string& text = ""); + /// Throw exception when handles are check for validity + void invalidHandleError(const std::type_info& type); + /// Throw exception when handles are badly assigned + void invalidHandleAssignmentError(const std::type_info& from, const std::type_info& to); + + /// Throw exception when handles are check for validity + template <typename T> void invalidHandleError() { + invalidHandleError(typeid(T)); + } + + /// Throw exception when handles are check for validity + void notImplemented(const std::string& msg); + + /// Class to perform dynamic casts using unknown pointers. + /** @class ComponentCast Primitives.h dd4hep/Primitives.h + * + * It is mandatory that the pointers referred do actually + * support the asked functionalty. + * Miracles also I cannot do..... + * + * @author M.Frank + * @date 13.08.2013 + */ + class ComponentCast { + public: + typedef void (*destroy_t)(void*); + typedef void* (*cast_t)(const void*); +#ifdef __CINT__ + const std::type_info* type; +#else + const std::type_info& type; +#endif + const void* abi_class; + destroy_t destroy; + cast_t cast; + + private: + /// Initializing Constructor + ComponentCast(const std::type_info& t, destroy_t d, cast_t c); + /// Defautl destructor + virtual ~ComponentCast(); + + public: + template <typename TYPE> static void _destroy(void* arg) { + TYPE* ptr = (TYPE*)arg; + if (ptr) delete ptr; + } + template <typename TYPE> static void* _cast(const void* arg) { + TYPE* ptr = (TYPE*)arg; + ptr = dynamic_cast<TYPE*>(ptr); + return (void*)ptr; + } + template <typename TYPE> static ComponentCast& instance() { + static ComponentCast c(typeid(TYPE),_destroy<TYPE>,_cast<TYPE>); + return c; + } + + /// Apply cast using typeinfo instead of dynamic_cast + void* apply_dynCast(const ComponentCast& to, const void* ptr) const; + /// Apply cast using typeinfo instead of dynamic_cast + void* apply_upCast(const ComponentCast& to, const void* ptr) const; + /// Apply cast using typeinfo instead of dynamic_cast + void* apply_downCast(const ComponentCast& to, const void* ptr) const; + }; + + /// Convert volumeID to string format (016X) + std::string volumeID(VolumeID vid); + + /// DD4hep internal namespace declaration for utilities and implementation details + namespace detail { + + /// We need it so often: one-at-time 64 bit hash function + unsigned long long int hash64(const char* key); + unsigned long long int hash64(const std::string& key); + template <typename T> unsigned long long int typeHash64() { + static unsigned long long int code = hash64(typeid(T).name()); + return code; + } + + /// We need it so often: one-at-time 32 bit hash function + inline unsigned int hash32(const char* key) { + unsigned int hash = 0; + const char* k = key; + for (; *k; k++) { + hash += *k; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); hash += (hash << 15); + return hash; + } + inline unsigned int hash32(const std::string& key) { + return hash32(key.c_str()); + } + + /// Convert date into epoch time (seconds since 1970) + long int makeTime(int year, int month, int day, + int hour=0, int minutes=0, int seconds=0); + + /// Convert date into epoch time (seconds since 1970) + long int makeTime(const std::string& date, const char* fmt="%d-%m-%Y %H:%M:%S"); + + + /// A bit of support for handling and printing primitives + /** + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP + */ + template<typename T> struct Primitive { + public: + /// Type decribed by th class + typedef T value_t; + /// Definition of the vector type + typedef std::vector<value_t> vector_t; + + /// Definition of the short integer mapped type + typedef std::pair<short,value_t> short_pair_t; + /// Definition of the unsigned short integer mapped type + typedef std::pair<unsigned short,value_t> ushort_pair_t; + /// Definition of the integer mapped type + typedef std::pair<int,value_t> int_pair_t; + /// Definition of the unsigned integer mapped type + typedef std::pair<unsigned int,value_t> uint_pair_t; + /// Definition of the long integer mapped type + typedef std::pair<long,value_t> long_pair_t; + /// Definition of the unsigned long integer mapped type + typedef std::pair<unsigned long,value_t> ulong_pair_t; + /// Definition of the size_t mapped type + typedef std::pair<size_t,value_t> size_pair_t; + /// Definition of the string mapped type + typedef std::pair<std::string,value_t> string_pair_t; + + /// Definition of the short integer mapped type + typedef std::map<short,value_t> short_map_t; + /// Definition of the unsigned short integer mapped type + typedef std::map<unsigned short,value_t> ushort_map_t; + /// Definition of the integer mapped type + typedef std::map<int,value_t> int_map_t; + /// Definition of the unsigned integer mapped type + typedef std::map<unsigned int,value_t> uint_map_t; + /// Definition of the long integer mapped type + typedef std::map<long,value_t> long_map_t; + /// Definition of the unsigned long integer mapped type + typedef std::map<unsigned long,value_t> ulong_map_t; + /// Definition of the size_t mapped type + typedef std::map<size_t,value_t> size_map_t; + /// Definition of the string mapped type + typedef std::map<std::string,value_t> string_map_t; + /// Definition of the limits + typedef std::numeric_limits<value_t> limits; + + /// Access to default printf format + static const char* default_format(); + /// Access to the specific printf format. May be overloaded by users + static const char* format() { return default_format(); } + /// Access to the RTTI data type + static const std::type_info& type() { return typeid(value_t); } + /// Access to the RTTI data type + static std::string type_name() { return typeName(type()); } + /// Auto conversion to string using the default format + static std::string toString(T value); + /// Get typed null pointer (for template selctions) + static const value_t* null_pointer() { return (value_t*)0; } + }; + + /// Safe cast mechanism using pre-linked conversions. + /** + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP + */ +#ifdef DD4HEP_USE_SAFE_CAST + template <typename TO> class safe_cast { + public: + template <typename FROM> static TO* cast(FROM* from); + template <typename FROM> static TO* cast(const FROM* from); + template <typename FROM> static TO* cast_non_null(FROM* from); + template <typename FROM> static TO* cast_non_null(const FROM* from); + }; +#else + template <typename TO> class safe_cast { + public: + static TO* cast(TO* from); + static TO* cast_non_null(TO* from); + template <typename FROM> static TO* cast(FROM* from) { return cast((TO*)from); } + template <typename FROM> static TO* cast(const FROM* from) { return cast((TO*)from); } + template <typename FROM> static TO* cast_non_null(FROM* from) { return cast_non_null((TO*)from); } + template <typename FROM> static TO* cast_non_null(const FROM* from) { return cast_non_null((TO*)from); } + }; +#endif + + /// Operator to clear containers when out of scope + /** + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_CORE + */ + template<typename C> struct ClearOnReturn { + C& container; + ClearOnReturn(C& c) : container(c) { } + ~ClearOnReturn() { container.clear(); } + }; + + /// Helper to copy objects. + template <typename T> inline void copyObject(void* target,const void* source) { + const T* src = (const T*)source; + ::new(target) T(*src); + } + /// Helper to destruct objects. Note: The memory is NOT released! + template <typename T> inline void destructObject(T* ptr) { + ptr->~T(); + } + /// Helper to delete objects from heap and reset the pointer. Saves many many lines of code + template <typename T> inline void deletePtr(T*& ptr) { + if (0 != ptr) + delete ptr; + ptr = 0; + } + /// Helper to delete objects from heap and reset the pointer. Saves many many lines of code + template <typename T> inline void deleteObject(T* ptr) { + if (0 != ptr) + delete ptr; + } + /// Helper to delete objects from heap and reset the pointer + template <typename T> inline void destroyObject(T*& ptr) { + deletePtr(ptr); + } + /// Functor to delete objects from heap and reset the pointer + template <typename T> class DestroyObject { + public: + void operator()(T& ptr) const { + destroyObject(ptr); + } + }; + + /// Operator to select second element of a pair + template <typename T> class Select2nd { + public: + typedef T arg_t; + typedef typename T::second_type result_t; + /// Operator function + const result_t& operator()(const arg_t &arg) const { return arg.second; } + }; + /// Generator to create Operator to select value elements of a map + template <typename T> Select2nd<typename T::value_type> select2nd(const T&) + { return Select2nd<typename T::value_type>(); } + + /// Operator to select the first element of a pair + template <typename T> class Select1st { + public: + typedef T arg_t; + typedef typename T::first_type result_t; + /// Operator function + const result_t& operator()(const arg_t &arg) const { return arg.first; } + }; + /// Generator to create Operator to select key values of a map + template <typename T> Select1st<typename T::value_type> select1st(const T&) + { return Select1st<typename T::value_type>(); } + + + /// map Functor to delete objects from heap + template <typename M> class DestroyObjects { + public: + M& object; + DestroyObjects(M& obj) : object(obj) { } + void operator()(std::pair<typename M::key_type, typename M::mapped_type> arg) const + { DestroyObject<typename M::mapped_type>()(arg.second); } + void operator()() const { + if ( !object.empty() ) for_each(object.begin(),object.end(),(*this)); + object.clear(); + } + }; + template <typename M> void destroyObjects(M& obj) + { DestroyObjects<M> del(obj); del(); } + template <typename M> DestroyObjects<M> destroy2nd(M& obj) + { DestroyObjects<M> del(obj); del(); } + + /// map Functor to delete objects from heap + template <typename M> class DestroyFirst { + public: + M& object; + DestroyFirst(M& obj) : object(obj) { } + void operator()(std::pair<typename M::key_type, typename M::mapped_type> arg) const + { DestroyObject<typename M::key_type>()(arg.first); } + void operator()() const { + if ( !object.empty() ) for_each(object.begin(),object.end(),(*this)); + object.clear(); + } + }; + template <typename M> void destroyFirst(M& arg) + { DestroyFirst<M> del(arg); del(); } + template <typename M> void destroy1st(M& arg) + { DestroyFirst<M> del(arg); del(); } + + /// Helper to delete objects from heap and reset the pointer. Saves many many lines of code + template <typename T> inline void releasePtr(T& arg) { + if (0 != arg) + arg->release(); + arg = 0; + } + + /// Functor to release objects from heap and reset the pointer + template <typename T> class ReleaseObject { + public: + void operator()(T& arg) const { + releasePtr(arg); + } + }; + /// Map Functor to release objects from heap + template <typename M> class ReleaseObjects { + public: + M& object; + ReleaseObjects(M& arg) : object(arg) { } + void operator()(std::pair<typename M::key_type, typename M::mapped_type> arg) const + { ReleaseObject<typename M::mapped_type>()(arg.second); } + void operator()() const { + if ( !object.empty() ) for_each(object.begin(),object.end(),(*this)); + object.clear(); + } + }; + template <typename M> ReleaseObject<typename M::value_type> releaseObject(M&) { + return ReleaseObject<typename M::value_type>(); + } + template <typename M> void releaseObjects(M& arg) { + ReleaseObjects<M> rel(arg); rel(); + } + template <typename M> void release2nd(M& arg) { + ReleaseObjects<M> rel(arg); rel(); + } + + /// Functor to delete objects from heap and reset the pointer + template <typename T> class ReferenceObject { + public: + typedef T arg_t; + T operator()(T arg) const { + if ( arg ) arg->addRef(); + return arg; + } + }; + /// Functor to delete objects from heap and reset the pointer + template <typename M> class ReferenceObjects { + public: + typedef typename M::second_type result_t; + result_t operator()(const M& arg) const { + return ReferenceObject<result_t>()(arg.second); + } + }; + template <typename M> ReferenceObject<M> referenceObject(M&) { + return ReferenceObject<typename M::value_type>(); + } + template <typename M> ReferenceObjects<typename M::value_type> reference2nd(M&) { + return ReferenceObjects<typename M::value_type>(); + } + + /// Member function call-functor with no arguments + template <typename R, typename T> struct ApplyMemFunc { + typedef R (T::*memfunc_t)(); + memfunc_t func; + ApplyMemFunc(memfunc_t f) : func(f) {} + void operator()(T* arg) const { if (arg) { (arg->*func)(); } } + }; + + /// Member function call-functor with 1 argument + template <typename R, typename T, typename A1> struct ApplyMemFunc1 { + typedef R (T::*memfunc_t)(A1 a1); + memfunc_t func; + A1& arg1; + ApplyMemFunc1(memfunc_t f, A1& a1) : func(f), arg1(a1) {} + void operator()(T* arg) const { if ( arg ) { (arg->*func)(arg1); } } + }; + + /// Member function call-functor with 2 arguments + template <typename R, typename T, typename A1, typename A2> struct ApplyMemFunc2 { + typedef R (T::*memfunc_t)(A1 a1, A2 a2); + memfunc_t func; + A1& arg1; + A2& arg2; + ApplyMemFunc2(memfunc_t f, A1& a1, A2& a2) : func(f), arg1(a1), arg2(a2) {} + void operator()( T* arg) const { if ( arg ) { (arg->*func)(arg1, arg2); } } + }; + + /// Member function call-functor with no arguments (const version) + template <typename R, typename T> struct ApplyMemFuncConst { + typedef R (T::*memfunc_t)() const; + memfunc_t func; + ApplyMemFuncConst(memfunc_t f) : func(f) {} + void operator()(const T* arg) const { if ( arg ) { (arg->*func)(); } } + }; + + /// Member function call-functor with 1 argument (const version) + template <typename R, typename T, typename A1> struct ApplyMemFuncConst1 { + typedef R (T::*memfunc_t)(A1 a1) const; + memfunc_t func; + A1& arg1; + ApplyMemFuncConst1(memfunc_t f, A1& a1) : func(f), arg1(a1) {} + void operator()(const T* arg) const { if ( arg ) { (arg->*func)(arg1); } } + }; + + /// Member function call-functor with 2 arguments (const version) + template <typename R, typename T, typename A1, typename A2> struct ApplyMemFuncConst2 { + typedef R (T::*memfunc_t)(A1 a1, A2 a2) const; + memfunc_t func; + A1& arg1; + A2& arg2; + ApplyMemFuncConst2(memfunc_t f, A1& a1, A2& a2) : func(f), arg1(a1), arg2(a2) {} + void operator()(const T* arg) const { if ( arg ) { (arg->*func)(arg1, arg2); } } + }; + + template <typename C, typename R, typename T> + void call_member_func(C& object, R (T::*pmf)()) + { std::for_each(object.begin(),object.end(),ApplyMemFunc<R,T>(pmf)); } + + template <typename C, typename R, typename T> + void call_member_func(C& object, R (T::*pmf)() const) + { std::for_each(object.begin(),object.end(),ApplyMemFuncConst<R,T>(pmf)); } + + template <typename C, typename R, typename T, typename A1> + void call_member_func(C& object, R (T::*pmf)(A1 a1), A1 a1) + { std::for_each(object.begin(),object.end(),ApplyMemFunc1<R,T,A1>(pmf,a1)); } + + template <typename C, typename R, typename T, typename A1> + void call_member_func(C& object, R (T::*pmf)(A1 a1) const, A1 a1) + { std::for_each(object.begin(),object.end(),ApplyMemFuncConst1<R,T,A1>(pmf,a1)); } + + + template <typename C, typename R, typename T, typename A1, typename A2> + void call_member_func(C& object, R (T::*pmf)(A1 a1,A2 a2), A1 a1, A2 a2) + { std::for_each(object.begin(),object.end(),ApplyMemFunc2<R,T,A1,A2>(pmf,a1,a2)); } + + template <typename C, typename R, typename T, typename A1, typename A2> + void call_member_func(C& object, R (T::*pmf)(A1 a1,A2 a2) const, A1 a1, A2 a2) + { std::for_each(object.begin(),object.end(),ApplyMemFuncConst2<R,T,A1,A2>(pmf,a1,a2)); } + + + /// Generic map Functor to act on first element (key) + template <typename M, typename FCN> class Apply1rst { + public: + const FCN& func; + Apply1rst(const FCN& f) : func(f) { } + void operator()(std::pair<typename M::key_type const, typename M::mapped_type>& arg) const + { (func)(arg.first); } + void operator()(const std::pair<typename M::key_type const, typename M::mapped_type>& arg) const + { (func)(arg.first); } + }; + + template <typename C, typename FCN> Apply1rst<C,FCN> apply__1rst_value(C&,const FCN& func) + { return Apply1rst<C,FCN>(func); } + + template <typename C, typename FCN> void apply1rst(C& object,const FCN& func) + { std::for_each(object.begin(),object.end(),apply__1rst_value(object,func)); } + + template <typename C, typename R, typename T> + void apply1rst(C& object, R (T::*pmf)()) + { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFunc<R,T>(pmf))); } + + template <typename C, typename R, typename T, typename A1> + void apply1rst(C object, R (T::*pmf)(A1 a1), A1 a1) + { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFunc1<R,T,A1>(pmf,a1))); } + + template <typename C, typename R, typename T> + void apply1rst(C& object, R (T::*pmf)() const) + { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFuncConst<R,T>(pmf))); } + + template <typename C, typename R, typename T, typename A1> + void apply1rst(C object, R (T::*pmf)(A1 a1) const, A1 a1) + { std::for_each(object.begin(),object.end(),apply__1rst_value(object,ApplyMemFuncConst1<R,T,A1>(pmf,a1))); } + + /// Generic map Functor to act on second element (mapped type) + template <typename M, typename FCN> class Apply2nd { + public: + const FCN& func; + Apply2nd(const FCN& f) : func(f) { } + void operator()(std::pair<typename M::key_type const, typename M::mapped_type>& arg) const + { (func)(arg.second); } + void operator()(const std::pair<typename M::key_type const, typename M::mapped_type>& arg) const + { (func)(arg.second); } + }; + + template <typename C, typename FCN> Apply2nd<C,FCN> apply__2nd_value(C&,const FCN& func) + { return Apply2nd<C,FCN>(func); } + + template <typename C, typename FCN> void apply2nd(C& object,const FCN& func) + { std::for_each(object.begin(),object.end(),apply__2nd_value(object,func)); } + + template <typename C, typename R, typename T> + void apply2nd(C& object, R (T::*pmf)()) + { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFunc<R,T>(pmf))); } + + template <typename C, typename R, typename T, typename A1> + void apply2nd(C object, R (T::*pmf)(A1 a1), A1 a1) + { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFunc1<R,T,A1>(pmf,a1))); } + + template <typename C, typename R, typename T> + void apply2nd(C& object, R (T::*pmf)() const) + { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFuncConst<R,T>(pmf))); } + + template <typename C, typename R, typename T, typename A1> + void apply2nd(C object, R (T::*pmf)(A1 a1) const, A1 a1) + { std::for_each(object.begin(),object.end(),apply__2nd_value(object,ApplyMemFuncConst1<R,T,A1>(pmf,a1))); } + + /// Data structure to manipulate a bitmask held by reference and represented by an integer + /** + * @author M.Frank + * @version 1.0 + */ + template <typename T> class ReferenceBitMask { + public: + /// Reference to the data + T& mask; + /// Standard constructor + ReferenceBitMask(T& arg); + T value() const { + return mask; + } + void set(const T& arg) { + mask |= arg; + } + void clear(const T& arg) { + mask &= ~arg; + } + void clear() { + mask = 0; + } + bool isSet(const T& arg) const { + return (mask&arg) == arg; + } + bool anySet(const T& arg) const { + return (mask&arg) != 0; + } + bool testBit(int bit) const { + T arg = T(1)<<bit; + return isSet(arg); + } + bool isNull() const { + return mask == 0; + } + }; + /// Standard constructor + template <typename T> ReferenceBitMask<T>::ReferenceBitMask(T& arg) : mask(arg) {} + + } // End namespace detail +} // End namespace dd4hep +#endif // DD4HEP_PARSERS_PRIMITIVES_H diff --git a/DDCore/include/Parsers/Printout.h b/DDCore/include/Parsers/Printout.h new file mode 100644 index 000000000..534d78286 --- /dev/null +++ b/DDCore/include/Parsers/Printout.h @@ -0,0 +1,319 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_PARSERS_PRINTOUT_H +#define DD4HEP_PARSERS_PRINTOUT_H + +// Framework include files +#include "Parsers/config.h" + +// C/C++ include files +#include <cstdio> +#include <cstdlib> +#include <cstdarg> +#include <map> +#include <string> +#include <sstream> +#include <iostream> + +/// Forward declarations +class TNamed; + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + + // Forward declarations + class Detector; + class NamedObject; + template <typename T> class Handle; + + enum PrintLevel { + NOLOG = 0, + VERBOSE = 1, + DEBUG = 2, + INFO = 3, + WARNING = 4, + ERROR = 5, + FATAL = 6, + ALWAYS = 7 + }; + +#ifndef __CINT__ + typedef size_t (*output_function1_t)(void*, PrintLevel severity, const char*, const char*); + typedef size_t (*output_function2_t)(void*, PrintLevel severity, const char*, const char*, va_list& args); + + /// Helper function to serialize argument list to a single string + /** + * @arg argc [int,read-only] Number of arguments. + * @arg argv [char**,read-only] Argument strings + * @return String containing the concatenated arguments + */ + std::string arguments(int argc, char** argv); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg str [stringstream, RW] string stream containing data to be printed. + * Object is reset after use. + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const char* src, std::stringstream& str); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg str [stringstream, RW] string stream containing data to be printed. + * Object is reset after use. + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const std::string& src, std::stringstream& str); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const char* src, const char* fmt, ...); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const std::string& src, const char* fmt, ...); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const std::string& src, const std::string& fmt, ...); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const char* src, const std::string& fmt, ...); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const char* src, const char* fmt, va_list& args); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const std::string& src, const char* fmt, va_list& args); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const std::string& src, const std::string& fmt, va_list& args); + + /// Calls the display action with a given severity level + /** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + int printout(PrintLevel severity, const char* src, const std::string& fmt, va_list& args); + + /// Calls the display action with ERROR and throws an std::runtime_error exception + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + int except(const std::string& src, const std::string& fmt, ...); + + /// Calls the display action with ERROR and throws an std::runtime_error exception + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + int except(const char* src, const char* fmt, ...); + + /// Calls the display action with ERROR and throws an std::runtime_error exception + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + int except(const std::string& src, const std::string& fmt, va_list& args); + + /// Calls the display action with ERROR and throws an std::runtime_error exception + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + int except(const char* src, const char* fmt, va_list& args); + + /// Build formatted string + /* + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + std::string format(const std::string& src, const std::string& fmt, ...); + + /// Build exception string + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @return Status code indicating success or failure + */ + std::string format(const char* src, const char* fmt, ...); + + /// Build formatted string + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + std::string format(const std::string& src, const std::string& fmt, va_list& args); + + /// Build formatted string + /** + * @arg src [string,read-only] Information source (component, etc.) + * @arg fmt [string,read-only] Format string for ellipsis args + * @arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * @return Status code indicating success or failure + */ + std::string format(const char* src, const char* fmt, va_list& args); + + /// Customize printer function + void setPrinter(void* print_arg, output_function1_t fcn); + + /// Customize printer function + void setPrinter2(void* print_arg, output_function2_t fcn); + +#endif // __CINT__ + + /// Set new printout format for the 3 fields: source-level-message. All 3 are strings + std::string setPrintFormat(const std::string& new_format); + + /// Set new print level. Returns the old print level + PrintLevel setPrintLevel(PrintLevel new_level); + + /// Access the current printer level + PrintLevel printLevel(); + + /// Translate the printer level from string to value + PrintLevel printLevel(const char* value); + + /// Translate the printer level from string to value + PrintLevel printLevel(const std::string& value); + + /// Check if this print level would result in some output + bool isActivePrintLevel(int severity); + + /// Helper class template to implement ASCII object dumps + /** @class Printer Conversions.h dd4hep/compact/Conversions.h + * + * Small helper class to print objects + * + * @author M.Frank + * @version 1.0 + */ + template <typename T> struct Printer { + /// Reference to the detector description object + const Detector* description; + /// Reference to the output stream object, the Printer object should write + std::ostream& os; + /// Optional text prefix when formatting the output + std::string prefix; + /// Initializing constructor of the functor + Printer(const Detector* l, std::ostream& stream, const std::string& p = "") + : description(l), os(stream), prefix(p) { + } + /// Callback operator to be specialized depending on the element type + void operator()(const T& value) const; + }; + + template <typename T> inline std::ostream& print(const T& object, std::ostream& os = std::cout, + const std::string& indent = "") { + Printer<T>(0, os, indent)(object); + return os; + } + + /// Helper class template to implement ASCII dumps of named objects maps + /** @class PrintMap Conversions.h dd4hep/compact/Conversions.h + * + * Small helper class to print maps of objects + * + * @author M.Frank + * @version 1.0 + */ + template <typename T> struct PrintMap { + typedef T item_type; + typedef const std::map<std::string, Handle<NamedObject> > cont_type; + + /// Reference to the detector description object + const Detector* description; + /// Reference to the output stream object, the Printer object should write + std::ostream& os; + /// Optional text prefix when formatting the output + std::string text; + /// Reference to the container data of the map. + cont_type& cont; + /// Initializing constructor of the functor + PrintMap(const Detector* l, std::ostream& stream, cont_type& c, const std::string& t = "") + : description(l), os(stream), text(t), cont(c) { + } + /// Callback operator to be specialized depending on the element type + void operator()() const; + }; + + /// Helper function to print booleans in format YES/NO + inline const char* yes_no(bool value) { + return value ? "YES" : "NO "; + } + /// Helper function to print booleans in format true/false + inline const char* true_false(bool value) { + return value ? "true " : "false"; + } + +} /* End namespace dd4hep */ +#endif /* DD4HEP_PARSERS_PRINTOUT_H */ diff --git a/DDCore/include/XML/detail/ChildValue.h b/DDCore/include/Parsers/detail/ChildValue.h similarity index 100% rename from DDCore/include/XML/detail/ChildValue.h rename to DDCore/include/Parsers/detail/ChildValue.h diff --git a/DDCore/include/XML/detail/ChildValue.imp b/DDCore/include/Parsers/detail/ChildValue.imp similarity index 100% rename from DDCore/include/XML/detail/ChildValue.imp rename to DDCore/include/Parsers/detail/ChildValue.imp diff --git a/DDCore/include/XML/detail/ChildValue.inl b/DDCore/include/Parsers/detail/ChildValue.inl similarity index 100% rename from DDCore/include/XML/detail/ChildValue.inl rename to DDCore/include/Parsers/detail/ChildValue.inl diff --git a/DDCore/include/XML/detail/Conversions.h b/DDCore/include/Parsers/detail/Conversions.h similarity index 98% rename from DDCore/include/XML/detail/Conversions.h rename to DDCore/include/Parsers/detail/Conversions.h index 7da6ba1ff..f764136fc 100644 --- a/DDCore/include/XML/detail/Conversions.h +++ b/DDCore/include/Parsers/detail/Conversions.h @@ -24,11 +24,14 @@ #include <iostream> // Framework include files -#include "DD4hep/Detector.h" + /// Namespace for the AIDA detector description toolkit namespace dd4hep { + /// Forward declaration + class Detector; + /// Namespace for the AIDA detector description toolkit supporting XML utilities namespace DD4HEP_CONVERSION_NS { class Handle_t; diff --git a/DDCore/include/XML/detail/Detector.h b/DDCore/include/Parsers/detail/Detector.h similarity index 100% rename from DDCore/include/XML/detail/Detector.h rename to DDCore/include/Parsers/detail/Detector.h diff --git a/DDCore/include/XML/detail/Detector.imp b/DDCore/include/Parsers/detail/Detector.imp similarity index 100% rename from DDCore/include/XML/detail/Detector.imp rename to DDCore/include/Parsers/detail/Detector.imp diff --git a/DDCore/include/XML/detail/Dimension.h b/DDCore/include/Parsers/detail/Dimension.h similarity index 100% rename from DDCore/include/XML/detail/Dimension.h rename to DDCore/include/Parsers/detail/Dimension.h diff --git a/DDCore/include/XML/detail/Dimension.imp b/DDCore/include/Parsers/detail/Dimension.imp similarity index 100% rename from DDCore/include/XML/detail/Dimension.imp rename to DDCore/include/Parsers/detail/Dimension.imp diff --git a/DDCore/include/XML/detail/Dimension.inl b/DDCore/include/Parsers/detail/Dimension.inl similarity index 100% rename from DDCore/include/XML/detail/Dimension.inl rename to DDCore/include/Parsers/detail/Dimension.inl diff --git a/DDCore/include/XML/detail/README.txt b/DDCore/include/Parsers/detail/README.txt similarity index 97% rename from DDCore/include/XML/detail/README.txt rename to DDCore/include/Parsers/detail/README.txt index bf32aaf80..9a693c211 100644 --- a/DDCore/include/XML/detail/README.txt +++ b/DDCore/include/Parsers/detail/README.txt @@ -1,4 +1,4 @@ - +f XML/detail ---------- @@ -25,7 +25,7 @@ underlying implementation is based on: -- TinyXML --> uses the XML branch (default) -- JSON --> Uses the JSON branch (requires boost presence) with the implementation of boost::property_tree --- RapitXML --> Not implmented. +-- RapidXML --> Not implmented. Would be a jiffy to implement using the JSON branch and the implementation of boost::property_tree. Only the document handling is different. diff --git a/DDCore/include/XML/Conversions.h b/DDCore/include/XML/Conversions.h index f89015093..7ab31e6d3 100644 --- a/DDCore/include/XML/Conversions.h +++ b/DDCore/include/XML/Conversions.h @@ -14,7 +14,7 @@ #define DD4HEP_COMPACT_CONVERSION_H #define DD4HEP_CONVERSION_NS xml -#include "XML/detail/Conversions.h" +#include "Parsers/detail/Conversions.h" #undef DD4HEP_CONVERSION_NS #endif /* DD4HEP_COMPACT_CONVERSION_H */ diff --git a/DDCore/include/XML/Evaluator.h b/DDCore/include/XML/Evaluator.h new file mode 100644 index 000000000..8e395fb59 --- /dev/null +++ b/DDCore/include/XML/Evaluator.h @@ -0,0 +1,24 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_DDCORE_JSON_EVALUATOR_H +#define DD4HEP_DDCORE_JSON_EVALUATOR_H + +// Forwarding printout functionality to dd4hep +/** Note: This is necessary to use the JSON functionality as a standalone + * utility without the need to externalize the world. + * + * See the externalized header in doc/externalize for details. + */ +#include "Evaluator/Evaluator.h" + +#endif /* DD4HEP_DDCORE_JSON_EVALUATOR_H */ diff --git a/DDCore/include/XML/Printout.h b/DDCore/include/XML/Printout.h index f09259dbb..cfa38a6ae 100644 --- a/DDCore/include/XML/Printout.h +++ b/DDCore/include/XML/Printout.h @@ -10,15 +10,15 @@ // Author : M.Frank // //========================================================================== -#ifndef DD4HEP_DDCORE_XML_PRINTOUT_H -#define DD4HEP_DDCORE_XML_PRINTOUT_H +#ifndef DD4HEP_XML_PRINTOUT_H +#define DD4HEP_XML_PRINTOUT_H // Forwarding printout functionality to dd4hep -/** Note: This is necessary to use the XML functionality as a standalone +/** Note: This is necessary to use the JSON functionality as a standalone * utility without the need to externalize the world. * * See the externalized header in doc/externalize for details. */ -#include "DD4hep/Printout.h" +#include "Parsers/Printout.h" -#endif /* DD4HEP_DDCORE_XML_PRINTOUT_H */ +#endif /* DD4HEP_XML_PRINTOUT_H */ diff --git a/DDCore/include/XML/XMLChildValue.h b/DDCore/include/XML/XMLChildValue.h index 0013fd183..d3af31ed4 100644 --- a/DDCore/include/XML/XMLChildValue.h +++ b/DDCore/include/XML/XMLChildValue.h @@ -18,7 +18,7 @@ #include "XML/XMLTags.h" #define DD4HEP_DIMENSION_NS xml -#include "XML/detail/ChildValue.h" +#include "Parsers/detail/ChildValue.h" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_XML_XMLCHILDVALUE_H */ diff --git a/DDCore/include/XML/XMLChildValue.inl b/DDCore/include/XML/XMLChildValue.inl index 346e197ab..7927acab5 100644 --- a/DDCore/include/XML/XMLChildValue.inl +++ b/DDCore/include/XML/XMLChildValue.inl @@ -18,7 +18,7 @@ #include "XML/XMLChildValue.h" #define DD4HEP_DIMENSION_NS xml -#include "XML/detail/ChildValue.inl" +#include "Parsers/detail/ChildValue.inl" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_XML_XMLCHILDVALUE_INL */ diff --git a/DDCore/include/XML/XMLDetector.h b/DDCore/include/XML/XMLDetector.h index 6f0b63fae..d6212c951 100644 --- a/DDCore/include/XML/XMLDetector.h +++ b/DDCore/include/XML/XMLDetector.h @@ -17,7 +17,7 @@ #include "XML/XMLDimension.h" #define DD4HEP_DIMENSION_NS xml -#include "XML/detail/Detector.h" +#include "Parsers/detail/Detector.h" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_XMLDETECTOR_H */ diff --git a/DDCore/include/XML/XMLDimension.h b/DDCore/include/XML/XMLDimension.h index 9cdc52b5a..8f2a3f434 100644 --- a/DDCore/include/XML/XMLDimension.h +++ b/DDCore/include/XML/XMLDimension.h @@ -18,7 +18,7 @@ #include "XML/XMLTags.h" #define DD4HEP_DIMENSION_NS xml -#include "XML/detail/Dimension.h" +#include "Parsers/detail/Dimension.h" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_XML_XMLDIMENSION_H */ diff --git a/DDCore/include/XML/XMLDimension.inl b/DDCore/include/XML/XMLDimension.inl index a9af04f48..3c962a7e3 100644 --- a/DDCore/include/XML/XMLDimension.inl +++ b/DDCore/include/XML/XMLDimension.inl @@ -17,7 +17,7 @@ #include "XML/XMLDimension.h" #define DD4HEP_DIMENSION_NS xml -#include "XML/detail/Dimension.inl" +#include "Parsers/detail/Dimension.inl" #undef DD4HEP_DIMENSION_NS #endif /* DD4HEP_XMLDIMENSION_INL */ diff --git a/DDCore/include/XML/XMLElements.h b/DDCore/include/XML/XMLElements.h index f7fa8b084..d62cfe03f 100644 --- a/DDCore/include/XML/XMLElements.h +++ b/DDCore/include/XML/XMLElements.h @@ -21,7 +21,6 @@ // Framework include files #include "XML/config.h" -//#include "DD4hep/Primitives.h" #ifndef RAD_2_DEGREE #define RAD_2_DEGREE 57.295779513082320876798154814105 diff --git a/DDCore/include/XML/config.h b/DDCore/include/XML/config.h index 7c828c2fc..0f2912fac 100644 --- a/DDCore/include/XML/config.h +++ b/DDCore/include/XML/config.h @@ -17,6 +17,8 @@ #ifndef DD4HEP_XML_CONFIG_H #define DD4HEP_XML_CONFIG_H +#include "Parsers/config.h" + #if defined(DD4HEP_USE_TINYXML) #define __TIXML__ #endif @@ -56,4 +58,4 @@ namespace dd4hep { #else // Xerces-C #define XML_IMPLEMENTATION_TYPE " Apache Xerces-C DOM Parser" #endif // __TIXML__ -#endif // DD4HEP_XML_CONFIG_H +#endif // DD4HEP_XML_CONFIG_H diff --git a/DDCore/src/AlignmentData.cpp b/DDCore/src/AlignmentData.cpp index 40349994b..1a8fdff95 100644 --- a/DDCore/src/AlignmentData.cpp +++ b/DDCore/src/AlignmentData.cpp @@ -201,8 +201,7 @@ Alignment AlignmentData::nominal() const { return detector.nominal(); } -#include "DDParsers/Parsers.h" -#include "DDParsers/ToStream.h" +#include "Parsers/Parsers.h" DD4HEP_DEFINE_PARSER_DUMMY(Delta) DD4HEP_DEFINE_PARSER_DUMMY(AlignmentData) diff --git a/DDCore/src/AlignmentsInterna.cpp b/DDCore/src/AlignmentsInterna.cpp index 8aa2ffa49..db86ff023 100644 --- a/DDCore/src/AlignmentsInterna.cpp +++ b/DDCore/src/AlignmentsInterna.cpp @@ -64,8 +64,7 @@ void AlignmentObject::clear() { } -#include "DDParsers/Parsers.h" -#include "DDParsers/ToStream.h" +#include "Parsers/Parsers.h" DD4HEP_DEFINE_PARSER_DUMMY(AlignmentObject) #include "DD4hep/detail/BasicGrammar_inl.h" diff --git a/DDCore/src/AlignmentsPrinter.cpp b/DDCore/src/AlignmentsPrinter.cpp index 23e95fba8..6808a167e 100644 --- a/DDCore/src/AlignmentsPrinter.cpp +++ b/DDCore/src/AlignmentsPrinter.cpp @@ -20,7 +20,7 @@ // C/C++ include files #include <sstream> #include "TClass.h" -#include "DDParsers/ToStream.h" +#include "Parsers/spirit/ToStream.h" using namespace std; using namespace dd4hep; diff --git a/DDCore/src/ConditionsData.cpp b/DDCore/src/ConditionsData.cpp index 9e5bba897..6742827ed 100644 --- a/DDCore/src/ConditionsData.cpp +++ b/DDCore/src/ConditionsData.cpp @@ -77,8 +77,7 @@ AbstractMap& AbstractMap::operator=(const AbstractMap& c) { return *this; } -#include "DDParsers/Parsers.h" -#include "DDParsers/ToStream.h" +#include "Parsers/Parsers.h" DD4HEP_DEFINE_PARSER_DUMMY(AbstractMap) #include "DD4hep/detail/BasicGrammar_inl.h" #include "DD4hep/detail/ConditionsInterna.h" diff --git a/DDCore/src/ConditionsPrinter.cpp b/DDCore/src/ConditionsPrinter.cpp index d7ab23d40..42a729fd2 100644 --- a/DDCore/src/ConditionsPrinter.cpp +++ b/DDCore/src/ConditionsPrinter.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework includes -#include "DDParsers/ToStream.h" +#include "Parsers/spirit/ToStream.h" #include "DD4hep/Printout.h" #include "DD4hep/ConditionsData.h" #include "DD4hep/ConditionsPrinter.h" diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index f61c0e0a0..907e0fae2 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -14,7 +14,7 @@ #include "DD4hep/InstanceCount.h" #include "DD4hep/Printout.h" #include "DD4hep/detail/Handle.inl" -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" #include <iostream> #include <iomanip> #include <climits> diff --git a/DDCore/src/JSON/Detector.cpp b/DDCore/src/JSON/Detector.cpp new file mode 100644 index 000000000..2d4498fca --- /dev/null +++ b/DDCore/src/JSON/Detector.cpp @@ -0,0 +1,23 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_NONE + +// Framework include files +#include "JSON/Detector.h" + +// Instantiate here the concrete implementations +#define DD4HEP_DIMENSION_NS json +using namespace dd4hep::DD4HEP_DIMENSION_NS; + +#include "Parsers/detail/Detector.imp" +#endif diff --git a/DDCore/src/JSON/Elements.cpp b/DDCore/src/JSON/Elements.cpp index 165dbae07..ec56f3ac8 100644 --- a/DDCore/src/JSON/Elements.cpp +++ b/DDCore/src/JSON/Elements.cpp @@ -15,7 +15,6 @@ #include "JSON/Printout.h" #include "JSON/Evaluator.h" #include "JSON/Elements.h" -//#include "XML/XMLTags.h" // C/C++ include files #include <iostream> diff --git a/DDCore/src/JSON/Helpers.cpp b/DDCore/src/JSON/Helpers.cpp index fe2d8e665..bd8bcbff4 100644 --- a/DDCore/src/JSON/Helpers.cpp +++ b/DDCore/src/JSON/Helpers.cpp @@ -12,7 +12,6 @@ //========================================================================== // Framework include files -#include "JSON/Detector.h" #include "JSON/Dimension.inl" #include "JSON/ChildValue.inl" @@ -20,6 +19,5 @@ #define DD4HEP_DIMENSION_NS json using namespace dd4hep::DD4HEP_DIMENSION_NS; -#include "XML/detail/Detector.imp" -#include "XML/detail/Dimension.imp" -#include "XML/detail/ChildValue.imp" +#include "Parsers/detail/Dimension.imp" +#include "Parsers/detail/ChildValue.imp" diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp index 9f5543cb9..16c2d0701 100644 --- a/DDCore/src/OpaqueData.cpp +++ b/DDCore/src/OpaqueData.cpp @@ -176,8 +176,8 @@ std::ostream& operator << (std::ostream& s, const OpaqueDataBlock& data) { s << data.str(); return s; } -#include "DDParsers/Parsers.h" -#include "DDParsers/ToStream.h" + +#include "Parsers/Parsers.h" DD4HEP_DEFINE_PARSER_DUMMY(OpaqueDataBlock) #include "DD4hep/detail/BasicGrammar_inl.h" diff --git a/DDCore/src/Parsers/Exceptions.cpp b/DDCore/src/Parsers/Exceptions.cpp new file mode 100755 index 000000000..29d1f7397 --- /dev/null +++ b/DDCore/src/Parsers/Exceptions.cpp @@ -0,0 +1,29 @@ +//========================================================================== +// 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 "Parsers/Exceptions.h" +#include "Parsers/Primitives.h" + +using namespace std; +using namespace dd4hep; + +string unrelated_type_error::msg(const type_info& typ1, const type_info& typ2, const string& text) { + string m = "The types " + typeName(typ1) + " and " + typeName(typ2) + " are not related. " + text; + return m; +} + +string unrelated_value_error::msg(const type_info& typ, const string& text) { + string m = "The type " + typeName(typ) + " cannot be converted: " + text; + return m; +} diff --git a/DDCore/src/Parsers/Primitives.cpp b/DDCore/src/Parsers/Primitives.cpp new file mode 100755 index 000000000..7af056d34 --- /dev/null +++ b/DDCore/src/Parsers/Primitives.cpp @@ -0,0 +1,531 @@ +//========================================================================== +// 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 "Parsers/Primitives.h" +#include "Parsers/Exceptions.h" +#include "Parsers/Printout.h" + +// C/C++ include files +#include <algorithm> +#include <functional> +#include <numeric> +#include <stdexcept> +#include <cstdint> +#include <cstring> +#include <map> + +#if defined(__linux) || defined(__APPLE__) +#include <cxxabi.h> +#ifndef __APPLE__ +typedef abi::__class_type_info class_t; +using abi::__dynamic_cast; +#endif +#endif + +/// Local Utilities +namespace { + +#if 0 +//----------------------------------------------------------------------------- +// MurmurHash2, 64-bit versions, by Austin Appleby +// +// The same caveats as 32-bit MurmurHash2 apply here - beware of alignment +// and endian-ness issues if used across multiple platforms. + inline uint64_t murmur_hash_64 ( const void * key, int len) { +#define seed 0xFEEDBABE + typedef unsigned long long int uint64; + +#if INTPTR_MAX == INT32_MAX + const unsigned int * data = (const unsigned int *)key; + const unsigned int m = 0x5bd1e995; + const int r = 24; + + unsigned int h1 = seed ^ len; + unsigned int h2 = 0; + + while(len >= 8) + { + unsigned int k1 = *data++; + k1 *= m; k1 ^= k1 >> r; k1 *= m; + h1 *= m; h1 ^= k1; + len -= 4; + + unsigned int k2 = *data++; + k2 *= m; k2 ^= k2 >> r; k2 *= m; + h2 *= m; h2 ^= k2; + len -= 4; + } + + if(len >= 4) + { + unsigned int k1 = *data++; + k1 *= m; k1 ^= k1 >> r; k1 *= m; + h1 *= m; h1 ^= k1; + len -= 4; + } + + switch(len) + { + case 3: h2 ^= ((unsigned char*)data)[2] << 16; + case 2: h2 ^= ((unsigned char*)data)[1] << 8; + case 1: h2 ^= ((unsigned char*)data)[0]; + h2 *= m; + }; + + h1 ^= h2 >> 18; h1 *= m; + h2 ^= h1 >> 22; h2 *= m; + h1 ^= h2 >> 17; h1 *= m; + h2 ^= h1 >> 19; h2 *= m; + + uint64 h = h1; + + h = (h << 32) | h2; +#elif INTPTR_MAX == INT64_MAX + const uint64* data = (const uint64*)key; + const uint64 m = 0xc6a4a7935bd1e995; + const int r = 47; + + uint64 h = seed ^ (len * m); + + const uint64 * end = data + (len/8); + + while(data != end) + { + uint64 k = *data++; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; + } + + const unsigned char * data2 = (const unsigned char*)data; + + switch(len & 7) + { + case 7: h ^= uint64(data2[6]) << 48; + case 6: h ^= uint64(data2[5]) << 40; + case 5: h ^= uint64(data2[4]) << 32; + case 4: h ^= uint64(data2[3]) << 24; + case 3: h ^= uint64(data2[2]) << 16; + case 2: h ^= uint64(data2[1]) << 8; + case 1: h ^= uint64(data2[0]); + h *= m; + }; + + h ^= h >> r; + h *= m; + h ^= h >> r; + +#else +#error "Environment not 32 or 64-bit." +#endif + return h; + } +#endif + + struct FNV1a_64 { + static const unsigned long long int hashinit = 14695981039346656037ull; + static constexpr unsigned long long int doByte(unsigned long long int hash,unsigned char val) + { return (hash ^ val) * 1099511628211ull; } + }; +} + +/// Convert volumeID to string format (016X) +std::string dd4hep::volumeID(VolumeID vid) { + char text[32]; + ::snprintf(text,sizeof(text),"%016llx",vid); + return text; +} + +/// We need it so often: one-at-time 64 bit hash function +unsigned long long int dd4hep::detail::hash64(const char* key) { + //return murmur_hash_64(key, strlen(key)); + unsigned char* str = (unsigned char*)key; + unsigned long long int hash = FNV1a_64::hashinit; + for ( ; *str; ++str) hash = FNV1a_64::doByte(hash, *str); + return hash; +} + +unsigned long long int dd4hep::detail::hash64(const std::string& key) { + //return murmur_hash_64(key.data(), key.length()); + return std::accumulate(begin(key),end(key),FNV1a_64::hashinit,FNV1a_64::doByte); +} + +long int dd4hep::detail::makeTime(int year, int month, int day, + int hour, int minutes, int seconds) +{ + struct tm tm_init; + ::memset(&tm_init,0,sizeof(tm_init)); + tm_init.tm_year = year > 1900 ? year-1900 : year; + tm_init.tm_mon = month; + tm_init.tm_mday = day; + tm_init.tm_hour = hour; + tm_init.tm_min = minutes; + tm_init.tm_sec = seconds; + tm_init.tm_isdst = -1; + long int ti = ::mktime(&tm_init); + if ( ti >= 0 ) return ti; + except("dd4hep","Invalid time data given for conversion to epoch: %d-%d-%d %02d:%02d:%02d", + year, month, day, hour, minutes, seconds); + return ti; +} + +/// Convert date into epoch time (seconds since 1970) +long int dd4hep::detail::makeTime(const std::string& date, const char* fmt) { + struct tm tm; + char* c = ::strptime(date.c_str(),fmt,&tm); + if ( 0 == c ) { + except("dd4hep", + "Invalid time format given for update:%s should be: %s", + date.c_str(), fmt); + } + long ti = ::mktime(&tm); + if ( ti >= 0 ) return ti; + except("dd4hep", + "Invalid time string given for conversion to epoch: %s (fmt='%s')", + date.c_str(), fmt); + return ti; +} + +static const std::string __typeinfoName(const std::type_info& tinfo) { + const char* class_name = tinfo.name(); + std::string result; +#ifdef WIN32 + std::size_t off = 0; + if ( ::strncmp(class_name, "class ", 6) == 0 ) { + // The returned name is prefixed with "class " + off = 6; + } + if ( ::strncmp(class_name, "struct ", 7) == 0 ) { + // The returned name is prefixed with "struct " + off = 7; + } + if ( off != std::string::npos ) { + std::string tmp = class_name + off; + size_t loc = 0; + while( (loc = tmp.find("class ")) != std::string::npos ) { + tmp.erase(loc, 6); + } + loc = 0; + while( (loc = tmp.find("struct ")) != std::string::npos ) { + tmp.erase(loc, 7); + } + result = tmp; + } + else { + result = class_name; + } + // Change any " *" to "*" + while ( (off=result.find(" *")) != std::string::npos ) { + result.replace(off, 2, "*"); + } + // Change any " &" to "&" + while ( (off=result.find(" &")) != std::string::npos ) { + result.replace(off, 2, "&"); + } +#elif defined(sun) + result = class_name; +#elif !defined(__ICC) + if (::strlen(class_name) == 1) { + // See http://www.realitydiluted.com/mirrors/reality.sgi.com/dehnert_engr/cxx/abi.pdf + // for details + switch (class_name[0]) { + case 'v': + result = "void"; + break; + case 'w': + result = "wchar_t"; + break; + case 'b': + result = "bool"; + break; + case 'c': + result = "char"; + break; + case 'h': + result = "unsigned char"; + break; + case 's': + result = "short"; + break; + case 't': + result = "unsigned short"; + break; + case 'i': + result = "int"; + break; + case 'j': + result = "unsigned int"; + break; + case 'l': + result = "long"; + break; + case 'm': + result = "unsigned long"; + break; + case 'x': + result = "long long"; + break; + case 'y': + result = "unsigned long long"; + break; + case 'n': + result = "__int128"; + break; + case 'o': + result = "unsigned __int128"; + break; + case 'f': + result = "float"; + break; + case 'd': + result = "double"; + break; + case 'e': + result = "long double"; + break; + case 'g': + result = "__float128"; + break; + case 'z': + result = "ellipsis"; + break; + } + } + else { + char buff[16 * 1024]; + std::size_t len = sizeof(buff); + int status = 0; + result = __cxxabiv1::__cxa_demangle(class_name, buff, &len, &status); + } +#else + result = class_name; + throw std::runtime_error("CXXABI is missing for ICC!"); +#endif + return result; +} + +std::string dd4hep::typeName(const std::type_info& typ) { + return __typeinfoName(typ); +} + +void dd4hep::invalidHandleError(const std::type_info& type) +{ + throw invalid_handle_exception("Attempt to access invalid object of type "+typeName(type)+" [Invalid Handle]"); +} + +void dd4hep::invalidHandleAssignmentError(const std::type_info& from, + const std::type_info& to) +{ + std::string msg = "Wrong assingment from "; + msg += typeName(from); + msg += " to "; + msg += typeName(to); + msg += " not possible!!"; + throw invalid_handle_exception(msg); +} + +/// Throw exception when handles are check for validity +void dd4hep::notImplemented(const std::string& msg) +{ + std::string m = "The requested feature " + msg + " is not implemented!"; + throw std::runtime_error(m); +} + +void dd4hep::typeinfoCheck(const std::type_info& typ1, const std::type_info& typ2, const std::string& text) +{ + if (typ1 != typ2) { + throw unrelated_type_error(typ1, typ2, text); + } +} + +namespace dd4hep { + namespace detail { + template<> const char* Primitive<bool>::default_format() { return "%d"; } + template<> const char* Primitive<char>::default_format() { return "%c"; } + template<> const char* Primitive<unsigned char>::default_format() { return "%02X"; } + template<> const char* Primitive<short>::default_format() { return "%d"; } + template<> const char* Primitive<unsigned short>::default_format() { return "%04X"; } + template<> const char* Primitive<int>::default_format() { return "%d"; } + template<> const char* Primitive<unsigned int>::default_format() { return "%08X"; } + template<> const char* Primitive<long>::default_format() { return "%ld"; } + template<> const char* Primitive<unsigned long>::default_format() { return "%016X"; } + template<> const char* Primitive<float>::default_format() { return "%f"; } + template<> const char* Primitive<double>::default_format() { return "%g"; } + template<> const char* Primitive<char*>::default_format() { return "%s"; } + template<> const char* Primitive<const char*>::default_format() { return "%s"; } + template<> const char* Primitive<std::string>::default_format() { return "%s"; } + + /// Generic function to convert to string + template <typename T> std::string Primitive<T>::toString(T value) { + char text[1024]; + ::snprintf(text,sizeof(text),default_format(),value); + return text; + } + + /// Convert string to string + template <> std::string Primitive<const char*>::toString(const char* value) { + if ( value ) { + return value; + } + throw std::runtime_error("Failed to convert (char*)NULL to std::string!"); + } + /// Convert string to string + template <> std::string Primitive<char*>::toString(char* value) { + if ( value ) { + return value; + } + throw std::runtime_error("Failed to convert (char*)NULL to std::string!"); + } + /// Convert string to string + template <> std::string Primitive<std::string>::toString(std::string value) { + return value; + } + + template std::string Primitive<bool>::toString(bool value); + template std::string Primitive<char>::toString(char value); + template std::string Primitive<unsigned char>::toString(unsigned char value); + template std::string Primitive<short>::toString(short value); + template std::string Primitive<unsigned short>::toString(unsigned short value); + template std::string Primitive<int>::toString(int value); + template std::string Primitive<unsigned int>::toString(unsigned int value); + template std::string Primitive<long>::toString(long value); + template std::string Primitive<unsigned long>::toString(unsigned long value); + template std::string Primitive<float>::toString(float value); + template std::string Primitive<double>::toString(double value); + } +} + +/// Initializing Constructor +dd4hep::ComponentCast::ComponentCast(const std::type_info& t, destroy_t d, cast_t c) + : type(t), destroy(d), cast(c) { +#ifdef __APPLE__ + abi_class = 0; +#else + abi_class = dynamic_cast<const class_t*>(&type); + if (!abi_class) { + throw std::runtime_error("Class type " + typeName(type) + " is not an abi object type!"); + } +#endif +} + +/// Defautl destructor +dd4hep::ComponentCast::~ComponentCast() { +} + +#if 0 +// Dynamic cast runtime. +// src2dst has the following possible values +// >-1: src_type is a unique public non-virtual base of dst_type +// dst_ptr + src2dst == src_ptr +// -1: unspecified relationship +// -2: src_type is not a public base of dst_type +// -3: src_type is a multiple public non-virtual base of dst_type +extern "C" void* +__dynamic_cast(const void* __src_ptr,// Starting object. + const abi::__class_type_info* __src_type,// Static type of object. + const abi::__class_type_info* __dst_type,// Desired target type. + ptrdiff_t __src2dst);// How src and dst are related. +#endif +#if 0 +#ifndef __APPLE__ +static inline void* cast_wrap(const void* p, + const abi::__class_type_info* src, + const abi::__class_type_info* dst, + ptrdiff_t src2dst) +{ + return abi::__dynamic_cast(p,src,dst,src2dst); +} +#endif +#endif + +/// Apply cast using typeinfo instead of dynamic_cast +void* dd4hep::ComponentCast::apply_dynCast(const ComponentCast& to, const void* ptr) const +{ + if (&to == this) { + return (void*) ptr; + } +#ifdef __APPLE__ + // First try down cast + void *r = (*to.cast)(ptr); + if (r) + return r; + // Now try the up-cast + r = (*cast)(ptr); + if (r) return r; + throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); +#else + void* r = (void*)ptr; + if ( to.abi_class ) { + bool cast_worked = type.__do_upcast((const class_t*)to.abi_class,&r); + if ( cast_worked ) return r; + r = (void*)ptr; + cast_worked = to.type.__do_upcast((const class_t*)abi_class,&r); + if ( cast_worked ) return r; +#if 0 + const class_t* src_type = (const class_t*)to.abi_class; + if (src_type) { + // First try down cast + void *r = cast_wrap(ptr, src_type, (const class_t*) abi_class, -1); + if ( r ) return r; + // Now try the up-cast + r = cast_wrap(ptr, (const class_t*) abi_class, src_type, -1); + if (r) return r; + } +#endif + throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); + } + throw unrelated_type_error(type, to.type, "Target type is not an abi class type!"); +#endif +} + +/// Apply cast using typeinfo instead of dynamic_cast +void* dd4hep::ComponentCast::apply_upCast(const ComponentCast& to, const void* ptr) const +{ + if (&to == this) { + return (void*) ptr; + } + return apply_dynCast(to, ptr); +} + +/// Apply cast using typeinfo instead of dynamic_cast +void* dd4hep::ComponentCast::apply_downCast(const ComponentCast& to, const void* ptr) const +{ + if (&to == this) { + return (void*) ptr; + } +#ifdef __APPLE__ + void *r = (*to.cast)(ptr); + if (r) return r; + throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); +#else + if ( to.abi_class ) { + // Since we have to cast a 'to' pointer up to the real pointer + // no virtual inheritance can be supported! + void* r = (void*)ptr; + bool cast_worked = type.__do_upcast((const class_t*)to.abi_class,&r); + if ( cast_worked ) return r; +#if 0 + void *r = cast_wrap(ptr, src_type, (const class_t*)abi_class, -1); + if (r) return r; +#endif + throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!"); + } + throw unrelated_type_error(type, to.type, "Target type is not an abi class type!"); +#endif +} + diff --git a/DDCore/src/Parsers/Printout.cpp b/DDCore/src/Parsers/Printout.cpp new file mode 100755 index 000000000..27ed3b149 --- /dev/null +++ b/DDCore/src/Parsers/Printout.cpp @@ -0,0 +1,414 @@ +//========================================================================== +// 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 "Parsers/Printout.h" + +// C/C++ include files +#include <cstring> +#include <cstdarg> +#include <sstream> +#include <stdexcept> + +// Disable some diagnostics for ROOT dictionaries +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wvarargs" +#endif + +using namespace std; + +namespace { + size_t _the_printer_1(void*, dd4hep::PrintLevel lvl, const char* src, const char* text); + size_t _the_printer_2(void* par, dd4hep::PrintLevel lvl, const char* src, const char* fmt, va_list& args); + + std::string print_fmt = "%-16s %5s %s"; + dd4hep::PrintLevel print_lvl = dd4hep::INFO; + void* print_arg = 0; + dd4hep::output_function1_t print_func_1 = 0; + dd4hep::output_function2_t print_func_2 = _the_printer_2; + + const char* print_level(dd4hep::PrintLevel lvl) { + switch(lvl) { + case dd4hep::NOLOG: return "NOLOG"; + case dd4hep::VERBOSE: return "VERB "; + case dd4hep::DEBUG: return "DEBUG"; + case dd4hep::INFO: return "INFO "; + case dd4hep::WARNING: return "WARN "; + case dd4hep::ERROR: return "ERROR"; + case dd4hep::FATAL: return "FATAL"; + case dd4hep::ALWAYS: return " "; + default: + if ( lvl> dd4hep::ALWAYS ) + return print_level(dd4hep::ALWAYS); + return print_level(dd4hep::NOLOG); + } + } + + size_t _the_printer_1(void*, dd4hep::PrintLevel lvl, const char* src, const char* text) { + ::fflush(stdout); + ::fflush(stderr); + cout << flush; + cerr << flush; + size_t len = ::fprintf(stdout, print_fmt.c_str(), src, print_level(lvl), text); + ::fputc('\n',stdout); + return len; + } + + size_t _the_printer_2(void* par, dd4hep::PrintLevel lvl, const char* src, const char* fmt, va_list& args) { + if ( !print_func_1 ) { + char text[4096]; + ::fflush(stdout); + ::fflush(stderr); + cout << flush; + cerr << flush; + ::snprintf(text,sizeof(text),print_fmt.c_str(),src,print_level(lvl),fmt); + size_t len = ::vfprintf(stdout, text, args); + ::fputc('\n',stdout); + return len; + } + char str[4096]; + ::vsnprintf(str, sizeof(str), fmt, args); + return print_func_1(par, lvl, src, str); + } + + string __format(const char* fmt, va_list& args) { + char str[4096]; + ::vsnprintf(str, sizeof(str), fmt, args); + return string(str); + } +} + +/// Helper function to serialize argument list to a single string +/** + * \arg argc [int,read-only] Number of arguments. + * \arg argv [char**,read-only] Argument strings + * \return String containing the concatenated arguments + */ +string dd4hep::arguments(int argc, char** argv) { + stringstream str; + for(int i=0; i<argc;) { + str << argv[i]; + if ( ++i < argc ) str << " "; + } + return str.str(); +} + +/// Calls the display action with a given severity level +/** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg str [stringstream, RW] string stream containing data to be printed. + * Object is reset after use. + * @return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const char* src, std::stringstream& str) { + int ret = 1; + if (severity >= print_lvl) { + ret = printout(severity, src, str.str().c_str()); + } + str.str(""); + return ret; +} + +/// Calls the display action with a given severity level +/** + * @arg severity [int,read-only] Display severity flag (see enum) + * @arg src [string,read-only] Information source (component, etc.) + * @arg str [stringstream, RW] string stream containing data to be printed. + * Object is reset after use. + * @return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const std::string& src, std::stringstream& str) { + int ret = 1; + if (severity >= print_lvl) { + ret = printout(severity, src, str.str().c_str()); + } + str.str(""); + return ret; +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const char* src, const char* fmt, ...) { + if (severity >= print_lvl) { + va_list args; + va_start(args, fmt); + printout(severity, src, fmt, args); + va_end(args); + } + return 1; +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const string& src, const char* fmt, ...) { + if (severity >= print_lvl) { + va_list args; + va_start(args, fmt); + printout(severity, src.c_str(), fmt, args); + va_end(args); + } + return 1; +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const char* src, const string& fmt, ...) { + if (severity >= print_lvl) { + va_list args; + va_start(args, &fmt); + printout(severity, src, fmt.c_str(), args); + va_end(args); + } + return 1; +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const string& src, const string& fmt, ...) { + if (severity >= print_lvl) { + va_list args; + va_start(args, &fmt); + printout(severity, src.c_str(), fmt.c_str(), args); + va_end(args); + } + return 1; +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const char* src, const char* fmt, va_list& args) { + if (severity >= print_lvl) { + print_func_2(print_arg, severity,src,fmt,args); + } + return 1; +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const string& src, const char* fmt, va_list& args) { + return printout(severity, src.c_str(), fmt, args); +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const char* src, const string& fmt, va_list& args) { + return printout(severity, src, fmt.c_str(), args); +} + +/** Calls the display action + * \arg severity [int,read-only] Display severity flag + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::printout(PrintLevel severity, const string& src, const string& fmt, va_list& args) { + return printout(severity, src.c_str(), fmt.c_str(), args); +} + +/** Calls the display action with ERROR and throws an std::runtime_error exception + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::except(const string& src, const string& fmt, ...) { + va_list args; + va_start(args, &fmt); + return except(src.c_str(),fmt.c_str(), args); +} + +/** Calls the display action with ERROR and throws an std::runtime_error exception + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +int dd4hep::except(const char* src, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + return except(src, fmt, args); +} + +/** Calls the display action with ERROR and throws an std::runtime_error exception + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * \return Status code indicating success or failure + */ +int dd4hep::except(const string& src, const string& fmt, va_list& args) { + string msg = __format(fmt.c_str(), args); + va_end(args); + printout(ERROR, src.c_str(), "%s", msg.c_str()); + // No return. Must call va_end here! + throw runtime_error((src+": "+msg).c_str()); +} + +/** Calls the display action with ERROR and throws an std::runtime_error exception + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * \return Status code indicating success or failure + */ +int dd4hep::except(const char* src, const char* fmt, va_list& args) { + string msg = __format(fmt, args); + va_end(args); + printout(ERROR, src, "%s", msg.c_str()); + // No return. Must call va_end here! + throw runtime_error((string(src)+": "+msg).c_str()); +} + +/** Build exception string + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +string dd4hep::format(const string& src, const string& fmt, ...) { + va_list args; + va_start(args, &fmt); + string str = format(src, fmt, args); + va_end(args); + return str; +} + +/** Build exception string + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \return Status code indicating success or failure + */ +string dd4hep::format(const char* src, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + string str = format(src, fmt, args); + va_end(args); + return str; +} + +/** Build exception string and throw std::runtime_error + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * \return Status code indicating success or failure + */ +string dd4hep::format(const string& src, const string& fmt, va_list& args) { + return format(src.c_str(), fmt.c_str(), args); +} + +/** Build exception string and throw std::runtime_error + * \arg src [string,read-only] Information source (component, etc.) + * \arg fmt [string,read-only] Format string for ellipsis args + * \arg args [ap_list,read-only] List with variable number of arguments to fill format string. + * \return Status code indicating success or failure + */ +string dd4hep::format(const char* src, const char* fmt, va_list& args) { + char str[4096]; + size_t len1 = ::snprintf(str, sizeof(str), "%s: ", src); + size_t len2 = ::vsnprintf(str + len1, sizeof(str) - len1, fmt, args); + if ( len2 > sizeof(str) - len1 ) { + len2 = sizeof(str) - len1 - 1; + str[sizeof(str)-1] = 0; + } + return string(str); +} + +/// Set new print level. Returns the old print level +dd4hep::PrintLevel dd4hep::setPrintLevel(PrintLevel new_level) { + PrintLevel old = print_lvl; + print_lvl = new_level; + return old; +} + +/// Access the current printer level +dd4hep::PrintLevel dd4hep::printLevel() { + return print_lvl; +} + +/// Translate the printer level from string to value +dd4hep::PrintLevel dd4hep::printLevel(const char* value) { + if ( !value ) except("Printout","Invalid printlevel requested [EINVAL: Null-pointer argument]"); + // Explicit values + if ( strcmp(value,"NOLOG") == 0 ) return dd4hep::NOLOG; + if ( strcmp(value,"VERBOSE") == 0 ) return dd4hep::VERBOSE; + if ( strcmp(value,"DEBUG") == 0 ) return dd4hep::DEBUG; + if ( strcmp(value,"INFO") == 0 ) return dd4hep::INFO; + if ( strcmp(value,"WARNING") == 0 ) return dd4hep::WARNING; + if ( strcmp(value,"ERROR") == 0 ) return dd4hep::ERROR; + if ( strcmp(value,"FATAL") == 0 ) return dd4hep::FATAL; + if ( strcmp(value,"ALWAYS") == 0 ) return dd4hep::ALWAYS; + // Numeric values + if ( strcmp(value,"0") == 0 ) return dd4hep::NOLOG; + if ( strcmp(value,"1") == 0 ) return dd4hep::VERBOSE; + if ( strcmp(value,"2") == 0 ) return dd4hep::DEBUG; + if ( strcmp(value,"3") == 0 ) return dd4hep::INFO; + if ( strcmp(value,"4") == 0 ) return dd4hep::WARNING; + if ( strcmp(value,"5") == 0 ) return dd4hep::ERROR; + if ( strcmp(value,"6") == 0 ) return dd4hep::FATAL; + if ( strcmp(value,"7") == 0 ) return dd4hep::ALWAYS; + except("Printout","Unknown printlevel requested:%s",value); + return dd4hep::ALWAYS; +} + +/// Translate the printer level from string to value +dd4hep::PrintLevel dd4hep::printLevel(const std::string& value) { + return printLevel(value.c_str()); +} + +/// Check if this print level would result in some output +bool dd4hep::isActivePrintLevel(int severity) { + return severity >= print_lvl; +} + +/// Set new printout format for the 3 fields: source-level-message. All 3 are strings +string dd4hep::setPrintFormat(const string& new_format) { + string old = print_fmt; + print_fmt = new_format; + return old; +} + +/// Customize printer function +void dd4hep::setPrinter(void* arg, output_function1_t fcn) { + print_arg = arg; + print_func_1 = fcn ? fcn : _the_printer_1; +} + +/// Customize printer function +void dd4hep::setPrinter2(void* arg, output_function2_t fcn) { + print_arg = arg; + print_func_2 = fcn ? fcn : _the_printer_2; +} diff --git a/DDCore/src/RootDictionary.h b/DDCore/src/RootDictionary.h index 3d48c0fed..de986c74e 100644 --- a/DDCore/src/RootDictionary.h +++ b/DDCore/src/RootDictionary.h @@ -17,7 +17,7 @@ #define DD4HEP_DDCORE_ROOTDICTIONARY_H // Framework include files -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" #include "DD4hep/DD4hepRootPersistency.h" #include "DD4hep/Printout.h" #include "DD4hep/detail/Grammar.h" diff --git a/DDCore/src/XML/Detector.cpp b/DDCore/src/XML/Detector.cpp new file mode 100644 index 000000000..693f390d2 --- /dev/null +++ b/DDCore/src/XML/Detector.cpp @@ -0,0 +1,23 @@ +//========================================================================== +// 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 +// +//========================================================================== +#ifndef DD4HEP_NONE + +// Framework include files +#include "XML/XMLDetector.h" + +// Instantiate here the concrete implementations +#define DD4HEP_DIMENSION_NS xml +using namespace dd4hep::DD4HEP_DIMENSION_NS; + +#include "Parsers/detail/Detector.imp" +#endif diff --git a/DDCore/src/XML/Layering.cpp b/DDCore/src/XML/Layering.cpp index 060cc0c4b..93dff1bc9 100644 --- a/DDCore/src/XML/Layering.cpp +++ b/DDCore/src/XML/Layering.cpp @@ -10,6 +10,7 @@ // Author : M.Frank // //========================================================================== +#ifndef DD4HEP_NONE // Framework include files #include "DD4hep/Primitives.h" @@ -128,4 +129,4 @@ Layering::~Layering(){ for_each(layers.begin(), layers.end(), detail::deletePtr<Layer>); layers.clear(); } - +#endif diff --git a/DDCore/src/XML/Utilities.cpp b/DDCore/src/XML/Utilities.cpp index 7dd5a5fda..20b0fcaac 100644 --- a/DDCore/src/XML/Utilities.cpp +++ b/DDCore/src/XML/Utilities.cpp @@ -10,6 +10,7 @@ // Author : M.Frank // //========================================================================== +#ifndef DD4HEP_NONE // Framework include files #include "XML/Utilities.h" @@ -130,3 +131,4 @@ void dd4hep::xml::setDetectorTypeFlag( dd4hep::xml::Handle_t e, dd4hep::DetElem det_name.c_str() ) ; } } +#endif diff --git a/DDCore/src/XML/XMLElements.cpp b/DDCore/src/XML/XMLElements.cpp index 0283b7e14..821a4a430 100644 --- a/DDCore/src/XML/XMLElements.cpp +++ b/DDCore/src/XML/XMLElements.cpp @@ -12,7 +12,7 @@ //========================================================================== // Framework include files -#include "DDParsers/Evaluator.h" +#include "XML/Evaluator.h" #include "XML/XMLElements.h" #include "XML/Printout.h" #include "XML/XMLTags.h" diff --git a/DDCore/src/XML/XMLHelpers.cpp b/DDCore/src/XML/XMLHelpers.cpp index d70e8384a..59fa2b888 100644 --- a/DDCore/src/XML/XMLHelpers.cpp +++ b/DDCore/src/XML/XMLHelpers.cpp @@ -12,7 +12,6 @@ //========================================================================== // Framework include files -#include "XML/XMLDetector.h" #include "XML/XMLDimension.inl" #include "XML/XMLChildValue.inl" @@ -20,6 +19,5 @@ #define DD4HEP_DIMENSION_NS xml using namespace dd4hep::DD4HEP_DIMENSION_NS; -#include "XML/detail/Detector.imp" -#include "XML/detail/Dimension.imp" -#include "XML/detail/ChildValue.imp" +#include "Parsers/detail/Dimension.imp" +#include "Parsers/detail/ChildValue.imp" diff --git a/DDCore/src/XML/XMLParsers.cpp b/DDCore/src/XML/XMLParsers.cpp index 06d68b3c1..f3228de0f 100644 --- a/DDCore/src/XML/XMLParsers.cpp +++ b/DDCore/src/XML/XMLParsers.cpp @@ -12,6 +12,7 @@ // \version 1.0 // //========================================================================== +#ifndef DD4HEP_NONE // Framework include files #include "DD4hep/Objects.h" @@ -130,3 +131,5 @@ void dd4hep::xml::parse_sequence(xml_h e, OpaqueDataBlock& block) { "++ Failed to convert unknown sequence conditions type: %s",typ.c_str()); } } + +#endif diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt index 386877207..df438aa03 100644 --- a/DDG4/CMakeLists.txt +++ b/DDG4/CMakeLists.txt @@ -10,6 +10,7 @@ #========================================================================== dd4hep_package( DDG4 USES [GEANT4 REQUIRED COMPONENTS gdml ui_all vis_all] + [ROOT REQUIRED COMPONENTS Geom GenVector RIO] BOOST DDCore OPTIONAL CLHEP [XercesC QUIET] INCLUDE_DIRS include diff --git a/DDG4/include/DDG4/Geant4InputAction.h b/DDG4/include/DDG4/Geant4InputAction.h index 7c4be855a..8cc138366 100644 --- a/DDG4/include/DDG4/Geant4InputAction.h +++ b/DDG4/include/DDG4/Geant4InputAction.h @@ -18,7 +18,7 @@ #include "DDG4/Geant4Vertex.h" #include "DDG4/Geant4Particle.h" #include "DDG4/Geant4GeneratorAction.h" -#include "DDParsers/Parsers.h" +#include "Parsers/Parsers.h" // C/C++ include files #include <vector> @@ -73,15 +73,15 @@ namespace dd4hep { */ template <typename T> void _getParameterValue( std::map< std::string, std::string > & parameters, - std::string const& parameterName, - T& parameter, T defaultValue ) { - - if( parameters.find( parameterName ) != parameters.end() ) { - dd4hep::Parsers::parse( parameter, parameters.at( parameterName ) ); - parameters.erase( parameterName ); - } else { - parameter = defaultValue; - } + std::string const& parameterName, + T& parameter, T defaultValue ) { + + if( parameters.find( parameterName ) != parameters.end() ) { + dd4hep::Parsers::parse( parameter, parameters.at( parameterName ) ); + parameters.erase( parameterName ); + } else { + parameter = defaultValue; + } } public: @@ -158,8 +158,8 @@ namespace dd4hep { public: /// Read an event and return a LCCollectionVec of MCParticles. int readParticles(int event_number, - Vertices& vertices, - Particles& particles); + Vertices& vertices, + Particles& particles); /// helper to report Geant4 exceptions std::string issue(int i) const; diff --git a/DDParsers/CMakeLists.txt b/DDParsers/CMakeLists.txt index 61ae41caf..9fcb0fc6a 100644 --- a/DDParsers/CMakeLists.txt +++ b/DDParsers/CMakeLists.txt @@ -10,13 +10,15 @@ # #================================================================================= dd4hep_package( DDParsers - USES [ROOT REQUIRED COMPONENTS Geom GenVector] + USES [ROOT REQUIRED] + OPTIONAL XERCESC INCLUDE_DIRS include - INSTALL_INCLUDES include/DDParsers ) + INSTALL_INCLUDES include/Evaluator include/Parsers ) dd4hep_add_package_library ( DDParsers INCLUDE_DIRS LINK_LIBRARIES - SOURCES src/*.cpp src/Evaluator/*.cpp - OPTIONAL [BOOST SOURCES src/parsers/*.cpp] + SOURCES src/Parsers/*.cpp src/Evaluator/*.cpp + OPTIONAL [BOOST SOURCES src/Spirit/*.cpp] ) + diff --git a/DDParsers/include/DDParsers/DD4hepUnits.h b/DDParsers/include/Evaluator/DD4hepUnits.h similarity index 100% rename from DDParsers/include/DDParsers/DD4hepUnits.h rename to DDParsers/include/Evaluator/DD4hepUnits.h diff --git a/DDParsers/include/DDParsers/Evaluator.h b/DDParsers/include/Evaluator/Evaluator.h similarity index 100% rename from DDParsers/include/DDParsers/Evaluator.h rename to DDParsers/include/Evaluator/Evaluator.h diff --git a/DDParsers/include/Parsers/Parsers.h b/DDParsers/include/Parsers/Parsers.h new file mode 100644 index 000000000..f928f1c51 --- /dev/null +++ b/DDParsers/include/Parsers/Parsers.h @@ -0,0 +1,24 @@ +//========================================================================== +// 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 +// +//========================================================================== +// +// Setup XML parsing for the use of Apache Xerces-C and TiXml +// +//========================================================================== +#ifndef DD4HEP_PARSERS_PARSERS_H +#define DD4HEP_PARSERS_PARSERS_H + +#include "Parsers/config.h" +#include "Parsers/spirit/Parsers.h" +#include "Parsers/spirit/ToStream.h" + +#endif // DD4HEP_PARSERS_PARSERS_H diff --git a/DDParsers/include/Parsers/config.h b/DDParsers/include/Parsers/config.h new file mode 100644 index 000000000..8df27f312 --- /dev/null +++ b/DDParsers/include/Parsers/config.h @@ -0,0 +1,22 @@ +//========================================================================== +// 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 +// +//========================================================================== +// +// Setup XML parsing for the use of Apache Xerces-C and TiXml +// +//========================================================================== +#ifndef DD4HEP_PARSERS_CONFIG_H +#define DD4HEP_PARSERS_CONFIG_H + +//#define dd4hep Online + +#endif // DD4HEP_PARSERS_CONFIG_H diff --git a/DDParsers/src/parsers/GrammarsV2.h b/DDParsers/include/Parsers/spirit/GrammarsV2.h old mode 100644 new mode 100755 similarity index 100% rename from DDParsers/src/parsers/GrammarsV2.h rename to DDParsers/include/Parsers/spirit/GrammarsV2.h diff --git a/DDParsers/include/DDParsers/Parsers.h b/DDParsers/include/Parsers/spirit/Parsers.h old mode 100644 new mode 100755 similarity index 99% rename from DDParsers/include/DDParsers/Parsers.h rename to DDParsers/include/Parsers/spirit/Parsers.h index 59df94581..82b453403 --- a/DDParsers/include/DDParsers/Parsers.h +++ b/DDParsers/include/Parsers/spirit/Parsers.h @@ -14,6 +14,7 @@ #define DD4HEP_PARSERS_H 1 // ============================================================================ // Include files +#include "Parsers/config.h" // ============================================================================ // STD & STL // ============================================================================ diff --git a/DDParsers/src/parsers/ParsersFactory.h b/DDParsers/include/Parsers/spirit/ParsersFactory.h similarity index 97% rename from DDParsers/src/parsers/ParsersFactory.h rename to DDParsers/include/Parsers/spirit/ParsersFactory.h index f232ce76b..8fa42bf91 100644 --- a/DDParsers/src/parsers/ParsersFactory.h +++ b/DDParsers/include/Parsers/spirit/ParsersFactory.h @@ -26,8 +26,9 @@ // ============================================================================ // dd4hep // ============================================================================ -#include "UsedParser.h" -#include "GrammarsV2.h" +#include "Parsers/config.h" +#include "Parsers/spirit/UsedParser.h" +#include "Parsers/spirit/GrammarsV2.h" // ============================================================================ /// Namespace for the AIDA detector description toolkit namespace dd4hep { diff --git a/DDParsers/src/parsers/ParsersStandardListCommon.h b/DDParsers/include/Parsers/spirit/ParsersStandardListCommon.h old mode 100644 new mode 100755 similarity index 95% rename from DDParsers/src/parsers/ParsersStandardListCommon.h rename to DDParsers/include/Parsers/spirit/ParsersStandardListCommon.h index 3271114bd..36bbfa647 --- a/DDParsers/src/parsers/ParsersStandardListCommon.h +++ b/DDParsers/include/Parsers/spirit/ParsersStandardListCommon.h @@ -1,5 +1,5 @@ //========================================================================== -// AIDA Detector description implementation +// AIDA Detector description implementation //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) // All rights reserved. @@ -13,8 +13,7 @@ // ============================================================================ // Include files // ============================================================================ -#include "ParsersFactory.h" - +#include "Parsers/spirit/ParsersFactory.h" #define IMPLEMENT_STL_PARSER(x,y) \ int parse(x < y > & result, const std::string& input) \ @@ -56,7 +55,7 @@ // ============================================================================ #define PARSERS_DEF_FOR_LIST(InnerType) \ - namespace dd4hep{ namespace Parsers{ \ + namespace DD4hep{ namespace Parsers{ \ IMPLEMENT_STL_PARSERS(InnerType) \ IMPLEMENT_MAPPED_PARSERS(pair,InnerType) }} diff --git a/DDParsers/src/parsers/ParsersStandardMiscCommon.h b/DDParsers/include/Parsers/spirit/ParsersStandardMiscCommon.h old mode 100644 new mode 100755 similarity index 90% rename from DDParsers/src/parsers/ParsersStandardMiscCommon.h rename to DDParsers/include/Parsers/spirit/ParsersStandardMiscCommon.h index 9df29330c..6717e55bb --- a/DDParsers/src/parsers/ParsersStandardMiscCommon.h +++ b/DDParsers/include/Parsers/spirit/ParsersStandardMiscCommon.h @@ -1,5 +1,5 @@ //========================================================================== -// AIDA Detector description implementation +// AIDA Detector description implementation //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) // All rights reserved. @@ -13,6 +13,6 @@ // ============================================================================ // Include files // ============================================================================ -#include "ParsersFactory.h" +#include "Parsers/spirit/ParsersFactory.h" // ============================================================================ #endif /* PARSERS_STANDARD_MISC_COMMON_H */ diff --git a/DDParsers/include/DDParsers/ToStream.h b/DDParsers/include/Parsers/spirit/ToStream.h similarity index 99% rename from DDParsers/include/DDParsers/ToStream.h rename to DDParsers/include/Parsers/spirit/ToStream.h index bb71c2803..de1912fea 100644 --- a/DDParsers/include/DDParsers/ToStream.h +++ b/DDParsers/include/Parsers/spirit/ToStream.h @@ -14,6 +14,7 @@ #define DD4HEPPROPERTYPARSERS_PARSERVALUETOSTREAM_H 1 // ============================================================================ // Include files +#include "Parsers/config.h" // ============================================================================ // STD & STL // ============================================================================ diff --git a/DDParsers/src/parsers/UsedParser.h b/DDParsers/include/Parsers/spirit/UsedParser.h old mode 100644 new mode 100755 similarity index 76% rename from DDParsers/src/parsers/UsedParser.h rename to DDParsers/include/Parsers/spirit/UsedParser.h index 77b639d21..df3a6302d --- a/DDParsers/src/parsers/UsedParser.h +++ b/DDParsers/include/Parsers/spirit/UsedParser.h @@ -1,5 +1,5 @@ //========================================================================== -// AIDA Detector description implementation +// AIDA Detector description implementation //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) // All rights reserved. @@ -11,17 +11,18 @@ #ifndef DD4HEP_DDCORE_PARSERS_USEDPARSERS_H #define DD4HEP_DDCORE_PARSERS_USEDPARSERS_H +#include "Parsers/config.h" #if defined(DD4HEP_PARSER_HEADER) // This is the case, if the parsers are externalized -// and the dd4hep namespace is renamed! +// and the DD4hep namespace is renamed! #include DD4HEP_PARSER_HEADER #else -// Standard dd4hep parser handling -#include "DDParsers/Parsers.h" -#include "DDParsers/ToStream.h" +// Standard DD4hep parser handling +#include "Parsers/spirit/Parsers.h" +#include "Parsers/spirit/ToStream.h" #endif diff --git a/DDParsers/src/Evaluator/Evaluator.cpp b/DDParsers/src/Evaluator/Evaluator.cpp index 831d088ef..fcc6d8743 100644 --- a/DDParsers/src/Evaluator/Evaluator.cpp +++ b/DDParsers/src/Evaluator/Evaluator.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // --------------------------------------------------------------------------- -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" #include <iostream> #include <cmath> // for pow() diff --git a/DDParsers/src/Evaluator/ExpressionEvaluator.cpp b/DDParsers/src/Evaluator/ExpressionEvaluator.cpp index c347791ac..4da4bd0f0 100644 --- a/DDParsers/src/Evaluator/ExpressionEvaluator.cpp +++ b/DDParsers/src/Evaluator/ExpressionEvaluator.cpp @@ -10,9 +10,9 @@ // Author : M.Frank // //========================================================================== - -#include "DDParsers/Evaluator.h" -#include "DDParsers/DD4hepUnits.h" +#include "Parsers/config.h" +#include "Evaluator/Evaluator.h" +#include "Evaluator/DD4hepUnits.h" namespace units = dd4hep; namespace { @@ -53,6 +53,7 @@ namespace { } namespace dd4hep { + XmlTools::Evaluator& evaluator() { static XmlTools::Evaluator* e = 0; if ( !e ) { diff --git a/DDParsers/src/Evaluator/setStdMath.cpp b/DDParsers/src/Evaluator/setStdMath.cpp index be047e266..e0c097e1b 100644 --- a/DDParsers/src/Evaluator/setStdMath.cpp +++ b/DDParsers/src/Evaluator/setStdMath.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // ---------------------------------------------------------------------- -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" #ifdef DD4HEP_NONE /// Utility namespace to support TGeo units. @@ -12,7 +12,7 @@ namespace dd4hep { //} } #else -#include "DDParsers/DD4hepUnits.h" +#include "Evaluator/DD4hepUnits.h" #endif namespace units = dd4hep; diff --git a/DDParsers/src/Evaluator/setSystemOfUnits.cpp b/DDParsers/src/Evaluator/setSystemOfUnits.cpp index c6156acc9..42b9bd6bc 100644 --- a/DDParsers/src/Evaluator/setSystemOfUnits.cpp +++ b/DDParsers/src/Evaluator/setSystemOfUnits.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // ---------------------------------------------------------------------- -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" namespace XmlTools { diff --git a/DDParsers/src/ParsersDictionary.h b/DDParsers/src/ParsersDictionary.h new file mode 100644 index 000000000..be4b09480 --- /dev/null +++ b/DDParsers/src/ParsersDictionary.h @@ -0,0 +1,19 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// 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 Markus Frank +// \date 2018-02-05 +// \version 1.0 +// +//========================================================================== +#ifndef PARSERDICTIONARY_H +#define PARSERDICTIONARY_H 1 + + +#endif // PARSERDICTIONARY_H diff --git a/DDParsers/src/parsers/Evaluators.cpp b/DDParsers/src/Spirit/Evaluators.cpp old mode 100644 new mode 100755 similarity index 94% rename from DDParsers/src/parsers/Evaluators.cpp rename to DDParsers/src/Spirit/Evaluators.cpp index c10091902..48e153f0f --- a/DDParsers/src/parsers/Evaluators.cpp +++ b/DDParsers/src/Spirit/Evaluators.cpp @@ -11,6 +11,8 @@ // //========================================================================== +#include "Parsers/config.h" + // Framework include files #if defined(DD4HEP_PARSER_HEADER) @@ -22,12 +24,13 @@ #else // Standard dd4hep parser handling -#include "DDParsers/ToStream.h" +#include "Parsers/spirit/ToStream.h" #endif -#include "DDParsers/Evaluator.h" +#include "Evaluator/Evaluator.h" // C/C++ include files +#include <iostream> #include <stdexcept> namespace dd4hep { diff --git a/DDParsers/src/Spirit/ExtraParsers.cpp b/DDParsers/src/Spirit/ExtraParsers.cpp new file mode 100755 index 000000000..8245ad80c --- /dev/null +++ b/DDParsers/src/Spirit/ExtraParsers.cpp @@ -0,0 +1,31 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// ExtraProperties.cpp +//-------------------------------------------------------------------------- +// +// Package : Dataflow +// +// Author : Markus Frank +//========================================================================== +// Note: +// +// This is an example file, which shows how to instantiate extera parsers, +// which are not part of DD4hep, but may be interesting for a +// client application. +// +//========================================================================== + +/// Framework includes +#include "Parsers/spirit/ParsersFactory.h" + +PARSERS_DEF_FOR_SINGLE(unsigned int) +PARSERS_DEF_FOR_SINGLE(unsigned long) +PARSERS_DEF_FOR_SINGLE(long long) +PARSERS_DEF_FOR_SINGLE(unsigned long long) diff --git a/DDParsers/src/parsers/ParserStandardList_Mapint_bool.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapint_bool.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_Mapint_bool.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapint_bool.cpp index 5da178df7..613f7a1cc --- a/DDParsers/src/parsers/ParserStandardList_Mapint_bool.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapint_bool.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,int,bool) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapint_double.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapint_double.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_Mapint_double.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapint_double.cpp index 372bcbd72..456a0fdf9 --- a/DDParsers/src/parsers/ParserStandardList_Mapint_double.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapint_double.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,int,double) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapint_float.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapint_float.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapint_float.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapint_float.cpp index 4fc4cabc6..b527885c9 --- a/DDParsers/src/parsers/ParserStandardList_Mapint_float.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapint_float.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,int,float) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapint_int.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapint_int.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapint_int.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapint_int.cpp index f92fa302c..da317b6bc --- a/DDParsers/src/parsers/ParserStandardList_Mapint_int.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapint_int.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,int,int) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapint_long.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapint_long.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapint_long.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapint_long.cpp index 27e52a9fd..87a7421cf --- a/DDParsers/src/parsers/ParserStandardList_Mapint_long.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapint_long.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,int,long) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapint_string.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapint_string.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapint_string.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapint_string.cpp index 62dd72d00..67e07ca28 --- a/DDParsers/src/parsers/ParserStandardList_Mapint_string.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapint_string.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,int,std::string) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapped_bool.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapped_bool.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapped_bool.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapped_bool.cpp index b3e0f2f0f..af3a8fce4 --- a/DDParsers/src/parsers/ParserStandardList_Mapped_bool.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapped_bool.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_MAPPED_PARSERS(pair,bool) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapped_double.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapped_double.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapped_double.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapped_double.cpp index bd5428f5a..364cec9ec --- a/DDParsers/src/parsers/ParserStandardList_Mapped_double.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapped_double.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_MAPPED_PARSERS(pair,double) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapped_float.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapped_float.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapped_float.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapped_float.cpp index 92178bbdc..041457bf9 --- a/DDParsers/src/parsers/ParserStandardList_Mapped_float.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapped_float.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_MAPPED_PARSERS(pair,float) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapped_int.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapped_int.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapped_int.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapped_int.cpp index 418e7ed2d..0b6dfbe2c --- a/DDParsers/src/parsers/ParserStandardList_Mapped_int.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapped_int.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_MAPPED_PARSERS(pair,int) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapped_long.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapped_long.cpp old mode 100644 new mode 100755 similarity index 75% rename from DDParsers/src/parsers/ParserStandardList_Mapped_long.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapped_long.cpp index c1540f7c8..3a5c0cef8 --- a/DDParsers/src/parsers/ParserStandardList_Mapped_long.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapped_long.cpp @@ -1,4 +1,3 @@ -// $Id: ParserStandardList_Mapped_long.cpp 2166 2016-03-17 16:37:06Z /DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=sailer/CN=683529/CN=Andre Sailer $ //========================================================================== // AIDA Detector description implementation //-------------------------------------------------------------------------- @@ -10,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_MAPPED_PARSERS(pair,long) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapped_string.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapped_string.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapped_string.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapped_string.cpp index 18f703873..8796edaa8 --- a/DDParsers/src/parsers/ParserStandardList_Mapped_string.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapped_string.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_MAPPED_PARSERS(pair,std::string) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapstring_bool.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapstring_bool.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapstring_bool.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapstring_bool.cpp index 9428191eb..0af0baf85 --- a/DDParsers/src/parsers/ParserStandardList_Mapstring_bool.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapstring_bool.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,std::string,bool) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapstring_double.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapstring_double.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapstring_double.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapstring_double.cpp index 8a7e2d0f5..c3af32e01 --- a/DDParsers/src/parsers/ParserStandardList_Mapstring_double.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapstring_double.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,std::string,double) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapstring_float.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapstring_float.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapstring_float.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapstring_float.cpp index a05159389..d2851664d --- a/DDParsers/src/parsers/ParserStandardList_Mapstring_float.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapstring_float.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,std::string,float) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapstring_int.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapstring_int.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapstring_int.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapstring_int.cpp index 2aa4f24fd..950ec339a --- a/DDParsers/src/parsers/ParserStandardList_Mapstring_int.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapstring_int.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,std::string,int) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapstring_long.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapstring_long.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapstring_long.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapstring_long.cpp index 76051cc46..e6358c50a --- a/DDParsers/src/parsers/ParserStandardList_Mapstring_long.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapstring_long.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,std::string,long) }} diff --git a/DDParsers/src/parsers/ParserStandardList_Mapstring_string.cpp b/DDParsers/src/Spirit/ParserStandardList_Mapstring_string.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_Mapstring_string.cpp rename to DDParsers/src/Spirit/ParserStandardList_Mapstring_string.cpp index ab2a2734b..e34ba7560 --- a/DDParsers/src/parsers/ParserStandardList_Mapstring_string.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_Mapstring_string.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_MAP_PARSER(std::map,std::string,std::string) }} diff --git a/DDParsers/src/parsers/ParserStandardList_list_bool.cpp b/DDParsers/src/Spirit/ParserStandardList_list_bool.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_list_bool.cpp rename to DDParsers/src/Spirit/ParserStandardList_list_bool.cpp index aae227af3..ce5359778 --- a/DDParsers/src/parsers/ParserStandardList_list_bool.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_list_bool.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::list,bool) }} diff --git a/DDParsers/src/parsers/ParserStandardList_list_double.cpp b/DDParsers/src/Spirit/ParserStandardList_list_double.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_list_double.cpp rename to DDParsers/src/Spirit/ParserStandardList_list_double.cpp index be4659e5d..549a2f369 --- a/DDParsers/src/parsers/ParserStandardList_list_double.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_list_double.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::list,double) }} diff --git a/DDParsers/src/parsers/ParserStandardList_list_float.cpp b/DDParsers/src/Spirit/ParserStandardList_list_float.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_list_float.cpp rename to DDParsers/src/Spirit/ParserStandardList_list_float.cpp index 8609a5e80..0245155cd --- a/DDParsers/src/parsers/ParserStandardList_list_float.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_list_float.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::list,float) }} diff --git a/DDParsers/src/parsers/ParserStandardList_list_int.cpp b/DDParsers/src/Spirit/ParserStandardList_list_int.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_list_int.cpp rename to DDParsers/src/Spirit/ParserStandardList_list_int.cpp index 5b3c38a94..e792e9fe1 --- a/DDParsers/src/parsers/ParserStandardList_list_int.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_list_int.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::list,int) }} diff --git a/DDParsers/src/parsers/ParserStandardList_list_long.cpp b/DDParsers/src/Spirit/ParserStandardList_list_long.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_list_long.cpp rename to DDParsers/src/Spirit/ParserStandardList_list_long.cpp index 909a28f27..d8ba02b32 --- a/DDParsers/src/parsers/ParserStandardList_list_long.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_list_long.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::list,long) }} diff --git a/DDParsers/src/parsers/ParserStandardList_list_string.cpp b/DDParsers/src/Spirit/ParserStandardList_list_string.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_list_string.cpp rename to DDParsers/src/Spirit/ParserStandardList_list_string.cpp index c102f7767..b9da1e150 --- a/DDParsers/src/parsers/ParserStandardList_list_string.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_list_string.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::list,std::string) }} diff --git a/DDParsers/src/parsers/ParserStandardList_set_bool.cpp b/DDParsers/src/Spirit/ParserStandardList_set_bool.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_set_bool.cpp rename to DDParsers/src/Spirit/ParserStandardList_set_bool.cpp index ef742afde..c175197c1 --- a/DDParsers/src/parsers/ParserStandardList_set_bool.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_set_bool.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::set,bool) }} diff --git a/DDParsers/src/parsers/ParserStandardList_set_double.cpp b/DDParsers/src/Spirit/ParserStandardList_set_double.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_set_double.cpp rename to DDParsers/src/Spirit/ParserStandardList_set_double.cpp index fc9affd32..9d1aa393d --- a/DDParsers/src/parsers/ParserStandardList_set_double.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_set_double.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::set,double) }} diff --git a/DDParsers/src/parsers/ParserStandardList_set_float.cpp b/DDParsers/src/Spirit/ParserStandardList_set_float.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_set_float.cpp rename to DDParsers/src/Spirit/ParserStandardList_set_float.cpp index f5ad768fa..922fd0661 --- a/DDParsers/src/parsers/ParserStandardList_set_float.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_set_float.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::set,float) }} diff --git a/DDParsers/src/parsers/ParserStandardList_set_int.cpp b/DDParsers/src/Spirit/ParserStandardList_set_int.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_set_int.cpp rename to DDParsers/src/Spirit/ParserStandardList_set_int.cpp index 4fdbb4845..3d8d5cd64 --- a/DDParsers/src/parsers/ParserStandardList_set_int.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_set_int.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::set,int) }} diff --git a/DDParsers/src/parsers/ParserStandardList_set_long.cpp b/DDParsers/src/Spirit/ParserStandardList_set_long.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_set_long.cpp rename to DDParsers/src/Spirit/ParserStandardList_set_long.cpp index f6437283b..e2302d1cc --- a/DDParsers/src/parsers/ParserStandardList_set_long.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_set_long.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::set,long) }} diff --git a/DDParsers/src/parsers/ParserStandardList_set_string.cpp b/DDParsers/src/Spirit/ParserStandardList_set_string.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_set_string.cpp rename to DDParsers/src/Spirit/ParserStandardList_set_string.cpp index f0424935c..b3ec82454 --- a/DDParsers/src/parsers/ParserStandardList_set_string.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_set_string.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::set,std::string) }} diff --git a/DDParsers/src/parsers/ParserStandardList_vector_bool.cpp b/DDParsers/src/Spirit/ParserStandardList_vector_bool.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_vector_bool.cpp rename to DDParsers/src/Spirit/ParserStandardList_vector_bool.cpp index a6a015e5f..3f60c0488 --- a/DDParsers/src/parsers/ParserStandardList_vector_bool.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_vector_bool.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::vector,bool) }} diff --git a/DDParsers/src/parsers/ParserStandardList_vector_double.cpp b/DDParsers/src/Spirit/ParserStandardList_vector_double.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_vector_double.cpp rename to DDParsers/src/Spirit/ParserStandardList_vector_double.cpp index 3020da1cd..ef4e36a93 --- a/DDParsers/src/parsers/ParserStandardList_vector_double.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_vector_double.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::vector,double) }} diff --git a/DDParsers/src/parsers/ParserStandardList_vector_float.cpp b/DDParsers/src/Spirit/ParserStandardList_vector_float.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParserStandardList_vector_float.cpp rename to DDParsers/src/Spirit/ParserStandardList_vector_float.cpp index 7d887f2d5..aefabf66c --- a/DDParsers/src/parsers/ParserStandardList_vector_float.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_vector_float.cpp @@ -10,7 +10,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::vector,float) }} diff --git a/DDParsers/src/parsers/ParserStandardList_vector_int.cpp b/DDParsers/src/Spirit/ParserStandardList_vector_int.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_vector_int.cpp rename to DDParsers/src/Spirit/ParserStandardList_vector_int.cpp index 299141d15..8ef2d8473 --- a/DDParsers/src/parsers/ParserStandardList_vector_int.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_vector_int.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::vector,int) }} diff --git a/DDParsers/src/parsers/ParserStandardList_vector_long.cpp b/DDParsers/src/Spirit/ParserStandardList_vector_long.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_vector_long.cpp rename to DDParsers/src/Spirit/ParserStandardList_vector_long.cpp index f40131997..631a24893 --- a/DDParsers/src/parsers/ParserStandardList_vector_long.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_vector_long.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::vector,long) }} diff --git a/DDParsers/src/parsers/ParserStandardList_vector_string.cpp b/DDParsers/src/Spirit/ParserStandardList_vector_string.cpp old mode 100644 new mode 100755 similarity index 91% rename from DDParsers/src/parsers/ParserStandardList_vector_string.cpp rename to DDParsers/src/Spirit/ParserStandardList_vector_string.cpp index 5a674529a..e89818d9f --- a/DDParsers/src/parsers/ParserStandardList_vector_string.cpp +++ b/DDParsers/src/Spirit/ParserStandardList_vector_string.cpp @@ -9,7 +9,7 @@ // //========================================================================== -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace dd4hep{ namespace Parsers{ IMPLEMENT_STL_PARSER(std::vector,std::string) }} diff --git a/DDParsers/src/parsers/ParsersObjects_PxPyPzEVector.cpp b/DDParsers/src/Spirit/ParsersObjects_PxPyPzEVector.cpp old mode 100644 new mode 100755 similarity index 97% rename from DDParsers/src/parsers/ParsersObjects_PxPyPzEVector.cpp rename to DDParsers/src/Spirit/ParsersObjects_PxPyPzEVector.cpp index e2747bd23..822fa706b --- a/DDParsers/src/parsers/ParsersObjects_PxPyPzEVector.cpp +++ b/DDParsers/src/Spirit/ParsersObjects_PxPyPzEVector.cpp @@ -12,7 +12,7 @@ // Include files //========================================================================== #ifndef DD4HEP_PARSERS_NO_ROOT -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace ROOT { namespace Math { bool operator<(const PxPyPzEVector& a, const PxPyPzEVector& b) { diff --git a/DDParsers/src/parsers/ParsersObjects_XYZPoint.cpp b/DDParsers/src/Spirit/ParsersObjects_XYZPoint.cpp old mode 100644 new mode 100755 similarity index 97% rename from DDParsers/src/parsers/ParsersObjects_XYZPoint.cpp rename to DDParsers/src/Spirit/ParsersObjects_XYZPoint.cpp index 38af26205..379da7a39 --- a/DDParsers/src/parsers/ParsersObjects_XYZPoint.cpp +++ b/DDParsers/src/Spirit/ParsersObjects_XYZPoint.cpp @@ -12,7 +12,7 @@ // Include files //========================================================================== #ifndef DD4HEP_PARSERS_NO_ROOT -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace ROOT { namespace Math { bool operator<(const XYZPoint& a, const XYZPoint& b) { diff --git a/DDParsers/src/parsers/ParsersObjects_XYZVector.cpp b/DDParsers/src/Spirit/ParsersObjects_XYZVector.cpp old mode 100644 new mode 100755 similarity index 97% rename from DDParsers/src/parsers/ParsersObjects_XYZVector.cpp rename to DDParsers/src/Spirit/ParsersObjects_XYZVector.cpp index e848371f0..7013dc8d6 --- a/DDParsers/src/parsers/ParsersObjects_XYZVector.cpp +++ b/DDParsers/src/Spirit/ParsersObjects_XYZVector.cpp @@ -12,7 +12,7 @@ // Include files //========================================================================== #ifndef DD4HEP_PARSERS_NO_ROOT -#include "ParsersStandardListCommon.h" +#include "Parsers/spirit/ParsersStandardListCommon.h" namespace ROOT { namespace Math { bool operator<(const XYZVector& a, const XYZVector& b) { diff --git a/DDParsers/src/parsers/ParsersStandardMisc1.cpp b/DDParsers/src/Spirit/ParsersStandardMisc1.cpp old mode 100644 new mode 100755 similarity index 95% rename from DDParsers/src/parsers/ParsersStandardMisc1.cpp rename to DDParsers/src/Spirit/ParsersStandardMisc1.cpp index 25bc57b99..f12e9abf3 --- a/DDParsers/src/parsers/ParsersStandardMisc1.cpp +++ b/DDParsers/src/Spirit/ParsersStandardMisc1.cpp @@ -9,7 +9,7 @@ // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // //========================================================================== -#include "ParsersStandardMiscCommon.h" +#include "Parsers/spirit/ParsersStandardMiscCommon.h" int dd4hep::Parsers::parse(std::pair<double,double>& result, const std::string& input) { return dd4hep::Parsers::parse_(result, input); diff --git a/DDParsers/src/parsers/ParsersStandardMisc2.cpp b/DDParsers/src/Spirit/ParsersStandardMisc2.cpp old mode 100644 new mode 100755 similarity index 92% rename from DDParsers/src/parsers/ParsersStandardMisc2.cpp rename to DDParsers/src/Spirit/ParsersStandardMisc2.cpp index d8360d887..fe32e814a --- a/DDParsers/src/parsers/ParsersStandardMisc2.cpp +++ b/DDParsers/src/Spirit/ParsersStandardMisc2.cpp @@ -9,7 +9,7 @@ // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // //========================================================================== -#include "ParsersStandardMiscCommon.h" +#include "Parsers/spirit/ParsersStandardMiscCommon.h" int dd4hep::Parsers::parse(std::vector<std::vector<double> >& result, const std::string& input) { return dd4hep::Parsers::parse_(result, input); diff --git a/DDParsers/src/parsers/ParsersStandardMisc3.cpp b/DDParsers/src/Spirit/ParsersStandardMisc3.cpp old mode 100644 new mode 100755 similarity index 92% rename from DDParsers/src/parsers/ParsersStandardMisc3.cpp rename to DDParsers/src/Spirit/ParsersStandardMisc3.cpp index 6aaae862d..d9a5906c7 --- a/DDParsers/src/parsers/ParsersStandardMisc3.cpp +++ b/DDParsers/src/Spirit/ParsersStandardMisc3.cpp @@ -9,7 +9,7 @@ // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // //========================================================================== -#include "ParsersStandardMiscCommon.h" +#include "Parsers/spirit/ParsersStandardMiscCommon.h" int dd4hep::Parsers::parse(std::map<std::string, std::vector<std::string> >& result, const std::string& input) { return dd4hep::Parsers::parse_(result, input); diff --git a/DDParsers/src/parsers/ParsersStandardMisc4.cpp b/DDParsers/src/Spirit/ParsersStandardMisc4.cpp old mode 100644 new mode 100755 similarity index 93% rename from DDParsers/src/parsers/ParsersStandardMisc4.cpp rename to DDParsers/src/Spirit/ParsersStandardMisc4.cpp index e9ddccc89..a7da9ba30 --- a/DDParsers/src/parsers/ParsersStandardMisc4.cpp +++ b/DDParsers/src/Spirit/ParsersStandardMisc4.cpp @@ -9,7 +9,7 @@ // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // //========================================================================== -#include "ParsersStandardMiscCommon.h" +#include "Parsers/spirit/ParsersStandardMiscCommon.h" int dd4hep::Parsers::parse(std::map<std::string, std::vector<int> >& result, const std::string& input) { return dd4hep::Parsers::parse_(result, input); diff --git a/DDParsers/src/parsers/ParsersStandardMisc5.cpp b/DDParsers/src/Spirit/ParsersStandardMisc5.cpp old mode 100644 new mode 100755 similarity index 96% rename from DDParsers/src/parsers/ParsersStandardMisc5.cpp rename to DDParsers/src/Spirit/ParsersStandardMisc5.cpp index 7cc009a31..5bb576dff --- a/DDParsers/src/parsers/ParsersStandardMisc5.cpp +++ b/DDParsers/src/Spirit/ParsersStandardMisc5.cpp @@ -8,7 +8,7 @@ // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // //========================================================================== -#include "ParsersStandardMiscCommon.h" +#include "Parsers/spirit/ParsersStandardMiscCommon.h" #if defined(DD4HEP_HAVE_ALL_PARSERS) int dd4hep::Parsers::parse(std::map<unsigned int, std::string>& result, const std::string& input) { diff --git a/DDParsers/src/parsers/ParsersStandardSingle.cpp b/DDParsers/src/Spirit/ParsersStandardSingle.cpp old mode 100644 new mode 100755 similarity index 96% rename from DDParsers/src/parsers/ParsersStandardSingle.cpp rename to DDParsers/src/Spirit/ParsersStandardSingle.cpp index 849aef7d9..f65f7d386 --- a/DDParsers/src/parsers/ParsersStandardSingle.cpp +++ b/DDParsers/src/Spirit/ParsersStandardSingle.cpp @@ -8,7 +8,7 @@ // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // //========================================================================== -#include "ParsersFactory.h" +#include "Parsers/spirit/ParsersFactory.h" PARSERS_DEF_FOR_SINGLE(bool) PARSERS_DEF_FOR_SINGLE(int) diff --git a/DDParsers/src/ToStream.cpp b/DDParsers/src/Spirit/ToStream.cpp old mode 100644 new mode 100755 similarity index 98% rename from DDParsers/src/ToStream.cpp rename to DDParsers/src/Spirit/ToStream.cpp index 0bdaf3a34..7f48c2c0d --- a/DDParsers/src/ToStream.cpp +++ b/DDParsers/src/Spirit/ToStream.cpp @@ -22,7 +22,7 @@ #else // Standard dd4hep parser handling -#include "DDParsers/ToStream.h" +#include "Parsers/spirit/ToStream.h" #endif -- GitLab