Go to the documentation of this file.
11 #ifndef GAUDIKERNEL_PROPERTYHOLDER_H
12 #define GAUDIKERNEL_PROPERTYHOLDER_H
45 template <
typename TYPE,
typename VERIFIER,
typename HANDLERS>
55 inline bool iequal( std::string_view
v1, std::string_view
v2 ) {
83 static_assert( std::is_base_of_v<IProperty, BASE> && std::is_base_of_v<INamedInterface, BASE>,
84 "PropertyHolder template argument must inherit from IProperty and INamedInterface" );
107 assertUniqueName( prop.
name() );
108 m_properties.push_back( &prop );
114 template <typename TYPE, typename = std::enable_if_t<!Gaudi::Details::is_gaudi_property<TYPE>::value>>
121 return &declareProperty( *p );
126 template <
class TYPE,
class VERIFIER,
class HANDLERS>
134 return &declareProperty( *p );
141 if ( !rsvc )
return nullptr;
144 m_remoteProperties.emplace_back( RemProperty{
name, rsvc, nam } );
171 return setPropertyRepr(
name, value );
228 return any_of(
begin( m_properties ),
end( m_properties ),
232 any_of(
begin( m_remoteProperties ),
end( m_remoteProperties ),
243 for (
const auto& it : m_remoteProperties ) {
253 auto set_prop = [&optsSvc,
this](
auto prop ) { optsSvc.
bind( this->
name(), prop ); };
255 std::for_each(
begin( m_remoteProperties ),
end( m_remoteProperties ), [&set_prop,
this](
auto& rem ) {
256 if ( rem.owner ) set_prop( this->property( rem.remName, rem.owner->getProperties() ) );
265 return p && Gaudi::Utils::iequal( p->name(), name );
267 return ( it !=
props.end() ) ? *it :
nullptr;
277 log <<
MSG::WARNING <<
"duplicated property name '" <<
name <<
"', see https://its.cern.ch/jira/browse/GAUDI-1023"
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
const std::string name() const
property name
void toupper(std::string &s)
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
Declare a PropertyBase instance setting name and documentation.
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
StatusCode setProperty(const std::string &name, const Gaudi::Details::PropertyBase &p) override
set the property from another property with a different name
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
typename std::remove_reference_t< T >::PropertyType PropertyType_t
Helper class to implement the IProperty interface.
virtual StatusCode fromString(const std::string &value)=0
string -> value
void assertUniqueName(std::string_view name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023).
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties owned by PropertyHolder, to be deleted.
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Declare a remote property.
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Gaudi::cpp17::detected_or_t< Gaudi::Property< T >, PropertyType_t, T > PropertyType
Gaudi::Details::PropertyBase * property(std::string_view name) const
\fixme property and bindPropertiesTo should be protected
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
Gaudi::Details::PropertyBase * property(std::string_view name, const std::vector< Gaudi::Details::PropertyBase * > &props) const
get the property by name form the proposed list
GAUDI_API ISvcLocator * svcLocator()
virtual void bind(const std::string &prefix, Gaudi::Details::PropertyBase *property)=0
Register a Gaudi::Property instance to the option service.
void setDocumentation(std::string value)
set the documentation string
AttribStringParser::Iterator begin(const AttribStringParser &parser)
StatusCode setProperty(const std::string &s) override
set the property from the formatted string
StatusCode setPropertyRepr(const std::string &n, const std::string &r) override
set the property from name and value string representation
typename details::detector< Default, void, Op, Args... >::type detected_or_t
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Helper to wrap a regular data member and use it as a regular property.
bool iequal(std::string_view v1, std::string_view v2)
Helper for case insensitive string comparison.
AttribStringParser::Iterator end(const AttribStringParser &)
PropertyHolder(const PropertyHolder &)=delete
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
Properties m_properties
Collection of all declared properties.
constexpr static const auto SUCCESS
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
const Gaudi::Details::PropertyBase & getProperty(std::string_view name) const override
get the property by name
virtual std::string toString() const =0
value -> string
std::vector< Gaudi::Details::PropertyBase * > Properties
void setName(std::string value)
set the new value for the property name
std::vector< RemProperty > RemoteProperties
StatusCode getProperty(std::string_view n, std::string &v) const override
convert the property to the string
constexpr static const auto FAILURE
Interface for a component that manages application configuration options.
Implementation of property with value of concrete type.
PropertyHolder & operator=(const PropertyHolder &)=delete
GAUDI_API bool hasProperty(const IProperty *p, std::string_view name)
simple function which check the existence of the property with the given name.
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
bool hasProperty(std::string_view name) const override
Return true if we have a property with the given name.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.