Skip to content
Snippets Groups Projects
Commit 67106d42 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

GaudiPluginService: add DECLARE_COMPONENT_PROPERTY macro

`DECLARE_COMPONENT_PROPERTY( MyComponent, "myprop", "value" )` can be
used to set properties on already declared components.
parent 5f59d208
No related branches found
No related tags found
1 merge request!1395PluginServiceV2: allow factories to be deprecated
......@@ -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_
/***********************************************************************************\
* (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 {};
......
......@@ -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" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment