diff --git a/DDCore/include/DD4hep/BasicGrammar_inl.h b/DDCore/include/DD4hep/BasicGrammar_inl.h index 06c95e975ea4fcd6c7410283bf2615a05347c5e6..33d1a201e5121a66d14e68170ff4532a45639b26 100644 --- a/DDCore/include/DD4hep/BasicGrammar_inl.h +++ b/DDCore/include/DD4hep/BasicGrammar_inl.h @@ -69,15 +69,15 @@ namespace DD4hep { /// Default destructor virtual ~Grammar(); /// PropertyGrammar overload: Access to the type information - virtual const std::type_info& type() const; + virtual const std::type_info& type() const override; /// Access to the type information name - virtual const std::string& type_name() const; + virtual const std::string& type_name() const override; /// Access the object size (sizeof operator) - virtual size_t sizeOf() const; + virtual size_t sizeOf() const override; /// PropertyGrammar overload: Serialize a property to a string - virtual std::string str(const void* ptr) const; + virtual std::string str(const void* ptr) const override; /// PropertyGrammar overload: Retrieve value from string - virtual bool fromString(void* ptr, const std::string& value) const; + virtual bool fromString(void* ptr, const std::string& value) const override; /// Evaluate string value if possible before calling boost::spirit virtual int evaluate(void* ptr, const std::string& value) const; }; diff --git a/DDCore/include/XML/UriReader.h b/DDCore/include/XML/UriReader.h index 0ee15cd34cb714ae33432f7a4b9ea19a3e1d0989..11d828a492507657c9a1a3277f314d8b62a226b1 100644 --- a/DDCore/include/XML/UriReader.h +++ b/DDCore/include/XML/UriReader.h @@ -81,15 +81,15 @@ namespace DD4hep { /// Default destructor virtual ~UriContextReader(); /// Access to local context - virtual UserContext* context() { return m_context; } + virtual UserContext* context() override { return m_context; } /// Resolve a given URI to a string containing the data - virtual bool load(const std::string& system_id, std::string& data); + virtual bool load(const std::string& system_id, std::string& data) override; /// Resolve a given URI to a string containing the data with context - virtual bool load(const std::string& system_id, UserContext* context, std::string& data); + virtual bool load(const std::string& system_id, UserContext* context, std::string& data) override; /// Inform reader about a locally (e.g. by XercesC) handled source load - virtual void parserLoaded(const std::string& system_id); + virtual void parserLoaded(const std::string& system_id) override; /// Inform reader about a locally (e.g. by XercesC) handled source load - virtual void parserLoaded(const std::string& system_id, UserContext* ctxt); + virtual void parserLoaded(const std::string& system_id, UserContext* ctxt) override; }; } /* End namespace XML */ diff --git a/DDCore/include/XML/XML.h b/DDCore/include/XML/XML.h index 25f983d51c42787b491d108e31f4be6281943ba4..89ebc5bec17f8472a2c4ad5a5059660ce477c39e 100644 --- a/DDCore/include/XML/XML.h +++ b/DDCore/include/XML/XML.h @@ -11,8 +11,8 @@ // //========================================================================== -#ifndef DD4HEP_DDCORE_XML_TYPES_H -#define DD4HEP_DDCORE_XML_TYPES_H +#ifndef DD4HEP_DDCORE_XML_XML_H +#define DD4HEP_DDCORE_XML_XML_H #include "XML/XMLTags.h" #include "XML/XMLDimension.h" @@ -28,4 +28,4 @@ typedef DD4hep::XML::Dimension xml_dim_t; typedef DD4hep::XML::Document xml_doc_t; typedef DD4hep::XML::Strng_t Unicode; -#endif // DD4HEP_DDCORE_XML_TYPES_H +#endif // DD4HEP_DDCORE_XML_XML_H diff --git a/DDCore/include/XML/tinyxml.h b/DDCore/include/XML/tinyxml.h index a2e71bc08123e0dbed26df8f964830c73e4f8e68..c893d40851d95371deb11c969af28d4938316cd4 100644 --- a/DDCore/include/XML/tinyxml.h +++ b/DDCore/include/XML/tinyxml.h @@ -981,10 +981,10 @@ public: /* Attribute parsing starts: first letter of the name returns: the next char after the value end quote */ - virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); + virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) override; // Prints this Attribute to a FILE stream. - virtual void Print(FILE* cfile, int depth) const { + virtual void Print(FILE* cfile, int depth) const override { Print(cfile, depth, 0); } void Print(FILE* cfile, int depth, TIXML_STRING* str) const; @@ -1235,25 +1235,25 @@ public: const char* GetText() const; /// Creates a new Element and returns it - the returned element is a copy. - virtual TiXmlNode* Clone() const; + virtual TiXmlNode* Clone() const override; // Print the Element to a FILE stream. - virtual void Print(FILE* cfile, int depth) const; + virtual void Print(FILE* cfile, int depth) const override; /* Attribtue parsing starts: next char past '<' returns: next char past '>' */ - virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); + virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) override; - virtual const TiXmlElement* ToElement() const { + virtual const TiXmlElement* ToElement() const override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlElement* ToElement() { + virtual TiXmlElement* ToElement() override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ - virtual bool Accept(TiXmlVisitor* visitor) const; + virtual bool Accept(TiXmlVisitor* visitor) const override; protected: @@ -1262,7 +1262,7 @@ protected: // Used to be public [internal use] #ifdef TIXML_USE_STL - virtual void StreamIn(std::istream * in, TIXML_STRING * tag); + virtual void StreamIn(std::istream * in, TIXML_STRING * tag) override; #endif /* [internal use] Reads the "value" of the element -- another element, or text. @@ -1295,32 +1295,32 @@ public: } /// Returns a copy of this Comment. - virtual TiXmlNode* Clone() const; + virtual TiXmlNode* Clone() const override; // Write this Comment to a FILE stream. - virtual void Print(FILE* cfile, int depth) const; + virtual void Print(FILE* cfile, int depth) const override; /* Attribtue parsing starts: at the ! of the !-- returns: next char past '>' */ - virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); + virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) override; - virtual const TiXmlComment* ToComment() const { + virtual const TiXmlComment* ToComment() const override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { + virtual TiXmlComment* ToComment() override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ - virtual bool Accept(TiXmlVisitor* visitor) const; + virtual bool Accept(TiXmlVisitor* visitor) const override; protected: void CopyTo(TiXmlComment* target) const; // used to be public #ifdef TIXML_USE_STL - virtual void StreamIn(std::istream * in, TIXML_STRING * tag); + virtual void StreamIn(std::istream * in, TIXML_STRING * tag) override; #endif // virtual void StreamOut( TIXML_OSTREAM * out ) const; @@ -1366,7 +1366,7 @@ public: } // Write this text object to a FILE stream. - virtual void Print(FILE* cfile, int depth) const; + virtual void Print(FILE* cfile, int depth) const override; /// Queries whether this represents text using a CDATA section. bool CDATA() const { @@ -1377,28 +1377,28 @@ public: cdata = _cdata; } - virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); + virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) override; - virtual const TiXmlText* ToText() const { + virtual const TiXmlText* ToText() const override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlText* ToText() { + virtual TiXmlText* ToText() override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ - virtual bool Accept(TiXmlVisitor* content) const; + virtual bool Accept(TiXmlVisitor* content) const override; protected: /// [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; + virtual TiXmlNode* Clone() const override; void CopyTo(TiXmlText* target) const; bool Blank() const; // returns true if all white space and new lines // [internal use] #ifdef TIXML_USE_STL - virtual void StreamIn(std::istream * in, TIXML_STRING * tag); + virtual void StreamIn(std::istream * in, TIXML_STRING * tag) override; #endif private: @@ -1453,31 +1453,31 @@ public: } /// Creates a copy of this Declaration and returns it. - virtual TiXmlNode* Clone() const; + virtual TiXmlNode* Clone() const override; // Print this declaration to a FILE stream. virtual void Print(FILE* cfile, int depth, TIXML_STRING* str) const; - virtual void Print(FILE* cfile, int depth) const { + virtual void Print(FILE* cfile, int depth) const override { Print(cfile, depth, 0); } - virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); + virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) override; - virtual const TiXmlDeclaration* ToDeclaration() const { + virtual const TiXmlDeclaration* ToDeclaration() const override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { + virtual TiXmlDeclaration* ToDeclaration() override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ - virtual bool Accept(TiXmlVisitor* visitor) const; + virtual bool Accept(TiXmlVisitor* visitor) const override; protected: void CopyTo(TiXmlDeclaration* target) const; // used to be public #ifdef TIXML_USE_STL - virtual void StreamIn(std::istream * in, TIXML_STRING * tag); + virtual void StreamIn(std::istream * in, TIXML_STRING * tag) override; #endif private: @@ -1509,28 +1509,28 @@ public: } /// Creates a copy of this Unknown and returns it. - virtual TiXmlNode* Clone() const; + virtual TiXmlNode* Clone() const override; // Print this Unknown to a FILE stream. - virtual void Print(FILE* cfile, int depth) const; + virtual void Print(FILE* cfile, int depth) const override; - virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding); + virtual const char* Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) override; - virtual const TiXmlUnknown* ToUnknown() const { + virtual const TiXmlUnknown* ToUnknown() const override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { + virtual TiXmlUnknown* ToUnknown() override{ return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ - virtual bool Accept(TiXmlVisitor* content) const; + virtual bool Accept(TiXmlVisitor* content) const override; protected: void CopyTo(TiXmlUnknown* target) const; #ifdef TIXML_USE_STL - virtual void StreamIn(std::istream * in, TIXML_STRING * tag); + virtual void StreamIn(std::istream * in, TIXML_STRING * tag) override; #endif private: @@ -1598,7 +1598,7 @@ public: method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml to use that encoding, regardless of what TinyXml might otherwise try to detect. */ - virtual const char* Parse(const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING); + virtual const char* Parse(const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING) override; /** Get the root element -- the only top level element -- of the document. In well formed XML, there should only be one. TinyXml is tolerant of @@ -1690,7 +1690,7 @@ public: } /** Write the document to standard out using formatted printing ("pretty print"). */ - void Print() const { + void Print() const { Print(stdout, 0); } @@ -1700,26 +1700,26 @@ public: */ //char* PrintToMemory() const; /// Print this Document to a FILE stream. - virtual void Print(FILE* cfile, int depth = 0) const; + virtual void Print(FILE* cfile, int depth = 0) const override; // [internal use] void SetError(int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding); - virtual const TiXmlDocument* ToDocument() const { + virtual const TiXmlDocument* ToDocument() const override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDocument* ToDocument() { + virtual TiXmlDocument* ToDocument() override { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ - virtual bool Accept(TiXmlVisitor* content) const; + virtual bool Accept(TiXmlVisitor* content) const override; protected: // [internal use] - virtual TiXmlNode* Clone() const; + virtual TiXmlNode* Clone() const override; #ifdef TIXML_USE_STL - virtual void StreamIn(std::istream * in, TIXML_STRING * tag); + virtual void StreamIn(std::istream * in, TIXML_STRING * tag) override; #endif private: @@ -1946,16 +1946,16 @@ public: : depth(0), simpleTextPrint(false), buffer(), indent(" "), lineBreak("\n") { } - virtual bool VisitEnter(const TiXmlDocument& doc); - virtual bool VisitExit(const TiXmlDocument& doc); + virtual bool VisitEnter(const TiXmlDocument& doc) override; + virtual bool VisitExit(const TiXmlDocument& doc) override; - virtual bool VisitEnter(const TiXmlElement& element, const TiXmlAttribute* firstAttribute); - virtual bool VisitExit(const TiXmlElement& element); + virtual bool VisitEnter(const TiXmlElement& element, const TiXmlAttribute* firstAttribute) override; + virtual bool VisitExit(const TiXmlElement& element) override; - virtual bool Visit(const TiXmlDeclaration& declaration); - virtual bool Visit(const TiXmlText& text); - virtual bool Visit(const TiXmlComment& comment); - virtual bool Visit(const TiXmlUnknown& unknown); + virtual bool Visit(const TiXmlDeclaration& declaration) override; + virtual bool Visit(const TiXmlText& text) override; + virtual bool Visit(const TiXmlComment& comment) override; + virtual bool Visit(const TiXmlUnknown& unknown) override; /** Set the indent characters for printing. By default 4 spaces but tab (\t) is also useful, or null/empty string for no indentation. diff --git a/doc/externalize/ExtraProperties.cpp b/doc/externalize/ExtraProperties.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3f226b9efa9b42b258ba0d8560396e02650af673 --- /dev/null +++ b/doc/externalize/ExtraProperties.cpp @@ -0,0 +1,53 @@ +//========================================================================== +// 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 "DD4hep/Parsers.h" +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + /// Namespace for the AIDA detector for utilities using boost::spirit parsers + namespace Parsers { + PARSERS_DECL_FOR_SINGLE(unsigned int) + PARSERS_DECL_FOR_SINGLE(unsigned long) + } +} +#include "DD4hep/BasicGrammar_inl.h" +#include "DD4hep/ComponentProperties_inl.h" + +// C/C++ include files +#include <map> + +typedef std::map<std::string, std::vector<std::string> > map_t; +DD4HEP_DEFINE_PARSER_GRAMMAR(map_t,eval_obj) +namespace DD4hep { + DD4HEP_DEFINE_PROPERTY_TYPE(map_t); +} + +DD4HEP_DEFINE_PARSER_GRAMMAR(unsigned int,eval_item) +DD4HEP_DEFINE_PARSER_GRAMMAR(unsigned long,eval_item) +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + DD4HEP_DEFINE_PROPERTY_TYPE(unsigned int); + DD4HEP_DEFINE_PROPERTY_TYPE(unsigned long); +} diff --git a/doc/externalize/Printout.cpp b/doc/externalize/Printout.cpp index 8205beb90a829c62235781fadb26b068a67b9da9..9c02b4ad69c81b47f55768dc5701e6c467e8b179 100644 --- a/doc/externalize/Printout.cpp +++ b/doc/externalize/Printout.cpp @@ -41,8 +41,28 @@ namespace { return print_level(DD4hep::NOLOG); } } + size_t print_out(DD4hep::PrintLevel lvl, const char* src, const char* fmt, va_list& args) { + char text[4096]; + ::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; + } +} + +/// 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; +} + + /** Calls the display action * \arg severity [int,read-only] Display severity flag * \arg src [string,read-only] Information source (component, etc.) @@ -53,7 +73,7 @@ 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); + print_out(severity, src, fmt, args); va_end(args); } return 1; @@ -69,7 +89,7 @@ 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); + print_out(severity, src.c_str(), fmt, args); va_end(args); } return 1; diff --git a/doc/externalize/Printout.h b/doc/externalize/Printout.h index 9939ae122a4c9599763cf557b76816db7efbebf8..563c724a42f75668aaf206b0c1a0e79a921387b1 100644 --- a/doc/externalize/Printout.h +++ b/doc/externalize/Printout.h @@ -29,6 +29,12 @@ namespace DD4hep { FATAL = 6, ALWAYS = 7 }; + /// Access the current printer level + PrintLevel printLevel(); + + /// Set new print level. Returns the old print level + PrintLevel setPrintLevel(PrintLevel new_level); + /// Calls the display action with a given severity level /** * @arg severity [int,read-only] Display severity flag (see enum) diff --git a/doc/externalize/externalize_properties.sh b/doc/externalize/externalize_properties.sh index 9c48e0c1b182c099011300d5eaa6b8d1a20a17b4..f4f9d4bd1a06c94f19d886379b692ce8c30bc96c 100755 --- a/doc/externalize/externalize_properties.sh +++ b/doc/externalize/externalize_properties.sh @@ -25,6 +25,7 @@ copy_files() { ${target}/src/DD4hep/; cd -; scp doc/externalize/PluginManager.cpp ${target}/src/DD4hep/; + scp doc/externalize/ExtraProperties.cpp ${target}/src/DD4hep/; } TARGET=${1};