diff --git a/GaudiPluginService/include/Gaudi/PluginServiceV2.h b/GaudiPluginService/include/Gaudi/PluginServiceV2.h index 7dac7144f1c98500766454ab357069b5990c7299..1737ad7b6428991415247c0f26b524bff8beda99 100644 --- a/GaudiPluginService/include/Gaudi/PluginServiceV2.h +++ b/GaudiPluginService/include/Gaudi/PluginServiceV2.h @@ -154,11 +154,21 @@ namespace Gaudi { ::Gaudi::PluginService::v2::Details::stringify_id( id ) }; \ } +#define _PS_V2_DECLARE_COMPONENT_PROPERTY( id, name, value ) \ + namespace { \ + struct _PS_V2_INTERNAL_SET_PROPERTY { \ + _PS_V2_INTERNAL_SET_PROPERTY() { \ + ::Gaudi::PluginService::v2::Details::Registry::instance().addProperty( #id, name, value ); \ + } \ + } _ps_v2_internal_set_property; \ + } + #if GAUDI_PLUGIN_SERVICE_USE_V2 # define DECLARE_COMPONENT( type ) _PS_V2_DECLARE_COMPONENT( type ) # define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id ) # define DECLARE_FACTORY( type, factory ) _PS_V2_DECLARE_FACTORY( type, factory ) # define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory ) +# define DECLARE_COMPONENT_PROPERTY( id, name, value ) _PS_V2_DECLARE_COMPONENT_PROPERTY( id, name, value ) #endif #endif //_GAUDI_PLUGIN_SERVICE_H_ diff --git a/GaudiPluginService/tests/src/UseCasesLib.cpp b/GaudiPluginService/tests/src/UseCasesLib.cpp index 6ec70a983869c1cd82f34e93f69c09f0dfe19323..c46ec1133b5accf1575eaa8569befd92ec615436 100644 --- a/GaudiPluginService/tests/src/UseCasesLib.cpp +++ b/GaudiPluginService/tests/src/UseCasesLib.cpp @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 2013-2019 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 2013-2022 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -55,6 +55,11 @@ public: DECLARE_COMPONENT( Component2 ) +// deprecated +class ObsoleteComponent : public Base {}; +DECLARE_COMPONENT( ObsoleteComponent ) +DECLARE_COMPONENT_PROPERTY( ObsoleteComponent, "deprecated", "this component is obsolete" ) + // namespaces namespace Test { class ComponentA : public Base {}; diff --git a/GaudiPluginService/tests/src/UseCasesTests.cpp b/GaudiPluginService/tests/src/UseCasesTests.cpp index f89a33b60e83940ce8a0189ed19f58a601b9f0dc..a64a13dd24bcef0c054de164c6e7d9f661d46529 100644 --- a/GaudiPluginService/tests/src/UseCasesTests.cpp +++ b/GaudiPluginService/tests/src/UseCasesTests.cpp @@ -65,6 +65,7 @@ BOOST_AUTO_TEST_CASE( deprecated ) { reg.setError( "deprecated" ); BOOST_CHECK( Base::Factory::create( "Component0" ) == nullptr ); + BOOST_CHECK( Base::Factory::create( "ObsoleteComponent" ) == nullptr ); reg.unsetError( "deprecated" ); reg.addProperty( "Component0", "deprecated", "this factory will be removed in Gaudi v99" );