From 12cd0bedc9884e018d1a56e62421d6f25a969e51 Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Tue, 30 Aug 2016 11:26:28 +0000 Subject: [PATCH] Remove MAC warnings. Test: Remove boost::file_system link dependency. --- DDCore/include/DD4hep/Handle.h | 32 +++++++++++----------- DDCore/include/DD4hep/Primitives.h | 8 ++---- DDCore/include/XML/XMLElements.h | 8 +++--- DDCore/src/DetectorInterna.cpp | 2 +- DDCore/src/LCDDData.cpp | 18 ++++++------- DDCore/src/VolumeManagerInterna.cpp | 2 +- DDCore/src/XML/XMLElements.cpp | 41 ++++++++++++++++++----------- DDDB/CMakeLists.txt | 2 +- 8 files changed, 58 insertions(+), 55 deletions(-) diff --git a/DDCore/include/DD4hep/Handle.h b/DDCore/include/DD4hep/Handle.h index 2c24816f2..f46eae0bb 100644 --- a/DDCore/include/DD4hep/Handle.h +++ b/DDCore/include/DD4hep/Handle.h @@ -200,34 +200,32 @@ namespace DD4hep { /// Functor to destroy handles and delete the cached object \ingroup DD4HEP_GEOMETRY template <typename T> class DestroyHandle { public: - void operator()(T p) const { - destroyHandle(p); - } + void operator()(T p) const { destroyHandle(p); } }; /// Functor to destroy handles and delete the cached object \ingroup DD4HEP_GEOMETRY template <typename T> class ReleaseHandle { public: - void operator()(T p) const { - releaseHandle(p); - } + void operator()(T p) const { releaseHandle(p); } }; /// map Functor to destroy handles and delete the cached object \ingroup DD4HEP_GEOMETRY template <typename M> class DestroyHandles { public: + /// Container reference M& object; - DestroyHandles(M& m) - : object(m) { - } - ~DestroyHandles() { - object.clear(); - } - void operator()(std::pair<typename M::key_type, typename M::mapped_type> p) const { - DestroyHandle<typename M::mapped_type>()(p.second); - } + /// Copy constructor allowed! + DestroyHandles(const DestroyHandles& c) : object(c.object) {} + /// Initializing constructor + DestroyHandles(M& m) : object(m) { } + /// Defautl destructor + ~DestroyHandles() { } + /// Action operator + void operator()(const std::pair<typename M::key_type, typename M::mapped_type>& p) const + { DestroyHandle<typename M::mapped_type>()(p.second); } }; /// Functional created of map destruction functors - template <typename M> DestroyHandles<M> destroyHandles(M& m) { - return DestroyHandles<M>(m); + template <typename M> void destroyHandles(M& m) { + for_each(m.begin(), m.end(), DestroyHandles<M>(m)); + m.clear(); } /// String conversions: boolean value to string \ingroup DD4HEP_GEOMETRY diff --git a/DDCore/include/DD4hep/Primitives.h b/DDCore/include/DD4hep/Primitives.h index 1dc02eb4c..37801a006 100644 --- a/DDCore/include/DD4hep/Primitives.h +++ b/DDCore/include/DD4hep/Primitives.h @@ -268,12 +268,8 @@ namespace DD4hep { template <typename M> class DestroyObjects { public: M& object; - DestroyObjects(M& m) - : object(m) { - } - ~DestroyObjects() { - object.clear(); - } + DestroyObjects(M& m) : object(m) { } + ~DestroyObjects() { object.clear(); } void operator()(std::pair<typename M::key_type, typename M::mapped_type> p) const { DestroyObject<typename M::mapped_type>()(p.second); } diff --git a/DDCore/include/XML/XMLElements.h b/DDCore/include/XML/XMLElements.h index 3e2d6ce8a..d437a33f1 100644 --- a/DDCore/include/XML/XMLElements.h +++ b/DDCore/include/XML/XMLElements.h @@ -682,9 +682,9 @@ namespace DD4hep { Handle_t m_element; /// Constructor from XmlElement handle - Element(const Handle_t& e) - : m_element(e) { - } + Element(const Handle_t& e) : m_element(e) { } + /// Constructor from XmlElement handle + Element(const Element& e) : m_element(e.m_element) { } /// Constructor from DOM document entity Element(const Document& document, const XmlChar* type); /// Access the hosting document handle of this DOM element @@ -722,7 +722,7 @@ namespace DD4hep { } /// Access the XmlElements parent Handle_t parent() const { - return m_element.parent(); + return m_element.parent(); } /// Access the XmlElements parent Elt_t parentElement() const; diff --git a/DDCore/src/DetectorInterna.cpp b/DDCore/src/DetectorInterna.cpp index 3eb460591..9b31f1958 100644 --- a/DDCore/src/DetectorInterna.cpp +++ b/DDCore/src/DetectorInterna.cpp @@ -85,7 +85,7 @@ DetElementObject::DetElementObject(const std::string& nam, int ident) /// Internal object destructor: release extension object(s) DetElementObject::~DetElementObject() { - for_each(children.begin(), children.end(), destroyHandles(children)); + destroyHandles(children); deletePtr (referenceTrafo); if ( conditions.isValid() ) delete conditions.ptr(); conditions = ConditionsContainer(); diff --git a/DDCore/src/LCDDData.cpp b/DDCore/src/LCDDData.cpp index c3f04fd22..d7f048e1f 100644 --- a/DDCore/src/LCDDData.cpp +++ b/DDCore/src/LCDDData.cpp @@ -51,15 +51,15 @@ void LCDDData::destroyData(bool destroy_mgr) { destroyHandle(m_world); destroyHandle(m_field); destroyHandle(m_header); - for_each(m_readouts.begin(), m_readouts.end(), destroyHandles(m_readouts)); - for_each(m_idDict.begin(), m_idDict.end(), destroyHandles(m_idDict)); - for_each(m_limits.begin(), m_limits.end(), destroyHandles(m_limits)); - for_each(m_regions.begin(), m_regions.end(), destroyHandles(m_regions)); - for_each(m_alignments.begin(), m_alignments.end(), destroyHandles(m_alignments)); - for_each(m_sensitive.begin(), m_sensitive.end(), destroyHandles(m_sensitive)); - for_each(m_display.begin(), m_display.end(), destroyHandles(m_display)); - for_each(m_fields.begin(), m_fields.end(), destroyHandles(m_fields)); - for_each(m_define.begin(), m_define.end(), destroyHandles(m_define)); + destroyHandles(m_readouts); + destroyHandles(m_idDict); + destroyHandles(m_limits); + destroyHandles(m_regions); + destroyHandles(m_alignments); + destroyHandles(m_sensitive); + destroyHandles(m_display); + destroyHandles(m_fields); + destroyHandles(m_define); destroyHandle(m_volManager); m_properties.clear(); diff --git a/DDCore/src/VolumeManagerInterna.cpp b/DDCore/src/VolumeManagerInterna.cpp index 9b2f12c39..e8dc6c4c6 100644 --- a/DDCore/src/VolumeManagerInterna.cpp +++ b/DDCore/src/VolumeManagerInterna.cpp @@ -42,7 +42,7 @@ VolumeManagerObject::~VolumeManagerObject() { for_each(volumes.begin(), volumes.end(), destroyObjects(volumes)); volumes.clear(); /// Cleanup dependent managers - for_each(managers.begin(), managers.end(), destroyHandles(managers)); + destroyHandles(managers); managers.clear(); subdetectors.clear(); } diff --git a/DDCore/src/XML/XMLElements.cpp b/DDCore/src/XML/XMLElements.cpp index cce5f9b81..ed518584e 100644 --- a/DDCore/src/XML/XMLElements.cpp +++ b/DDCore/src/XML/XMLElements.cpp @@ -218,14 +218,14 @@ template <typename T> static inline string __to_string(T value, const char* fmt) } /// Do-nothing version. Present for completeness and argument interchangeability -std::string DD4hep::XML::_toString(const char* s) { +string DD4hep::XML::_toString(const char* s) { if ( !s || *s == 0 ) return ""; else if ( !(*s == '$' && *(s+1) == '{') ) return s; return _checkEnviron(s); } /// Do-nothing version. Present for completeness and argument interchangeability -std::string DD4hep::XML::_toString(const std::string& s) { +string DD4hep::XML::_toString(const string& s) { if ( s.length() < 3 || s[0] != '$' ) return s; else if ( !(s[0] == '$' && s[1] == '{') ) return s; return _checkEnviron(s); @@ -348,7 +348,7 @@ void DD4hep::XML::_toDictionary(const XmlChar* name, T value) { #ifndef DD4HEP_USE_TINYXML template void DD4hep::XML::_toDictionary(const XmlChar* name, const char* value); #endif -template void DD4hep::XML::_toDictionary(const XmlChar* name, const std::string& value); +template void DD4hep::XML::_toDictionary(const XmlChar* name, const string& value); template void DD4hep::XML::_toDictionary(const XmlChar* name, unsigned long value); template void DD4hep::XML::_toDictionary(const XmlChar* name, unsigned int value); template void DD4hep::XML::_toDictionary(const XmlChar* name, unsigned short value); @@ -408,40 +408,49 @@ Strng_t DD4hep::XML::operator+(const Strng_t& a, const Strng_t& b) { } Tag_t DD4hep::XML::operator+(const Tag_t& a, const char* b) { - return a.str() + b; + string res = a.str() + b; + return Tag_t(res); } Tag_t DD4hep::XML::operator+(const char* a, const Tag_t& b) { - return a + b.str(); + string res = a + b.str(); + return Tag_t(res); } Tag_t DD4hep::XML::operator+(const Tag_t& a, const Strng_t& b) { - return a.str() + _toString(b); + string res = a.str() + _toString(b); + return Tag_t(res); } Tag_t DD4hep::XML::operator+(const Tag_t& a, const string& b) { - return a.str() + b; + string res = a.str() + b; + return Tag_t(res); } #ifndef DD4HEP_USE_TINYXML Strng_t DD4hep::XML::operator+(const Strng_t& a, const XmlChar* b) { - return _toString(a.ptr()) + _toString(b); + string res = _toString(a.ptr()) + _toString(b); + return Tag_t(res); } Strng_t DD4hep::XML::operator+(const XmlChar* a, const Strng_t& b) { - return _toString(a) + _toString(b.ptr()); + string res = _toString(a) + _toString(b.ptr()); + return Tag_t(res); } Strng_t DD4hep::XML::operator+(const XmlChar* a, const string& b) { - return _toString(a) + b; + string res = _toString(a) + b; + return Tag_t(res); } Strng_t DD4hep::XML::operator+(const string& a, const XmlChar* b) { - return a + _toString(b); + string res = a + _toString(b); + return Tag_t(res); } Tag_t DD4hep::XML::operator+(const Tag_t& a, const XmlChar* b) { - return a.str() + _toString(b); + string res = a.str() + _toString(b); + return Tag_t(res); } Strng_t& Strng_t::operator=(const XmlChar* s) { @@ -949,7 +958,7 @@ static unsigned int adler32(unsigned int adler, const XmlChar* xml_buff, size_t typedef unsigned int (fcn_t)(unsigned int, const XmlChar*, size_t); unsigned int Handle_t::checksum(unsigned int param, fcn_t fcn) const { #ifdef DD4HEP_USE_TINYXML - typedef std::map<std::string, std::string> StringMap; + typedef map<string, string> StringMap; TiXmlNode* n = Xml(m_node).n; if ( n ) { if ( 0 == fcn ) fcn = adler32; @@ -1159,11 +1168,11 @@ size_t Collection_t::size() const { } /// Helper function to throw an exception -void Collection_t::throw_loop_exception(const std::exception& e) const { +void Collection_t::throw_loop_exception(const exception& e) const { if (m_node) { - throw runtime_error(std::string(e.what()) + "\n" + "DD4hep: Error interpreting XML nodes of type <" + tag() + "/>"); + throw runtime_error(string(e.what()) + "\n" + "DD4hep: Error interpreting XML nodes of type <" + tag() + "/>"); } - throw runtime_error(std::string(e.what()) + "\n" + "DD4hep: Error interpreting collections XML nodes."); + throw runtime_error(string(e.what()) + "\n" + "DD4hep: Error interpreting collections XML nodes."); } void Collection_t::operator++() const { diff --git a/DDDB/CMakeLists.txt b/DDDB/CMakeLists.txt index 40b0914fc..9f5cf7477 100644 --- a/DDDB/CMakeLists.txt +++ b/DDDB/CMakeLists.txt @@ -19,7 +19,7 @@ dd4hep_package( DDDB USES DDCore DDCond - [BOOST REQUIRED COMPONENTS filesystem] + [BOOST REQUIRED] INCLUDE_DIRS include INSTALL_INCLUDES include/DDDB) -- GitLab