From bb9b0221a71add49014d20789634e0780c95649d Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <fwinkl@cern> Date: Tue, 13 Apr 2021 17:14:03 +0200 Subject: [PATCH] CLID: remove package information Remove `PackageInfo` (package name and version) from the CLID database. This information was never correctly filled (ATEAM-731). --- .../AthContainers/AthContainers/ViewVector.h | 7 +- Control/AthenaKernel/AthenaKernel/CLASS_DEF.h | 19 +-- .../AthenaKernel/AthenaKernel/CLIDRegistry.h | 20 +-- .../AthenaKernel/ClassID_traits.h | 10 +- .../AthenaKernel/tools/AthenaPackageInfo.h | 51 +----- Control/AthenaKernel/CMakeLists.txt | 4 - Control/AthenaKernel/doc/packagedoc.h | 10 +- .../share/AthenaPackageInfo_test.ref | 29 ---- .../AthenaKernel/src/AthenaPackageInfo.cxx | 41 ----- Control/AthenaKernel/src/BaseInfo.cxx | 4 +- Control/AthenaKernel/src/CLIDRegistry.cxx | 11 +- .../test/AthenaPackageInfo_test.cxx | 51 ------ .../AthenaKernel/test/CLIDRegistry_test.cxx | 14 +- Control/CLIDComps/share/ClassIDSvc_test.ref | 8 +- Control/CLIDComps/src/ClassIDSvc.cxx | 149 ++++-------------- Control/CLIDComps/src/ClassIDSvc.h | 18 +-- Control/CLIDComps/test/ClassIDSvc_test.cxx | 5 +- 17 files changed, 79 insertions(+), 372 deletions(-) delete mode 100644 Control/AthenaKernel/share/AthenaPackageInfo_test.ref delete mode 100644 Control/AthenaKernel/src/AthenaPackageInfo.cxx delete mode 100644 Control/AthenaKernel/test/AthenaPackageInfo_test.cxx diff --git a/Control/AthContainers/AthContainers/ViewVector.h b/Control/AthContainers/AthContainers/ViewVector.h index 434acea28464..88485dfc3bf3 100644 --- a/Control/AthContainers/AthContainers/ViewVector.h +++ b/Control/AthContainers/AthContainers/ViewVector.h @@ -1,6 +1,6 @@ // This file's extension implies that it's C, but it's really -*- C++ -*-. /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /** * @file AthContainers/ViewVector.h @@ -19,7 +19,6 @@ #include "AthContainers/exceptions.h" #include "AthContainers/ViewVectorBase.h" #include "AthLinks/ElementLink.h" -#include "boost/preprocessor/stringize.hpp" #include <atomic> @@ -314,10 +313,6 @@ struct ClassID_traits< ViewVector<DV> > static const std::type_info& typeInfo() { return typeid (ViewVector<DV>); } - static Athena::PackageInfo packageInfo() { - static Athena::PackageInfo pi( BOOST_PP_STRINGIZE(PACKAGE_VERSION_UQ) ); - return pi; - } typedef std::false_type has_version_tag; static const bool s_isConst = false; diff --git a/Control/AthenaKernel/AthenaKernel/CLASS_DEF.h b/Control/AthenaKernel/AthenaKernel/CLASS_DEF.h index 44d9f898e3ed..332900a814fe 100755 --- a/Control/AthenaKernel/AthenaKernel/CLASS_DEF.h +++ b/Control/AthenaKernel/AthenaKernel/CLASS_DEF.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENAKERNEL_CLASS_DEF_H @@ -8,12 +8,10 @@ * @brief macros to associate a CLID to a type * * @author Paolo Calafiura <pcalafiura@lbl.gov> - * $Id: CLASS_DEF.h,v 1.3 2009-01-15 19:07:29 binet Exp $ */ #include "AthenaKernel/ClassID_traits.h" #include "CxxUtils/checker_macros.h" -#include <boost/preprocessor/stringize.hpp> #ifdef __CLING__ # define CLIDREGISTRY_ADDENTRY(CID, NAME) \ @@ -22,8 +20,7 @@ const bool clidEntry_ ## CID = \ CLIDRegistry::addEntry(CID, typeid(NAME), \ ClassID_traits< NAME >::typeNameString(), \ - ClassID_traits< NAME >::packageInfo(), \ - ClassName< NAME >::name()); \ + ClassName< NAME >::name()); \ } # define CLIDREGISTRY_ADDENTRY2(CID, ARG1, ARG2) \ namespace detail { \ @@ -32,7 +29,6 @@ CLIDRegistry::addEntry \ (CID, typeid(ARG1,ARG2), \ ClassID_traits< ARG1,ARG2 >::typeNameString(), \ - ClassID_traits< ARG1,ARG2 >::packageInfo(), \ ClassName< ARG1,ARG2 >::name()); \ } #else @@ -42,8 +38,7 @@ const bool clidEntry_ ## CID = \ CLIDRegistry::addEntry<CID>(typeid(NAME), \ ClassID_traits< NAME >::typeNameString(), \ - ClassID_traits< NAME >::packageInfo(), \ - ClassName< NAME >::name()); \ + ClassName< NAME >::name()); \ } # define CLIDREGISTRY_ADDENTRY2(CID, ARG1, ARG2) \ namespace detail { \ @@ -52,7 +47,6 @@ CLIDRegistry::addEntry<CID> \ (typeid(ARG1,ARG2), \ ClassID_traits< ARG1,ARG2 >::typeNameString(), \ - ClassID_traits< ARG1,ARG2 >::packageInfo(), \ ClassName< ARG1,ARG2 >::name()); \ } #endif @@ -82,10 +76,6 @@ static const std::string name = typeNameString(); \ return name; \ } \ - static Athena::PackageInfo packageInfo() { \ - static const Athena::PackageInfo pi( BOOST_PP_STRINGIZE(PACKAGE_VERSION_UQ) ); \ - return pi; \ - } \ static const std::type_info& typeInfo() { \ return typeid (NAME); \ } \ @@ -127,9 +117,6 @@ static const std::type_info& typeInfo() { \ return typeid (ARG1,ARG2); \ } \ - static Athena::PackageInfo packageInfo() { \ - return Athena::PackageInfo("Package-00-00-00"); \ - } \ typedef std::true_type has_version_tag; \ static const int s_version = VERSION; \ static const bool s_isConst = false; \ diff --git a/Control/AthenaKernel/AthenaKernel/CLIDRegistry.h b/Control/AthenaKernel/AthenaKernel/CLIDRegistry.h index 98e712c29573..f16227d1d05a 100755 --- a/Control/AthenaKernel/AthenaKernel/CLIDRegistry.h +++ b/Control/AthenaKernel/AthenaKernel/CLIDRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration. + * Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration. */ #ifndef ATHENAKERNEL_CLIDREGISTRY_H @@ -9,10 +9,8 @@ * Use ClassIDSvc instead. * * @author Paolo Calafiura <pcalafiura@lbl.gov> - ATLAS Collaboration - *$Id: CLIDRegistry.h,v 1.2 2009-01-15 19:07:29 binet Exp $ */ -#include "AthenaKernel/tools/AthenaPackageInfo.h" #include "GaudiKernel/ClassID.h" #include <vector> @@ -37,16 +35,14 @@ class CLIDRegistry { public: typedef std::tuple <unsigned long, std::string, - Athena::PackageInfo, - std::string> tuple_t; + std::string> tuple_t; typedef std::vector< tuple_t > CLIDVector_t; ///to be called by the CLASS_DEFS template <unsigned long CLID> static bool addEntry(const std::type_info& ti, - const char* typeName, - const Athena::PackageInfo& pkgInfo, - const std::string& typeInfoName); + const char* typeName, + const std::string& typeInfoName); /// registry accessors (used by ClassIDSvc) //@{ @@ -65,8 +61,7 @@ public: /// Out-of-line part of addEntry(). static bool addEntry (unsigned long clid, const std::type_info& ti, - const char* typeName, - const Athena::PackageInfo& pkgInfo, + const char* typeName, const std::string& typeInfoName); private: @@ -77,12 +72,11 @@ private: template <unsigned long CLID> bool CLIDRegistry::addEntry(const std::type_info& ti, const char* typeName, - const Athena::PackageInfo& pkgInfo, - const std::string& typeInfoName) { + const std::string& typeInfoName) { static_assert (CLIDdetail::MINCLID <= CLID && CLID <= CLIDdetail::MAXCLID, "CLID out of CLIDRegistry range"); - addEntry (CLID, ti, typeName, pkgInfo, typeInfoName); + addEntry (CLID, ti, typeName, typeInfoName); return true; } diff --git a/Control/AthenaKernel/AthenaKernel/ClassID_traits.h b/Control/AthenaKernel/AthenaKernel/ClassID_traits.h index 3fc05144e17b..64f2a63e43a2 100755 --- a/Control/AthenaKernel/AthenaKernel/ClassID_traits.h +++ b/Control/AthenaKernel/AthenaKernel/ClassID_traits.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENAKERNEL_CLASSID_TRAITS_H @@ -9,7 +9,6 @@ * It also detects whether T inherits from Gaudi DataObject * * @author Paolo Calafiura <pcalafiura@lbl.gov> - ATLAS Collaboration - * $Id: ClassID_traits.h,v 1.3 2009-01-15 19:07:29 binet Exp $ */ #include <string> #include <typeinfo> @@ -23,7 +22,6 @@ #include "AthenaKernel/CLIDRegistry.h" #include "AthenaKernel/ClassName.h" -#include "AthenaKernel/tools/AthenaPackageInfo.h" #include <type_traits> @@ -68,12 +66,6 @@ struct ClassID_traits { return typeid(T); } - ///the package name of this CLASSDEF (and BY CONVENTION of the data obj too!) - static Athena::PackageInfo packageInfo() { - MY_STATIC_ASSERT(s_isDataObject); - return Athena::PackageInfo("Package-00-00-00"); - } - typedef std::false_type has_version_tag; typedef std::false_type has_classID_tag; static const int s_version = 0; diff --git a/Control/AthenaKernel/AthenaKernel/tools/AthenaPackageInfo.h b/Control/AthenaKernel/AthenaKernel/tools/AthenaPackageInfo.h index ee504e9005e5..a658124a5f19 100644 --- a/Control/AthenaKernel/AthenaKernel/tools/AthenaPackageInfo.h +++ b/Control/AthenaKernel/AthenaKernel/tools/AthenaPackageInfo.h @@ -1,66 +1,27 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENAKERNEL_TOOLS_ATHENA_PACKAGEINFO_H #define ATHENAKERNEL_TOOLS_ATHENA_PACKAGEINFO_H 1 -#include <iostream> #include <string> -class MsgStream; namespace Athena { /** * @class PackageInfo * @author Paolo Calafiura - * @brief decodes cmt PACKAGE_VERSION macro + * @brief decodes cmt PACKAGE_VERSION macro (deprecated) * - * FIXME class works fine technically, but it does not satisfy - * the use case it was designed for, namely to add package information - * to the ClassID_traits definition in AthenaKernel/CLASS_DEF.h - * - * $Id: AthenaPackageInfo.h,v 1.4 2007-12-14 01:58:50 binet Exp $ + * As of April 2021 this is a dummy class as the package information is no + * longer stored in the CLID database (ATEAM-731). It can be deleted once + * the IClassIDSvc interface has been cleaned up. */ - class PackageInfo { - private: - std::string m_name; - std::string m_version; public: - /** - * @brief construct PackageInfo from cmt-generated PACKAGE_VERSION #define - * @param a string of the form PACKAGE-XX-YY-NN - * @throws invalid_argument - */ - PackageInfo(const std::string& cmtPackageVersion); - PackageInfo() : m_name(), m_version() {} - const std::string& name() const { return m_name; } - const std::string& version() const { return m_version; } + PackageInfo(const std::string&) {} }; } -MsgStream& -operator << (MsgStream& ost, const Athena::PackageInfo& info); - -std::ostream& -operator << (std::ostream& ost, const Athena::PackageInfo& info); - -inline -bool -operator == (const Athena::PackageInfo& lhs, const Athena::PackageInfo& rhs) { - return ( (lhs.name() == rhs.name()) && (lhs.version() == rhs.version()) ); -} -inline -bool -operator != (const Athena::PackageInfo& lhs, const Athena::PackageInfo& rhs) { - return !(lhs == rhs); -} -inline -bool -operator < (const Athena::PackageInfo& lhs, const Athena::PackageInfo& rhs) { - return ( (lhs.name() < rhs.name()) || - ( (lhs.name() == rhs.name()) && (lhs.version() < rhs.version()) ) ); -} - #endif diff --git a/Control/AthenaKernel/CMakeLists.txt b/Control/AthenaKernel/CMakeLists.txt index bccf35daa237..eff5dc25bca0 100644 --- a/Control/AthenaKernel/CMakeLists.txt +++ b/Control/AthenaKernel/CMakeLists.txt @@ -43,10 +43,6 @@ atlas_add_test( MsgStreamMember_test LOG_IGNORE_PATTERN "^Wall clock time |ref count" LINK_LIBRARIES TestTools AthenaKernel ) -atlas_add_test( AthenaPackageInfo_test - SOURCES test/AthenaPackageInfo_test.cxx - LINK_LIBRARIES AthenaKernel ) - atlas_add_test( DirSearchPath_test SOURCES test/DirSearchPath_test.cxx INCLUDE_DIRS ${Boost_INCLUDE_DIRS} diff --git a/Control/AthenaKernel/doc/packagedoc.h b/Control/AthenaKernel/doc/packagedoc.h index 6f7503051347..5e0b39dcec71 100644 --- a/Control/AthenaKernel/doc/packagedoc.h +++ b/Control/AthenaKernel/doc/packagedoc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /** @@ -10,14 +10,6 @@ service base classes and simple utilities which do not depend on other packages. It can be seen as an extension of GaudiKernel. -@section AthenaKernel_Tests Unit Tests - - AthenaPackageInfo_test.cxx - - errorcheck_test.cxx - - getMessageSvc_test.cxx - - type_tools_test.cxx - - - @section AthenaKernel_Refs More Documentation More information is available from the Athena wiki diff --git a/Control/AthenaKernel/share/AthenaPackageInfo_test.ref b/Control/AthenaKernel/share/AthenaPackageInfo_test.ref deleted file mode 100644 index b47a79c9cb62..000000000000 --- a/Control/AthenaKernel/share/AthenaPackageInfo_test.ref +++ /dev/null @@ -1,29 +0,0 @@ -*** AthenaPackageInfo_test OK *** -Now we expect to see an error message: -----Error Message Starts--->> -PackageInfo::PackageInfo(BaD): invalid argument -PackageInfo should be constructed passing a string of the form PACKAGE-VERSION. -Usually this error occurs because CMT can not determine the version of your package. Please make sure that there is a version.cmt file in the cmt directory of your package and that version.cmt contains a single line of the form -MyPackage-01-02-03 -Notice that version.cmt is created automatically by CMT when you use 'cmt co' - -<<----Error Message Ends----- -Now we expect to see an error message: -----Error Message Starts--->> -PackageInfo::PackageInfo(BaD-): invalid argument -PackageInfo should be constructed passing a string of the form PACKAGE-VERSION. -Usually this error occurs because CMT can not determine the version of your package. Please make sure that there is a version.cmt file in the cmt directory of your package and that version.cmt contains a single line of the form -MyPackage-01-02-03 -Notice that version.cmt is created automatically by CMT when you use 'cmt co' - -<<----Error Message Ends----- -Now we expect to see an error message: -----Error Message Starts--->> -PackageInfo::PackageInfo(-BaD): invalid argument -PackageInfo should be constructed passing a string of the form PACKAGE-VERSION. -Usually this error occurs because CMT can not determine the version of your package. Please make sure that there is a version.cmt file in the cmt directory of your package and that version.cmt contains a single line of the form -MyPackage-01-02-03 -Notice that version.cmt is created automatically by CMT when you use 'cmt co' - -<<----Error Message Ends----- -*** AthenaPackageInfo_test OK *** diff --git a/Control/AthenaKernel/src/AthenaPackageInfo.cxx b/Control/AthenaKernel/src/AthenaPackageInfo.cxx deleted file mode 100644 index 97e7c63d66ef..000000000000 --- a/Control/AthenaKernel/src/AthenaPackageInfo.cxx +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include <iostream> -#include <stdexcept> - -#include "GaudiKernel/MsgStream.h" - -#include "AthenaKernel/tools/AthenaPackageInfo.h" -using Athena::PackageInfo; - -using namespace std; - -PackageInfo::PackageInfo(const string& cmtPackageVersion) { - string::size_type i(cmtPackageVersion.find('-')); - m_name = cmtPackageVersion.substr(0, i); - m_version = cmtPackageVersion.substr(i+1); - if (i==0 || i==string::npos || m_version.empty()) { - cerr << "PackageInfo::PackageInfo(" - << cmtPackageVersion <<"): invalid argument" << endl - << "PackageInfo should be constructed passing a string of the form " - << "PACKAGE-VERSION." << endl - << "Usually this error occurs because CMT can not determine the version " - << "of your package. Please make sure that there is a version.cmt file " - << "in the cmt directory of your package and that version.cmt contains " - << "a single line of the form" << endl << "MyPackage-01-02-03" << endl - << "Notice that version.cmt is created automatically by CMT when you use 'cmt co' " << endl - << endl; - throw invalid_argument("PackageInfo::PackageInfo"); - } -} - -MsgStream& -operator << (MsgStream& ost, const Athena::PackageInfo& info) { - return (ost << info.name() << '-' << info.version()); -} -std::ostream& -operator << (std::ostream& ost, const Athena::PackageInfo& info) { - return (ost << info.name() << '-' << info.version()); -} diff --git a/Control/AthenaKernel/src/BaseInfo.cxx b/Control/AthenaKernel/src/BaseInfo.cxx index ea3e1ca6b7da..38fe1f7b703c 100755 --- a/Control/AthenaKernel/src/BaseInfo.cxx +++ b/Control/AthenaKernel/src/BaseInfo.cxx @@ -1,8 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ -// $Id: BaseInfo.cxx,v 1.9 2008-11-25 21:45:04 ssnyder Exp $ /** * @file AthenaKernel/src/BaseInfo.cxx * @author scott snyder @@ -19,6 +18,7 @@ #include <map> #include <unordered_map> #include <algorithm> +#include <iostream> #include "string.h" diff --git a/Control/AthenaKernel/src/CLIDRegistry.cxx b/Control/AthenaKernel/src/CLIDRegistry.cxx index 867bbf3d9d06..2b73770e382b 100755 --- a/Control/AthenaKernel/src/CLIDRegistry.cxx +++ b/Control/AthenaKernel/src/CLIDRegistry.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration. + * Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration. */ #include "AthenaKernel/CLIDRegistry.h" @@ -20,8 +20,7 @@ public: bool addEntry (unsigned long clid, const std::type_info& ti, - const char* typeName, - const Athena::PackageInfo& pkgInfo, + const char* typeName, const std::string& typeInfoName); @@ -95,11 +94,10 @@ CLID CLIDRegistryImpl::typeinfoToCLID (const std::type_info& ti) const bool CLIDRegistryImpl::addEntry (unsigned long clid, const std::type_info& ti, const char* typeName, - const Athena::PackageInfo& pkgInfo, const std::string& typeInfoName) { lock_t lock (m_mutex); - m_vec.emplace_back (clid, std::string(typeName), pkgInfo, typeInfoName); + m_vec.emplace_back (clid, std::string(typeName), typeInfoName); m_clid_ti_map[clid] = &ti; m_ti_clid_map[&ti] = clid; return true; @@ -157,9 +155,8 @@ CLID CLIDRegistry::typeinfoToCLID (const std::type_info& ti) bool CLIDRegistry::addEntry (unsigned long clid, const std::type_info& ti, const char* typeName, - const Athena::PackageInfo& pkgInfo, const std::string& typeInfoName) { - return impl().addEntry (clid, ti, typeName, pkgInfo, typeInfoName); + return impl().addEntry (clid, ti, typeName, typeInfoName); } diff --git a/Control/AthenaKernel/test/AthenaPackageInfo_test.cxx b/Control/AthenaKernel/test/AthenaPackageInfo_test.cxx deleted file mode 100644 index d9683b5db36b..000000000000 --- a/Control/AthenaKernel/test/AthenaPackageInfo_test.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** - * @file AthenaPackageInfo_test.cxx - * @author Paolo Calafiura - * @brief Regression tests for PackageInfo (if only it worked...) - * - * verify that constructor parses correctly PACKAGE_VERSION macro strings - * of the format PACKAGE-xx-yy-zz - * - * $Id: AthenaPackageInfo_test.cxx,v 1.5 2008-07-25 23:37:34 calaf Exp $ - */ -#undef NDEBUG -#include <cassert> -#include <iostream> -#include "AthenaKernel/tools/AthenaPackageInfo.h" -using namespace std; -using Athena::PackageInfo; -int main() { - cout << "*** AthenaPackageInfo_test OK ***" << endl; - PackageInfo info(PACKAGE_VERSION); - assert( info.name() == "AthenaKernel" ); - assert( (info.version().size() == 7 && info.version()[0] == 'r') || //r123456 - info.version().size() == 8 || //00-00-00 - info.version().size() == 11 ); //00-00-00-00 - cerr << "Now we expect to see an error message:\n" - << "----Error Message Starts--->>" << endl; - try { - PackageInfo bad("BaD"); - assert(!"BaD should never get here"); - } catch (...) {} - cerr << "<<----Error Message Ends-----" << endl; - cerr << "Now we expect to see an error message:\n" - << "----Error Message Starts--->>" << endl; - try { - PackageInfo bad("BaD-"); - assert(!"BaD- should never get here"); - } catch (...) {} - cerr << "<<----Error Message Ends-----" << endl; - cerr << "Now we expect to see an error message:\n" - << "----Error Message Starts--->>" << endl; - try { - PackageInfo bad("-BaD"); - assert(!"-BaD should never get here"); - } catch (...) {} - cerr << "<<----Error Message Ends-----" << endl; - cout << "*** AthenaPackageInfo_test OK ***" << endl; - return 0; -} diff --git a/Control/AthenaKernel/test/CLIDRegistry_test.cxx b/Control/AthenaKernel/test/CLIDRegistry_test.cxx index e2707cdb2941..0e5c2aaf2011 100755 --- a/Control/AthenaKernel/test/CLIDRegistry_test.cxx +++ b/Control/AthenaKernel/test/CLIDRegistry_test.cxx @@ -1,11 +1,10 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /** @file CLIDRegistry_test.cxx * @brief unit test for CLIDRegistry * - * $Id: CLIDRegistry_test.cxx,v 1.2 2009-01-19 17:02:55 binet Exp $ * @author Paolo Calafiura <pcalafiura@lbl.gov> - ATLAS Collaboration */ @@ -20,7 +19,6 @@ #include <iostream> #include <typeinfo> -#include "AthenaKernel/tools/AthenaPackageInfo.h" using std::get; class Foo {}; @@ -31,26 +29,24 @@ int main () { std::cerr << "*** CLIDRegistry_test starts ***" <<std::endl; //reset newEntries before we start counting CLIDRegistry::CLIDVector_t er = CLIDRegistry::newEntries(); - Athena::PackageInfo info(PACKAGE_VERSION); #ifdef COMPILEFAIL - CLIDRegistry::addEntry<12>(typeid(Foo), "Foo", info, "Foo"); + CLIDRegistry::addEntry<12>(typeid(Foo), "Foo", "Foo"); //no upper limit CLIDRegistry::addEntry<1245736740>("Foo", info); #endif - CLIDRegistry::addEntry<1234>(typeid(Foo), "Foo", info, "Foo"); - CLIDRegistry::addEntry<4321>(typeid(Bar), "Bar", info, "Bar"); + CLIDRegistry::addEntry<1234>(typeid(Foo), "Foo", "Foo"); + CLIDRegistry::addEntry<4321>(typeid(Bar), "Bar", "Bar"); assert(CLIDRegistry::hasNewEntries()); er = CLIDRegistry::newEntries(); assert( er.size() == 2 ); assert( get<0>(er[0]) == 1234 ); assert( get<1>(er[0]) == "Foo" ); - assert( get<2>(er[0]).name() == "AthenaKernel" ); assert (CLIDRegistry::CLIDToTypeinfo (4321) == &typeid(Bar)); assert (CLIDRegistry::CLIDToTypeinfo (43213) == 0); assert (CLIDRegistry::typeinfoToCLID (typeid(Bar)) == 4321); assert (CLIDRegistry::typeinfoToCLID (typeid(Baz)) == 0); - CLIDRegistry::addEntry<43213>(typeid(Baz), "Baz", info, "Baz"); + CLIDRegistry::addEntry<43213>(typeid(Baz), "Baz", "Baz"); assert (CLIDRegistry::CLIDToTypeinfo (43213) == &typeid(Baz)); assert (CLIDRegistry::typeinfoToCLID (typeid(Baz)) == 43213); diff --git a/Control/CLIDComps/share/ClassIDSvc_test.ref b/Control/CLIDComps/share/ClassIDSvc_test.ref index 562f85b4e7ab..6e19a8526241 100644 --- a/Control/CLIDComps/share/ClassIDSvc_test.ref +++ b/Control/CLIDComps/share/ClassIDSvc_test.ref @@ -33,19 +33,19 @@ ClassIDSvc FATAL setTypeNameForID: input id 4294967294 is out of allowe <<---Error Message Ends------- Now we expect to see an error message: ----Error Message Starts--->> -ClassIDSvc ERROR uncheckedSetTypePackageForID: CLIDComps-00-06-12 can not set type name <Ble> for CLID 7890: Known name for this ID <Bla> It was set by APack-00-39-98 +ClassIDSvc FATAL uncheckedSetTypePackageForID: can not set type name <Ble> for CLID 7890: Known name for this ID <Bla> <<---Error Message Ends------- Now we expect to see an error message: ----Error Message Starts--->> -ClassIDSvc ERROR uncheckedSetTypePackageForID: CLIDComps-00-06-12 can not set CLID <9945> for type name Bli: Known CLID for this name <9942> It was set by CLIDComps-00-06-12 +ClassIDSvc FATAL uncheckedSetTypePackageForID: can not set CLID <9945> for type name Bli: Known CLID for this name <9942> <<---Error Message Ends------- Now we expect to see an error message: ----Error Message Starts--->> -ClassIDSvc ERROR uncheckedSetTypePackageForID: APack-00-39-98 can not set type name <Bl a> for CLID 7890: Known name for this ID <Bla> It was set by APack-00-39-98 +ClassIDSvc FATAL uncheckedSetTypePackageForID: can not set type name <Bl a> for CLID 7890: Known name for this ID <Bla> <<---Error Message Ends------- Now we expect to see an error message: ----Error Message Starts--->> -ClassIDSvc ERROR uncheckedSetTypePackageForID: APack-00-39-98 can not set type name <B l a> for CLID 7890: Known name for this ID <Bla> It was set by APack-00-39-98 +ClassIDSvc FATAL uncheckedSetTypePackageForID: can not set type name <B l a> for CLID 7890: Known name for this ID <Bla> <<---Error Message Ends------- ClassIDSvc INFO finalize: wrote 1233 entries to output CLIDDB file: CLIDTestOut.db *** ClassIDSvc basic test OK *** diff --git a/Control/CLIDComps/src/ClassIDSvc.cxx b/Control/CLIDComps/src/ClassIDSvc.cxx index e518f4b31eb3..e74b010f668c 100644 --- a/Control/CLIDComps/src/ClassIDSvc.cxx +++ b/Control/CLIDComps/src/ClassIDSvc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <algorithm> /* distance */ @@ -165,22 +165,13 @@ ClassIDSvc::getIDOfTypeInfoName(const std::string& typeInfoName, return sc; } -/// get PackageInfo associated with clID (if any) -StatusCode -ClassIDSvc::getPackageInfoForID(const CLID& id, Athena::PackageInfo& info) const -{ - lock_t lock (m_mutex); - maybeRescan(); - return getPackageInfoForIDInternal (id, info); -} - /// associate type name with clID StatusCode ClassIDSvc::setTypePackageForID(const CLID& id, - const std::string& typeName, - const Athena::PackageInfo& info, - const std::string& typeInfoName) + const std::string& typeName, + const Athena::PackageInfo&, + const std::string& typeInfoName) { lock_t lock (m_mutex); if (id < CLIDdetail::MINCLID || id > CLIDdetail::MAXCLID) { @@ -189,7 +180,7 @@ ClassIDSvc::setTypePackageForID(const CLID& id, << " : " << CLIDdetail::MAXCLID ); return StatusCode::FAILURE; } - return uncheckedSetTypePackageForID(id, typeName, info, typeInfoName); + return uncheckedSetTypePackageForID(id, typeName, typeInfoName); } @@ -201,13 +192,7 @@ ClassIDSvc::dump() const for (CLID clid : sortedIDs()) { const std::string& typeName = m_clidMap.find (clid)->second.first; - info() << "CLID: "<< clid - << " - type name: " << typeName; - Athena::PackageInfo pinfo; - if (getPackageInfoForIDInternal (clid, pinfo).isSuccess()) { - info() << "- Package "<< pinfo; - } - info() << '\n'; + info() << "CLID: "<< clid << " - type name: " << typeName << '\n'; } info() << "------------------------------" << endmsg; } @@ -254,18 +239,12 @@ ClassIDSvc::finalize() // ostream_iterator< pair<CLID, string> > os(outfile, ':'); // copy(m_clidMap.begin(), m_clidMap,end(), os); for (CLID clid : sortedIDs()) { - const std::string& typeName = m_clidMap[clid].first; - const std::string& tiName = m_clidMap[clid].second; - outfile << clid << "; " << typeName; - Athena::PackageInfo info; - if (getPackageInfoForIDInternal (clid, info).isSuccess()) { - outfile << "; " << info; - outfile << "; " << tiName; - } - outfile << endl; + const std::string& typeName = m_clidMap[clid].first; + const std::string& tiName = m_clidMap[clid].second; + outfile << clid << "; " << typeName << "; " << tiName << std::endl; } ATH_MSG_INFO( "finalize: wrote " << m_clidMap.size() << - " entries to output CLIDDB file: " << m_outputFileName ); + " entries to output CLIDDB file: " << m_outputFileName ); } outfile.close(); } //outputfilename != NULL @@ -324,28 +303,6 @@ std::vector<CLID> ClassIDSvc::sortedIDs() const } -/// get PackageInfo associated with clID (if any) -StatusCode -ClassIDSvc::getPackageInfoForIDInternal(const CLID& id, - Athena::PackageInfo& info) const -{ - StatusCode sc(StatusCode::FAILURE); - PackageMap::const_iterator iID = m_packageMap.find(id); - if (iID != m_packageMap.end()) { - info = iID->second; - ATH_CONST_MSG_VERBOSE("getPackageInfoForID(" << id << - ") package name is " << info.name() << - " package version is " << info.version()); - sc = StatusCode::SUCCESS; - } - else { - ATH_CONST_MSG_VERBOSE( "getPackageInfoForID(" << id << - ") no associated type name found "); - } - return sc; -} - - /// get id associated with type name (if any) StatusCode ClassIDSvc::getIDOfTypeNameInternal(const std::string& typeName, CLID& id) const @@ -460,18 +417,8 @@ ClassIDSvc::processCLIDDB(const char* fileName) massage(typeName); // cout << "typeName " << typeName << endl; - - string sinfo; - if (columns>=3) { - sinfo=*iToken++; - massage(sinfo); - } else { sinfo = "UNKNOWN-00-00-00"; } - Athena::PackageInfo info(sinfo); - - // cout << "info " << info << endl; - string typeInfoName; - if (columns>=4) { + if (columns>=3) { massage(typeInfoName = *iToken++); } else { typeInfoName = typeName; } @@ -480,7 +427,6 @@ ClassIDSvc::processCLIDDB(const char* fileName) if ((allOK = !typeName.empty())) { if (uncheckedSetTypePackageForID(id, typeName, - info, typeInfoName).isSuccess()) { ATH_MSG_VERBOSE( "processCLIDDB(" << fileName << ")\n added entry for CLID <" << id << @@ -516,17 +462,14 @@ bool ClassIDSvc::getRegistryEntries(const std::string& moduleName) for (const CLIDRegistry::tuple_t& ent : CLIDRegistry::newEntries()) { const CLID& clid = std::get<0>(ent); const std::string& typeName = std::get<1>(ent); - const Athena::PackageInfo& pkgInfo = std::get<2>(ent); - const std::string& typeInfoName = std::get<3>(ent); + const std::string& typeInfoName = std::get<2>(ent); ATH_MSG_VERBOSE( "reading [" << clid << ", " << typeName << ", " - << pkgInfo << ", " << typeInfoName << "]"); if (uncheckedSetTypePackageForID (clid, typeName, - pkgInfo, typeInfoName).isSuccess()) { ++nE; @@ -550,71 +493,47 @@ bool ClassIDSvc::getRegistryEntries(const std::string& moduleName) StatusCode ClassIDSvc::uncheckedSetTypePackageForID(const CLID& id, - const std::string& typeName, - const Athena::PackageInfo& info, - const std::string& typeInfoName) + const std::string& typeName, + const std::string& typeInfoName) { - StatusCode sc(StatusCode::SUCCESS); //process "raw" typeName string procName(typeName); massage(procName); + //first the id->name map string knownName("_____++++"); if (getTypeNameOfIDInternal(id, knownName).isSuccess() && procName != knownName) { - fatal() << "uncheckedSetTypePackageForID: " << info << - " can not set type name <" << procName << "> for CLID " << - id << ": Known name for this ID <" << knownName << '>'; - Athena::PackageInfo existInfo; - if (getPackageInfoForIDInternal(id, existInfo).isSuccess()) { - fatal() << " It was set by " << existInfo; - } - fatal() << endmsg; - sc = StatusCode::FAILURE; + ATH_MSG_FATAL("uncheckedSetTypePackageForID: can not set type name <" + << procName << "> for CLID " + << id << ": Known name for this ID <" << knownName << '>'); + return StatusCode::FAILURE; } else if (procName == knownName) { - if (msgLevel(MSG::VERBOSE)) { - ATH_MSG_VERBOSE("uncheckedSetTypePackageForID: type name <" << procName << - "> already set for CLID " << id); - Athena::PackageInfo existInfo; - if (getPackageInfoForIDInternal(id, existInfo).isSuccess()) { - ATH_MSG_VERBOSE( " It was set by " << existInfo ); - } - } - } - if (!sc.isSuccess()) return StatusCode::FAILURE; + ATH_MSG_VERBOSE("uncheckedSetTypePackageForID: type name <" << procName << + "> already set for CLID " << id); + } //now the name->id map CLID knownID(0); if (getIDOfTypeNameInternal(procName, knownID).isSuccess() && id != knownID) { - error() << "uncheckedSetTypePackageForID: " << info << - " can not set CLID <" << id << "> for type name " << - procName << ": Known CLID for this name <" << knownID << '>' ; - Athena::PackageInfo existInfo; - if (getPackageInfoForIDInternal(knownID, existInfo).isSuccess()) { - error() << " It was set by " << existInfo; - } - error() << endmsg; - sc = StatusCode::FAILURE; + ATH_MSG_FATAL("uncheckedSetTypePackageForID: can not set CLID <" + << id << "> for type name " + << procName << ": Known CLID for this name <" << knownID << '>'); + return StatusCode::FAILURE; } else if (id == knownID) { - if (msgLevel(MSG::VERBOSE)) { - ATH_MSG_VERBOSE( "uncheckedSetTypePackageForID: CLID <" << id << - "> already set for type name " << procName ); - Athena::PackageInfo existInfo; - if (getPackageInfoForIDInternal(id, existInfo).isSuccess()) { - ATH_MSG_VERBOSE( " It was set by " << existInfo); - } - } - } - const std::string procTiName = typeInfoName.empty() - ? procName - : typeInfoName; + ATH_MSG_VERBOSE("uncheckedSetTypePackageForID: CLID <" << id << + "> already set for type name " << procName); + } + const std::string procTiName = typeInfoName.empty() ? procName : typeInfoName; m_clidMap[id] = std::make_pair(procName, procTiName); m_nameMap[procName] = id; + // FIXME: should we also check for ti-name<=>clid duplicates ? m_tiNameMap[procTiName] = id; - m_packageMap[id] = info; + ATH_MSG_VERBOSE("uncheckedSetTypePackageForID: set type name <" << procName << "> for CLID " << id); - return sc; + + return StatusCode::SUCCESS; } diff --git a/Control/CLIDComps/src/ClassIDSvc.h b/Control/CLIDComps/src/ClassIDSvc.h index 507b56f8c935..7ffad280c432 100644 --- a/Control/CLIDComps/src/ClassIDSvc.h +++ b/Control/CLIDComps/src/ClassIDSvc.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef CLIDCOMPS_CLASSIDSVC_H @@ -46,7 +46,6 @@ private: typedef std::pair<std::string, std::string> TypeName; //typename+typeinfoname typedef std::unordered_map<CLID, TypeName> CLIDMap; typedef std::unordered_map<std::string, CLID> NameMap; - typedef std::unordered_map<CLID, Athena::PackageInfo> PackageMap; public: // Locking convention: public methods (except for gaudi state-change methods) @@ -72,11 +71,14 @@ public: /// get id associated with type-info name (if any) virtual StatusCode getIDOfTypeInfoName(const std::string& typeInfoName, CLID& id) const override; /// get type name associated with clID (if any) - virtual StatusCode getPackageInfoForID(const CLID& id, Athena::PackageInfo& info) const override; + virtual StatusCode getPackageInfoForID(const CLID&, Athena::PackageInfo&) const override { + throw std::runtime_error("getPackageInfoForID is no longer supported"); + return StatusCode::FAILURE; + } /// associate type name, package info and type-info name with clID virtual StatusCode setTypePackageForID(const CLID& id, const std::string& typeName, - const Athena::PackageInfo& info, + const Athena::PackageInfo&, const std::string& typeInfoName) override; //======================================================================== @@ -112,8 +114,6 @@ private: // Return all registered IDs in sorted order. std::vector<CLID> sortedIDs() const; - StatusCode - getPackageInfoForIDInternal(const CLID& id, Athena::PackageInfo& info) const; /// get id associated with type name (if any) StatusCode getIDOfTypeNameInternal(const std::string& typeName, CLID& id) const; @@ -131,9 +131,8 @@ private: /// associate type name with clID w/o checking CLID range StatusCode uncheckedSetTypePackageForID(const CLID& id, - const std::string& typeName, - const Athena::PackageInfo& info, - const std::string& typeInfoName); + const std::string& typeName, + const std::string& typeInfoName); /// Test to see if anything new has been added to the registry. void maybeRescan() const; @@ -149,7 +148,6 @@ private: CLIDMap m_clidMap; NameMap m_nameMap; NameMap m_tiNameMap; - PackageMap m_packageMap; /// The path is which clid db files are to be searched (DATAPATH) DirSearchPath m_clidDBPath; diff --git a/Control/CLIDComps/test/ClassIDSvc_test.cxx b/Control/CLIDComps/test/ClassIDSvc_test.cxx index 21e4a8729189..5ec3517354d1 100644 --- a/Control/CLIDComps/test/ClassIDSvc_test.cxx +++ b/Control/CLIDComps/test/ClassIDSvc_test.cxx @@ -1,11 +1,10 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /** @file ClassIDSvc_test.cxx * @brief unit test for ClassIDSvc * @author ATLAS Collaboration - * $Id: ClassIDSvc_test.cxx,v 1.5 2009-01-19 17:02:55 binet Exp $ ***************************************************************************/ #undef NDEBUG @@ -23,6 +22,8 @@ #include "AthenaKernel/CLASS_DEF.h" #include "AthenaKernel/CLIDRegistry.h" +#include "AthenaKernel/tools/AthenaPackageInfo.h" + class Foo{}; CLASS_DEF( Foo, 8101, 0) class Bar{}; -- GitLab