From eabfa49b0f1ca725aa1c3c70b00d5c3749330972 Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Fri, 5 Dec 2014 16:42:38 +0100 Subject: [PATCH] Disable deprecation warnings during dictionary generation. (AsgTools-00-00-35) * Tagging AsgTools-00-00-35. * AsgTools/AsgToolsDict.h: Disable deprecation warnings during dictionary generation. 2014-11-13 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> * Made the dictionary generation functional in Athena as well. * Had to disable the explicit instantiation of the setProperty(...) functions in AsgToolsDict.h, since in Athena that function is implemented in GaudiKernel, and always just takes two string arguments. (It's not a template function.) * Silenced the checkreq warning that Will introduced, by placing the new include file in AsgToolsAthena.h as well. * Tagging as AsgTools-00-00-34 2014-11-13 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> * Marked Will's retrieveMetadata function as deprecated. As we discussed it with him, the jet tools will need to use a more elegant solution than this ugly function. * The package now generates Reflex dictionaries in standalone ... (Long ChangeLog diff - truncated) --- .../AsgTools/AsgTools/AsgMetadataTool.h | 23 ++++++- .../AsgTools/AsgTools/AsgMetadataTool.icc | 69 +++++++++++++++++++ .../AsgTools/AsgTools/AsgToolsAthena.h | 7 +- .../AsgTools/AsgTools/AsgToolsDict.h | 39 +++++++++++ .../AsgTools/AsgTools/selection.xml | 9 +++ .../AsgTools/cmt/Makefile.RootCore | 2 +- .../AthToolSupport/AsgTools/cmt/requirements | 11 ++- 7 files changed, 152 insertions(+), 8 deletions(-) create mode 100644 Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.icc create mode 100644 Control/AthToolSupport/AsgTools/AsgTools/AsgToolsDict.h create mode 100644 Control/AthToolSupport/AsgTools/AsgTools/selection.xml diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.h b/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.h index 3bde14c82be..6c387157ac5 100644 --- a/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.h +++ b/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.h @@ -1,5 +1,5 @@ // Dear emacs, this is -*- c++ -*- -// $Id: AsgMetadataTool.h 611950 2014-08-15 08:52:15Z krasznaa $ +// $Id: AsgMetadataTool.h 628138 2014-11-13 11:51:41Z krasznaa $ #ifndef ASGTOOLS_ASGMETADATATOOL_H #define ASGTOOLS_ASGMETADATATOOL_H @@ -41,8 +41,8 @@ namespace asg { /// /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> /// - /// $Revision: 611950 $ - /// $Date: 2014-08-15 10:52:15 +0200 (Fri, 15 Aug 2014) $ + /// $Revision: 628138 $ + /// $Date: 2014-11-13 12:51:41 +0100 (Thu, 13 Nov 2014) $ /// class AsgMetadataTool : public AsgTool, public virtual IIncidentListener { @@ -83,6 +83,20 @@ namespace asg { /// Function initialising the tool in the correct way in Athena virtual StatusCode sysInitialize(); + + /// Helper function to access IOVMetaDataContainer information held in + /// the MetaDataStore + /// For non athena environments, this will just return StatusCode::FAILURE + /// + /// Note that having this function here is very bad design. :-( For now + /// it's marked as deprecated, but Will needs to put replacement code into + /// AthenaBaseComps to replace this... + /// + template< typename T > + StatusCode retrieveMetadata( const std::string& folder, + const std::string& key, + T& out ) __attribute__ ((deprecated)); + protected: /// @name Callback functions helping in metadata reading /// @{ @@ -108,4 +122,7 @@ namespace asg { } // namespace asg +// Include the template implementation(s): +#include "AsgTools/AsgMetadataTool.icc" + #endif // ASGTOOLS_ASGMETADATATOOL_H diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.icc b/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.icc new file mode 100644 index 00000000000..985c98e7535 --- /dev/null +++ b/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.icc @@ -0,0 +1,69 @@ +// Dear emacs, this is -*- c++ -*- +// $Id: AsgMetadataTool.icc 628138 2014-11-13 11:51:41Z krasznaa $ +#ifndef ASGTOOLS_ASGMETADATATOOL_ICC +#define ASGTOOLS_ASGMETADATATOOL_ICC + +#ifdef ASGTOOL_ATHENA + +// Athena EDM include(s): +#include "IOVDbDataModel/IOVMetaDataContainer.h" + +namespace asg { + + template< typename T > + StatusCode AsgMetadataTool::retrieveMetadata( const std::string& folder, + const std::string& key, + T& out ) { + + // Retrieve the metadata container: + const IOVMetaDataContainer* cont = 0; + ATH_CHECK( inputMetaStore()->retrieve( cont, folder ) ); + + // Payload is a collection of condattrlistcollections + // Only look a the first one, assuming it exists, and within that only + // look at the first channel; + if( ( cont->payloadContainer()->size() > 0 ) && + ( cont->payloadContainer()->at( 0 )->size() > 0 ) ) { + + // Just try to retrieve the requested key from the attributelist - + // we will let it throw the AttributeListException if it fails + // If the typeName is std::string, we will try to use the gaudi parsers + // to parse it, otherwise we try to do a straight assignment + const coral::Attribute& attr = + cont->payloadContainer()->at( 0 )->attributeList( cont->payloadContainer()->at( 0 )->chanNum( 0 ) )[ key ]; + if( attr.specification().typeName() == "string" ) { + ATH_CHECK( Gaudi::Parsers::parse( out, + attr.data< std::string >() ) ); + } else { + // Do a straight conversion, and just hope its ok + // (FIXME: should probably do a check of typeid(T) vs typeName) + out = attr.data< T >(); + } + // We were apparently successful: + return StatusCode::SUCCESS; + } + + // We failed... + return StatusCode::FAILURE; + } + +} // namespace asg + +#elif defined(ASGTOOL_STANDALONE) + +namespace asg { + + template< typename T > + StatusCode AsgMetadataTool::retrieveMetadata( const std::string&, + const std::string&, T& ) { + + ATH_MSG_WARNING( "retrieveMetadata currently unimplemented outside of " + "athena" ); + return StatusCode::FAILURE; + } + +} // namespace asg + +#endif // Environment selection + +#endif // not ASGTOOLS_ASGMETADATATOOL_ICC diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsAthena.h b/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsAthena.h index de41ff12db5..c3808c675d4 100644 --- a/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsAthena.h +++ b/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsAthena.h @@ -1,5 +1,5 @@ // Dear emacs, this is -*- c++ -*- -// $Id: AsgToolsAthena.h 615228 2014-09-05 10:19:06Z krasznaa $ +// $Id: AsgToolsAthena.h 628154 2014-11-13 12:30:13Z krasznaa $ /// @file AsgTools/AsgToolsAthena.h /// @short File making it clear to checkreq.py that the requirements file is OK /// @@ -9,8 +9,8 @@ /// to make it clear to checkreq.py that some of the Athena packages do get /// used publicly by the code. /// -/// $Revision: 615228 $ -/// $Date: 2014-09-05 12:19:06 +0200 (Fri, 05 Sep 2014) $ +/// $Revision: 628154 $ +/// $Date: 2014-11-13 13:30:13 +0100 (Thu, 13 Nov 2014) $ /// #ifndef ASGTOOLS_ASGTOOLSATHENA_H #define ASGTOOLS_ASGTOOLSATHENA_H @@ -22,5 +22,6 @@ #include "GaudiKernel/IAlgTool.h" #include "AthenaBaseComps/AthAlgTool.h" #include "SGTools/CLASS_DEF.h" +#include "IOVDbDataModel/IOVMetaDataContainer.h" #endif // ASGTOOLS_ASGTOOLSATHENA_H diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsDict.h b/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsDict.h new file mode 100644 index 00000000000..2cc8fcccd04 --- /dev/null +++ b/Control/AthToolSupport/AsgTools/AsgTools/AsgToolsDict.h @@ -0,0 +1,39 @@ +// Dear emacs, this is -*- c++ -*- +// $Id: AsgToolsDict.h 634085 2014-12-05 16:42:38Z ssnyder $ +#ifndef ASGTOOLS_ASGTOOLSDICT_H +#define ASGTOOLS_ASGTOOLSDICT_H + +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +// Local include(s): +#include "AsgTools/IAsgTool.h" +#include "AsgTools/AsgTool.h" +#include "AsgTools/AsgMetadataTool.h" + +// The following is only needed for standalone usage. In Athena the +// setProperty(...) function(s) come(s) from the AlgTool base class, with all +// the necessary dictionaries declared in GaudiKernel. +#ifdef ASGTOOL_STANDALONE + +// Helper macro for declaring the setProperty functions to the dictionary: +#define SETPROPERTY_INSTAN( TYPE ) \ + template StatusCode asg::AsgTool::setProperty< TYPE >( const std::string&, \ + const TYPE& ) + +// Declare all possible setProperty template instantiations to Reflex: +SETPROPERTY_INSTAN( bool ); +SETPROPERTY_INSTAN( int ); +SETPROPERTY_INSTAN( float ); +SETPROPERTY_INSTAN( double ); +SETPROPERTY_INSTAN( std::string ); +SETPROPERTY_INSTAN( std::vector< int > ); +SETPROPERTY_INSTAN( std::vector< float > ); +SETPROPERTY_INSTAN( std::vector< std::string > ); + +// Make the compiler forget about this macro now... +#undef SETPROPERTY_INSTAN + +#endif // ASGTOOL_STANDALONE +#endif // not ASGTOOLS_ASGTOOLSDICT_H diff --git a/Control/AthToolSupport/AsgTools/AsgTools/selection.xml b/Control/AthToolSupport/AsgTools/AsgTools/selection.xml new file mode 100644 index 00000000000..485a8c4da89 --- /dev/null +++ b/Control/AthToolSupport/AsgTools/AsgTools/selection.xml @@ -0,0 +1,9 @@ +<!-- $Id: selection.xml 628138 2014-11-13 11:51:41Z krasznaa $ --> +<lcgdict> + + <!-- The basic tool types: --> + <class name="asg::IAsgTool" /> + <class name="asg::AsgTool" /> + <class name="asg::AsgMetadataTool" /> + +</lcgdict> diff --git a/Control/AthToolSupport/AsgTools/cmt/Makefile.RootCore b/Control/AthToolSupport/AsgTools/cmt/Makefile.RootCore index 0ceec6060ff..a869856a4bb 100644 --- a/Control/AthToolSupport/AsgTools/cmt/Makefile.RootCore +++ b/Control/AthToolSupport/AsgTools/cmt/Makefile.RootCore @@ -19,6 +19,6 @@ PACKAGE_NOGRID = PACKAGE_PEDANTIC = 0 PACKAGE_NOOPT = 0 PACKAGE_NOCC = 0 -PACKAGE_REFLEX = 0 +PACKAGE_REFLEX = 1 include $(ROOTCOREDIR)/Makefile-common diff --git a/Control/AthToolSupport/AsgTools/cmt/requirements b/Control/AthToolSupport/AsgTools/cmt/requirements index df824391105..fe1703fe83f 100644 --- a/Control/AthToolSupport/AsgTools/cmt/requirements +++ b/Control/AthToolSupport/AsgTools/cmt/requirements @@ -1,5 +1,5 @@ package AsgTools -# $Id$ +# $Id: requirements 628154 2014-11-13 12:30:13Z krasznaa $ author David Adams @@ -12,8 +12,17 @@ use GaudiInterface GaudiInterface-* External use AthenaBaseComps AthenaBaseComps-* Control use SGTools SGTools-* Control +use IOVDbDataModel IOVDbDataModel-* Database + # Build a library: library AsgTools "../Root/MsgLevel.cxx ../Root/AsgTool.cxx \ ../Root/AsgMetadataTool.cxx ../Root/AsgMessaging.cxx \ *.cxx" apply_pattern installed_library + +private + +# Generate a dictionary: +use AtlasReflex AtlasReflex-* External -no_auto_imports +apply_pattern lcgdict dict=AsgTools selectionfile=selection.xml \ + headerfiles="../AsgTools/AsgToolsDict.h" -- GitLab