diff --git a/DDCore/include/JSON/ChildValue.h b/DDCore/include/JSON/ChildValue.h new file mode 100644 index 0000000000000000000000000000000000000000..794a6e89ab993048f6f32088d298b3959ea7a29c --- /dev/null +++ b/DDCore/include/JSON/ChildValue.h @@ -0,0 +1,33 @@ +//========================================================================== +// 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 : M.Frank +// +//========================================================================== +#ifndef DD4HEP_JSON_CHILDVALUE_H +#define DD4HEP_JSON_CHILDVALUE_H + +// Framework include files +#include "JSON/Dimension.h" + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + // Forward declarations + class NamedObject; + + /// Namespace for the AIDA detector description toolkit supporting JSON utilities + namespace JSON { + + /// Include the implementation in the proper namespace +#include "XML/detail/ChildValue.h" + + } /* End namespace JSON */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_JSON_CHILDVALUE_H */ diff --git a/DDCore/include/JSON/ChildValue.inl b/DDCore/include/JSON/ChildValue.inl new file mode 100644 index 0000000000000000000000000000000000000000..0b727b5de38b51b2276f9c6ec2e6e562f6c8b9e5 --- /dev/null +++ b/DDCore/include/JSON/ChildValue.inl @@ -0,0 +1,24 @@ +//========================================================================== +// 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 : M.Frank +// +//========================================================================== + +#ifndef DD4HEP_JSONCHILDVALUE_INL +#define DD4HEP_JSONCHILDVALUE_INL + +// Configuration definitions +#define CHILDVALUE_NS JSON + +// Framework include files +#include "JSON/ChildValue.h" +#include "XML/detail/ChildValue.inl" + +#endif /* DD4HEP_JSONCHILDVALUE_INL */ diff --git a/DDCore/include/JSON/Dimension.h b/DDCore/include/JSON/Dimension.h index c8e369618d395d1920a13e1359863dc454556deb..2b8b06c6ee8918f486cb3988d754545463cc1078 100644 --- a/DDCore/include/JSON/Dimension.h +++ b/DDCore/include/JSON/Dimension.h @@ -26,6 +26,6 @@ namespace DD4hep { /// Re-use the defined interface for the XML data access #include "XML/detail/Dimension.h" - } /* End namespace JSON */ -} /* End namespace DD4hep */ -#endif /* DD4HEP_JSON_DIMENSION_H */ + } /* End namespace JSON */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_JSON_DIMENSION_H */ diff --git a/DDCore/include/XML/detail/ChildValue.imp b/DDCore/include/XML/detail/ChildValue.imp index 8d96518fd130d50a354d621b1e661489abf70d25..d482a5880fc2b135e8c5850e36a1dbde89364c3d 100644 --- a/DDCore/include/XML/detail/ChildValue.imp +++ b/DDCore/include/XML/detail/ChildValue.imp @@ -11,6 +11,13 @@ // //========================================================================== +/** + * Note: Do NEVER include this file directly! + * + * Use the specific include files in the XML or JSON directory! + * Also NO header guards! + */ + XML_CHILDVALUE_ACCESSOR(int, id) XML_CHILDVALUE_ACCESSOR_INT(id) XML_CHILDVALUE_ACCESSOR(bool, combineHits) diff --git a/DDCore/include/XML/detail/ChildValue.inl b/DDCore/include/XML/detail/ChildValue.inl index 2c674ddbd50578bc12f6617da5490ca8f3d41e51..d7da2ac24dbbb902ed250a565207a8d948c61ece 100644 --- a/DDCore/include/XML/detail/ChildValue.inl +++ b/DDCore/include/XML/detail/ChildValue.inl @@ -20,10 +20,11 @@ */ -#define XML_CHILDVALUE_childValue(name,type) m_element.child(Unicode_##name).attr<type>(_DD4hep_Unicode_Item(value)) +#define XML_CHILDVALUE_childValue(name,type) \ + m_element.child(_DD4hep_Unicode_Item(name)).attr<type>(_DD4hep_Unicode_Item(value)) #define XML_CHILDVALUE_childValueDefault(name,type,def) \ - Handle_t __h = m_element.child(Unicode_##name,false); \ + Handle_t __h = m_element.child(_DD4hep_Unicode_Item(name),false); \ if ( __h.ptr() && __h.hasAttr(_DD4hep_Unicode_Item(value)) ) return __h.attr < type > (_DD4hep_Unicode_Item(value)); \ return def; @@ -32,7 +33,7 @@ #define XML_CHILDVALUE_ACCESSOR_DEFAULT(name,type,dressing) \ type ChildValue::name(type default_val) const { \ - Handle_t __h = m_element.child(Unicode_##name,false); \ + Handle_t __h = m_element.child(_DD4hep_Unicode_Item(name),false); \ if ( __h.ptr() ) { \ const XmlChar* val = __h.attr_value_nothrow(_DD4hep_Unicode_Item(value)); \ return val ? dressing(val) : default_val; } \ diff --git a/DDCore/include/XML/detail/Detector.h b/DDCore/include/XML/detail/Detector.h index a420dbd03e804a4431506b183b140004a1f3c808..ccf4d9a697e96336c3e4f17bf1c628cffeab59b5 100644 --- a/DDCore/include/XML/detail/Detector.h +++ b/DDCore/include/XML/detail/Detector.h @@ -10,19 +10,15 @@ // Author : M.Frank // //========================================================================== -#ifndef DD4HEP_XML_DETAIL_DETECTOR_H -#define DD4HEP_XML_DETAIL_DETECTOR_H /** * Note: Do NEVER include this file directly! * + * Also NO header guards! * Include XML/XMLDetector.h or JSON/Detector.h ! */ -// Framework includes -#include "XML/detail/Dimension.h" - -/// XML Handle class extending the XML handle Dimension +/// Generic Handle class extending the generic handle Dimension /** * Helper class to access any field in a xml tag. * Specialized for attributes of a detector sub-element. @@ -90,5 +86,3 @@ struct DetElement: public Dimension { return m_element.attr < T > (tag_value); } }; - -#endif /* DD4HEP_XML_DETAIL_DETECTOR_H */ diff --git a/DDCore/include/XML/detail/Detector.imp b/DDCore/include/XML/detail/Detector.imp index 8418b003c0556e90d4f36b20cb28418189fa5615..524aba7fbb8eff2d7b75d577d647f40adb223679 100644 --- a/DDCore/include/XML/detail/Detector.imp +++ b/DDCore/include/XML/detail/Detector.imp @@ -11,6 +11,15 @@ // //========================================================================== + +/** + * Note: Do NEVER include this file directly! + * + * Use the specific include files in the XML or JSON directory! + * Also NO header guards! + */ + + // Framework include files #include "DD4hep/Plugins.h" #include "DD4hep/LCDD.h" diff --git a/DDCore/include/XML/detail/Dimension.h b/DDCore/include/XML/detail/Dimension.h index d64042f73ac149f77e569f74b5f1f1f710efc6f9..09e524fdf6995007ef05f6eb36db51e88525aeeb 100644 --- a/DDCore/include/XML/detail/Dimension.h +++ b/DDCore/include/XML/detail/Dimension.h @@ -10,12 +10,11 @@ // Author : M.Frank // //========================================================================== -#ifndef DD4HEP_XML_DETAIL_DIMENSION_H -#define DD4HEP_XML_DETAIL_DIMENSION_H /** * Note: Do NEVER include this file directly! * + * Also NO header guards! * Include XML/XMLDimension.h or JSON/Dimension.h ! */ @@ -564,5 +563,3 @@ struct Dimension: public Element { /// Access limits attribute as STL string. If not present empty return empty string std::string limitsStr() const; }; - -#endif /* DD4HEP_XML_DETAIL_DIMENSION_H */ diff --git a/DDCore/include/XML/detail/Dimension.imp b/DDCore/include/XML/detail/Dimension.imp index 9d7b7d705ad195541b9cc2cfa7aa296f8837ba7e..ee263302a6fdb092bedd8c5c3a664843f39ad2a1 100644 --- a/DDCore/include/XML/detail/Dimension.imp +++ b/DDCore/include/XML/detail/Dimension.imp @@ -11,7 +11,13 @@ // //========================================================================== -#include "XML/detail/Dimension.inl" + +/** + * Note: Do NEVER include this file directly! + * + * Use the specific include files in the XML or JSON directory! + * Also NO header guards! + */ XML_ATTR_ACCESSOR(int, id) XML_ATTR_ACCESSOR_INT(id) diff --git a/DDCore/include/XML/detail/Dimension.inl b/DDCore/include/XML/detail/Dimension.inl index aeb2fc66283b9b7a126fa4d2e2d13b03ef6952af..a41da30a5d1d5cdca6188b456bf7a46feed712b4 100644 --- a/DDCore/include/XML/detail/Dimension.inl +++ b/DDCore/include/XML/detail/Dimension.inl @@ -11,12 +11,10 @@ // //========================================================================== -#ifndef DD4HEP_XML_DETAIL_DIMENSION_INL -#define DD4HEP_XML_DETAIL_DIMENSION_INL - /** * Note: Do NEVER include this file directly! * + * Also NO header guards! * Include XML/XMLDimension.h or JSON/Dimension.h ! */ @@ -51,5 +49,3 @@ #define XML_CHILD_ACCESSOR_XML_DIM(name) \ DD4hep::DIMENSION_NS::Dimension DD4hep::DIMENSION_NS::Dimension::name(bool throw_if_not_present) const { \ return m_element.child(_DD4hep_Unicode_Item(name),throw_if_not_present); } - -#endif /* DD4HEP_XML_DETAIL_DIMENSION_INL */ diff --git a/DDCore/include/XML/detail/README.txt b/DDCore/include/XML/detail/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..2aeecc4ecf3edd184fac9bb60783c2e1fe8c0850 --- /dev/null +++ b/DDCore/include/XML/detail/README.txt @@ -0,0 +1,23 @@ + +XML/detail +---------- + +This directory is used to implement helpers to input parsers. +These common implementation of the helpers should ensure that all +dependent parsers offer a rather identical interface to users. + +The base interface is implemented in the Element header file, +but all derived classes such as Dimension, Component or Detector +have the identical interface and are supposed to ease the access +to inditvidual attributes or child elements independent if the +underlying implementation is based on: + +-- XercesC --> uses the XML branch +-- TinyXML --> uses the XML branch +-- JSON --> Uses the JSON branch + with the implementation of boost::property_tree +-- RapitXML --> 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/src/JSON/Helpers.cpp b/DDCore/src/JSON/Helpers.cpp index d6f197354a991e999405b2e24dad1bbecffb2f22..d8ae985d7dc1b4ed8c6f9181c5c4979d148c4cad 100644 --- a/DDCore/src/JSON/Helpers.cpp +++ b/DDCore/src/JSON/Helpers.cpp @@ -14,9 +14,11 @@ // Framework include files #include "JSON/Detector.h" #include "JSON/Dimension.inl" +#include "JSON/ChildValue.inl" using namespace DD4hep::JSON; // Instantiate here the concrete implementations -#include "XML/detail/Dimension.imp" #include "XML/detail/Detector.imp" +#include "XML/detail/Dimension.imp" +#include "XML/detail/ChildValue.imp" diff --git a/DDCore/src/XML/XMLHelpers.cpp b/DDCore/src/XML/XMLHelpers.cpp index 387911b463e50da5daf553e2b8f3ccfc092be782..5390050946b0cc97ab1fd167fd1050bd19ec2f35 100644 --- a/DDCore/src/XML/XMLHelpers.cpp +++ b/DDCore/src/XML/XMLHelpers.cpp @@ -17,6 +17,8 @@ #include "XML/XMLChildValue.inl" using namespace DD4hep::XML; + +// Instantiate here the concrete implementations #include "XML/detail/Detector.imp" #include "XML/detail/Dimension.imp" #include "XML/detail/ChildValue.imp"