diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.h b/Control/AthToolSupport/AsgTools/AsgTools/AsgMetadataTool.h index 3bde14c82beb665574fa0bb495c952c28b9a9bbd..6c387157ac5e3ff5dcc83aa782f729262d668e8c 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 0000000000000000000000000000000000000000..985c98e7535bdf0ec39c75b28e7a5a37de6fd4e3 --- /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 de41ff12db5e3a8c768b31a8b2cb3eddf9afd64c..c3808c675d41f44cac20237d5f045c51db1a9adf 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 0000000000000000000000000000000000000000..2cc8fcccd04453fa4f275f13cb21ddbc3ca716e8 --- /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 0000000000000000000000000000000000000000..485a8c4da89dc3d0b347da9d78fe415cb6118b49 --- /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 0ceec6060ffb3a7d005f836391b07d4582b0bdac..a869856a4bb9a1caeceb48a9cfef1ddf5dd54465 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 df8243911050b6596cd83fda373266614ff45a8a..fe1703fe83f855ead18f693ac3ee2dfd404ad94e 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"