diff --git a/DDCore/include/DD4hep/Conditions.h b/DDCore/include/DD4hep/Conditions.h index 74d962fc5fb7327a0f67d90d97bfc38c34e885fc..8b40f75bd4d5322683ae03a95a4ee236ccaf85ee 100644 --- a/DDCore/include/DD4hep/Conditions.h +++ b/DDCore/include/DD4hep/Conditions.h @@ -210,6 +210,9 @@ namespace DD4hep { /// Constructor to be used when reading the already parsed object template <typename Q> Container(const Handle<Q>& e) : Handle<Object>(e) {} + /// Assignment operator + Container& operator=(const Container& c) = default; + /// Access the number of conditons keys available for this detector element size_t numKeys() const; @@ -278,7 +281,7 @@ namespace DD4hep { /// Automatic conversion to the string representation of the key object operator const std::string& () const { return name; } /// Automatic conversion to the hashed representation of the key object - operator key_type () const { return hash; } + operator key_type () const { return hash; } }; /// Hash code generation from input string diff --git a/DDCore/include/DD4hep/IOV.h b/DDCore/include/DD4hep/IOV.h index 7a91ec24ef952be304956095cbc23177a5b3b1bd..7acca979c145dec57cb37e2658f4094216b95786 100644 --- a/DDCore/include/DD4hep/IOV.h +++ b/DDCore/include/DD4hep/IOV.h @@ -33,11 +33,19 @@ namespace DD4hep { class IOVType { public: enum { UNKNOWN_IOV = ~0x0 } _IOVTypes; - + /// integer identifier ised internally unsigned int type; + /// String name std::string name; + /// Standard Constructor IOVType() : type(UNKNOWN_IOV), name() {} - ~IOVType() {} + /// Standard Destructor + ~IOVType() = default; + /// Copy constructor + IOVType(const IOVType& copy) : type(copy.type), name(copy.name) {} + /// Assignment operator + IOVType& operator=(const IOVType& copy); + /// Conversion to string std::string str() const; }; @@ -69,10 +77,9 @@ namespace DD4hep { /// Specialized copy constructor explicit IOV(const IOVType* typ, const Key& key); /// Copy constructor - IOV(const IOV& copy); - + IOV(const IOV& copy) = default; /// Standard Destructor - ~IOV(); + ~IOV() = default; /// Move the data content: 'from' will be reset to NULL void move(IOV& from); /// Create string representation of the IOV diff --git a/DDCore/include/DD4hep/LCDD.h b/DDCore/include/DD4hep/LCDD.h index 50cbeee8a7f5b5532b721e45f406ee9aa834471c..cd80feb2ae3f21644adc31c9dc7f73b4f48b0be2 100644 --- a/DDCore/include/DD4hep/LCDD.h +++ b/DDCore/include/DD4hep/LCDD.h @@ -98,8 +98,7 @@ namespace DD4hep { typedef std::map<std::string, PropertyValues> Properties; /// Destructor - virtual ~LCDD() { - } + virtual ~LCDD() = default; /// Access flag to steer the detail of building of the geometry/detector description virtual LCDDBuildType buildType() const = 0; diff --git a/DDCore/include/DD4hep/LCDDData.h b/DDCore/include/DD4hep/LCDDData.h index e5336e778d663b5be93af54576753d268d9bb8b6..2ec09ecd57ba0704ae3b15c705eafc9f9af0297b 100644 --- a/DDCore/include/DD4hep/LCDDData.h +++ b/DDCore/include/DD4hep/LCDDData.h @@ -128,6 +128,10 @@ namespace DD4hep { LCDDData(); /// Default destructor virtual ~LCDDData(); + /// Copy constructor + LCDDData(const LCDDData& copy) = delete; + /// Assignment operator + //LCDDData& operator=(const LCDDData& copy) = delete; public: /// Clear data content: releases all allocated resources void destroyData(bool destroy_mgr=true); diff --git a/DDCore/include/DD4hep/ObjectExtensions.h b/DDCore/include/DD4hep/ObjectExtensions.h index 4936b8d53c9c88496d9032830390e5a24d0a5860..25786beb99454e7cce5d007de2d98f1acb7931b7 100644 --- a/DDCore/include/DD4hep/ObjectExtensions.h +++ b/DDCore/include/DD4hep/ObjectExtensions.h @@ -60,8 +60,14 @@ namespace DD4hep { public: /// Default constructor ObjectExtensions(const std::type_info& parent_type); + /// Copy constructor + ObjectExtensions(const ObjectExtensions& copy) = delete; /// Default destructor virtual ~ObjectExtensions(); + /// Assignment operator + ObjectExtensions& operator=(const ObjectExtensions& copy) = delete; + /// Move extensions to target object + void move(ObjectExtensions& copy); /// Clear all extensions void clear(bool destroy=true); /// Copy object extensions from another object. Hosting type must be identical! diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h index 980341dd6591218dc748322440bf1219f874bb82..2d573a02280de4bb44cdea1629396c3948548d3d 100644 --- a/DDCore/include/DD4hep/OpaqueData.h +++ b/DDCore/include/DD4hep/OpaqueData.h @@ -39,11 +39,16 @@ namespace DD4hep { /// Standard initializing constructor OpaqueData(); /// Standard Destructor - virtual ~OpaqueData(); + virtual ~OpaqueData() = default; + /// Copy constructor + OpaqueData(const OpaqueData& copy) = default; + /// Assignment operator + OpaqueData& operator=(const OpaqueData& copy) = default; public: /// Data type const BasicGrammar* grammar; + protected: /// Pointer to object data void* pointer; diff --git a/DDCore/include/DD4hep/Primitives.h b/DDCore/include/DD4hep/Primitives.h index 169e2fe246105ddb3614683ce49c7d0d915196a9..0aa675043058841f7afdccbcb632a11a2a7d7d7c 100644 --- a/DDCore/include/DD4hep/Primitives.h +++ b/DDCore/include/DD4hep/Primitives.h @@ -68,8 +68,10 @@ namespace DD4hep { 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(); + virtual ~invalid_handle_exception() = default; }; /// ABI information about type names diff --git a/DDCore/src/Evaluator/stack.src b/DDCore/src/Evaluator/stack.src index 5a78318824eb70b3ec5a27986607e3d39532d95c..0da7e55315c100b70312bbe87dc020c40d003853 100644 --- a/DDCore/src/Evaluator/stack.src +++ b/DDCore/src/Evaluator/stack.src @@ -22,8 +22,8 @@ private: int k, max_size; T * v; - stack(const stack& c) : k(0), max_size(0), v(0) {} - stack& operator=(const stack&) { k=0; max_size=0; v=0; return *this; } + stack(const stack& c) = delete; + stack& operator=(const stack&) = delete; public: stack() : k(0), max_size(20), v(new T[20]) {} diff --git a/DDCore/src/IOV.cpp b/DDCore/src/IOV.cpp index ae14a00e0d0a4f29c93413d11c632a493d7cb4fe..39e801d9af249507120670bac33d9167edc29966 100644 --- a/DDCore/src/IOV.cpp +++ b/DDCore/src/IOV.cpp @@ -23,6 +23,16 @@ using namespace std; using namespace DD4hep; +/// Assignment operator +IOVType& IOVType::operator=(const IOVType& copy) { + if ( © != this ) { + name = copy.name; + type = copy.type; + } + return *this; +} + +/// Conversion to string std::string IOVType::str() const { char text[256]; ::snprintf(text,sizeof(text),"%s(%d)",name.c_str(),int(type)); @@ -39,12 +49,6 @@ IOV::IOV(const IOVType* t) : iovType(t), keyData(0,0), optData(0) { type = t ? t->type : int(IOVType::UNKNOWN_IOV); } -/// Copy constructor -IOV::IOV(const IOV& c) - : iovType(c.iovType), keyData(c.keyData), optData(c.optData), type(c.type) -{ -} - /// Copy constructor IOV::IOV(const IOVType* t, const Key& k) : iovType(t), keyData(k), optData(0) @@ -52,10 +56,6 @@ IOV::IOV(const IOVType* t, const Key& k) type = t ? t->type : int(IOVType::UNKNOWN_IOV); } -/// Standard Destructor -IOV::~IOV() { -} - /// Set discrete IOV value void IOV::set(const Key& value) { keyData = value; diff --git a/DDCore/src/LCDDData.cpp b/DDCore/src/LCDDData.cpp index d7f048e1ffb3eb2a675a3f002951541f7de18b50..d728282d3b0e2236bc95e86172997026fd9c9ad7 100644 --- a/DDCore/src/LCDDData.cpp +++ b/DDCore/src/LCDDData.cpp @@ -25,7 +25,6 @@ namespace DD4hep { namespace Geometry { class LCDDImp; }} using namespace DD4hep::Geometry; using namespace DD4hep; -using namespace std; /// Default constructor LCDDData::LCDDData() @@ -110,30 +109,28 @@ void LCDDData::clearData() { /// Adopt all data from source structure void LCDDData::adoptData(LCDDData& source) { m_inhibitConstants = source.m_inhibitConstants; - m_extensions = source.m_extensions; - m_motherVolumes = source.m_motherVolumes; - m_world = source.m_world; - m_field = source.m_field; - m_header = source.m_header; - m_properties = source.m_properties; - m_readouts = source.m_readouts; - m_idDict = source.m_idDict; - m_limits = source.m_limits; - m_regions = source.m_regions; - m_alignments = source.m_alignments; - m_sensitive = source.m_sensitive; - m_display = source.m_display; - m_fields = source.m_fields; - m_define = source.m_define; - m_trackers = source.m_trackers; - m_worldVol = source.m_worldVol; - m_trackingVol = source.m_trackingVol; - m_invisibleVis = source.m_invisibleVis; + m_extensions.move(source.m_extensions); + m_motherVolumes = source.m_motherVolumes; + m_world = source.m_world; + m_field = source.m_field; + m_header = source.m_header; + m_properties = source.m_properties; + m_readouts = source.m_readouts; + m_idDict = source.m_idDict; + m_limits = source.m_limits; + m_regions = source.m_regions; + m_alignments = source.m_alignments; + m_sensitive = source.m_sensitive; + m_display = source.m_display; + m_fields = source.m_fields; + m_define = source.m_define; + m_trackers = source.m_trackers; + m_worldVol = source.m_worldVol; + m_trackingVol = source.m_trackingVol; + m_invisibleVis = source.m_invisibleVis; m_materialVacuum = source.m_materialVacuum; - m_materialAir = source.m_materialAir; - m_manager = source.m_manager; - m_volManager = source.m_volManager; + m_materialAir = source.m_materialAir; + m_manager = source.m_manager; + m_volManager = source.m_volManager; source.clearData(); } - - diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index f412ed57931df3e88fd7f46634f962d3972bdf70..6b169b4de06ff0692e676af0cea172fb8057c5ab 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -84,21 +84,6 @@ namespace { } } -/// Disable copy constructor -LCDDImp::LCDDImp(const LCDDImp& copy) : LCDD(copy), LCDDData(copy), LCDDLoad(this), - m_detectorTypes(copy.m_detectorTypes), - m_buildType(copy.m_buildType) -{ -} - -/// Disable assignment operator -LCDDImp& LCDDImp::operator=(const LCDDImp& c) { - // Useless, but keep code checker happy.... - m_detectorTypes = c.m_detectorTypes; - m_buildType = c.m_buildType; - return *this; -} - LCDD& LCDD::getInstance() { if (!s_lcdd) s_lcdd = new LCDDImp(); diff --git a/DDCore/src/LCDDImp.h b/DDCore/src/LCDDImp.h index 025b85669062b03824980f4cb18c2fae78064698..ddd5cbb4cb2d71b6be8e0704844ef0263c0ddc11 100644 --- a/DDCore/src/LCDDImp.h +++ b/DDCore/src/LCDDImp.h @@ -50,10 +50,10 @@ namespace DD4hep { private: /// Disable copy constructor - LCDDImp(const LCDDImp& copy); + LCDDImp(const LCDDImp& copy) = delete; /// Disable assignment operator - LCDDImp& operator=(const LCDDImp& copy); + LCDDImp& operator=(const LCDDImp& copy) = delete; /// Internal helper to map detector types once the geometry is closed void mapDetectorTypes(); diff --git a/DDCore/src/ObjectExtensions.cpp b/DDCore/src/ObjectExtensions.cpp index c364b519e89d208b1eec0bdce88870c52b4b72ba..182d8cefcdbabf88ced5e9ab98748afd34c39397 100644 --- a/DDCore/src/ObjectExtensions.cpp +++ b/DDCore/src/ObjectExtensions.cpp @@ -42,6 +42,12 @@ ObjectExtensions::~ObjectExtensions() { InstanceCount::decrement(this); } +/// Move extensions to target object +void ObjectExtensions::move(ObjectExtensions& source) { + extensions = source.extensions; + source.extensions.clear(); +} + /// Internal object destructor: release extension object(s) void ObjectExtensions::clear(bool destroy) { for (Extensions::iterator i = extensions.begin(); i != extensions.end(); ++i) { diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp index 76dce8536168171098a37f1a768e6e2b26c7f137..94ccf8b656aaaeea2512a6902d8c5d3a71ab6ef6 100644 --- a/DDCore/src/OpaqueData.cpp +++ b/DDCore/src/OpaqueData.cpp @@ -29,10 +29,6 @@ using namespace DD4hep; OpaqueData::OpaqueData() : grammar(0), pointer(0) { } -/// Standard Destructor -OpaqueData::~OpaqueData() { -} - /// Create data block from string representation bool OpaqueData::fromString(const string& rep) { if ( pointer && grammar ) { diff --git a/DDCore/src/Primitives.cpp b/DDCore/src/Primitives.cpp index b50c256882ab34f82fe14fbf8165988cde5c42b2..e61ed5372121670fb12875c0f7be70539a80ff81 100644 --- a/DDCore/src/Primitives.cpp +++ b/DDCore/src/Primitives.cpp @@ -188,10 +188,6 @@ std::string DD4hep::typeName(const std::type_info& typ) { return __typeinfoName(typ); } -/// Default destructor of specialized exception -DD4hep::invalid_handle_exception::~invalid_handle_exception() { -} - void DD4hep::invalidHandleError(const std::type_info& type) { throw invalid_handle_exception("Attempt to access invalid object of type "+typeName(type)+" [Invalid Handle]"); diff --git a/DDCore/src/XML/DocumentHandler.cpp b/DDCore/src/XML/DocumentHandler.cpp index 901b7d308afcb178b5c5e12d098f4aad949b97c3..43d7edfe2da649002f3a18edced5b5b4d3ba1626 100644 --- a/DDCore/src/XML/DocumentHandler.cpp +++ b/DDCore/src/XML/DocumentHandler.cpp @@ -377,7 +377,7 @@ namespace DD4hep { namespace XML { /// XML-DOM ERror handler class for the TinyXML document parser (Compatibility class) - struct DocumentErrorHandler {}; + class DocumentErrorHandler {}; union Xml { Xml(void* ptr) : p(ptr) {} diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 242e7e959394c833d1cd35e1fc941fbe8addf046..2876c182bfc0ed44e3c829ff0622bcdb46c02c1e 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -10,7 +10,7 @@ # #========================================================================== dd4hep_package(UtilityApps - USES DDCore + USES DDSegmentation DDCore [ROOT REQUIRED COMPONENTS Geom] ) #----------------------------------------------------------------------------------- diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index ef3a98c8c5a8d82caebb16315f16dce5a5f02adb..52f4919adb3f958357697d00382f793969029cd5 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -39,6 +39,7 @@ macro(dd4hep_set_compiler_flags) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") endif()