35 template <
typename TYPE,
typename VERIFIER,
typename HANDLERS>
41 inline bool iequal( std::string_view v1, std::string_view v2 ) {
43 [](
char c1,
char c2 ) {
return toupper( c1 ) ==
toupper( c2 ); } );
69 static_assert( std::is_base_of_v<IProperty, BASE> && std::is_base_of_v<INamedInterface, BASE>,
70 "PropertyHolder template argument must inherit from IProperty and INamedInterface" );
100 template <
typename TYPE>
103 const std::string& doc =
"none" ) {
104 auto make_property = [&](
const std::string& n, TYPE& v ) {
105 if constexpr (
requires {
typename TYPE::PropertyType; } ) {
106 return std::make_unique<typename TYPE::PropertyType>( n, v );
108 return std::make_unique<Gaudi::Property<TYPE&>>( n, v );
111 m_todelete.push_back( make_property( name, value ) );
120 template <
class TYPE,
class VERIFIER,
class HANDLERS>
123 const std::string& doc =
"none" ) {
134 const std::string& rname =
"" ) {
135 if ( !rsvc )
return nullptr;
136 const std::string& nam = rname.empty() ? name : rname;
174 }
catch (
const std::invalid_argument& err ) {
193 if ( !p )
throw std::out_of_range(
"Property " + std::string{ name } +
" not found." );
239 auto set_prop = [&optsSvc,
this](
auto prop ) { optsSvc.
bind( this->name(), prop ); };
242 if ( rem.owner ) set_prop( this->
property( rem.remName, rem.owner->getProperties() ) );
249 const std::vector<Gaudi::Details::PropertyBase*>& props )
const {
251 return p && Gaudi::Utils::iequal( p->name(), name );
253 return ( it != props.end() ) ? *it :
nullptr;
261 if ( !msgSvc ) std::cerr <<
"error: cannot get MessageSvc!" << std::endl;
263 log <<
MSG::WARNING <<
"duplicated property name '" << name <<
"', see https://its.cern.ch/jira/browse/GAUDI-1023"
268 typedef std::vector<Gaudi::Details::PropertyBase*>
Properties;
281 std::vector<std::unique_ptr<Gaudi::Details::PropertyBase>>
m_todelete;
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
void setDocumentation(std::string value)
set the documentation string
virtual std::string toString() const =0
value -> string
void setName(std::string value)
set the new value for the property name
virtual StatusCode fromString(const std::string &value)=0
string -> value
const std::string name() const
property name
Implementation of property with value of concrete type.
Define general base for Gaudi exception.
The IMessage is the interface implemented by the message service.
The IProperty is the basic interface for all components which have properties that can be set or get.
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Definition of the MsgStream class used to transmit messages.
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
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
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties owned by PropertyHolder, to be deleted.
const Gaudi::Details::PropertyBase & getProperty(std::string_view name) const override
get the property by name
Gaudi::Details::PropertyBase * property(std::string_view name) const
\fixme property and bindPropertiesTo should be protected
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
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).
Properties m_properties
Collection of all declared properties.
PropertyHolder(const PropertyHolder &)=delete
StatusCode setPropertyRepr(const std::string &n, const std::string &r) override
set the property from name and value string representation
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 setProperty(const std::string &name, const Gaudi::Details::PropertyBase &p) override
set the property from another property with a different name
PropertyHolder< BASE > PropertyHolderImpl
Typedef used to refer to this class from derived classes, as in.
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Declare a remote property.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
StatusCode getProperty(std::string_view n, std::string &v) const override
convert the property to the string
StatusCode setProperty(const std::string &s) override
set the property from the formatted string
bool hasProperty(std::string_view name) const override
Return true if we have a property with the given name.
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
std::vector< RemProperty > RemoteProperties
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.
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
PropertyHolder & operator=(const PropertyHolder &)=delete
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
constexpr bool is_gaudi_property_v
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
bool iequal(std::string_view v1, std::string_view v2)
Helper for case insensitive string comparison.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
AttribStringParser::Iterator end(const AttribStringParser &)
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
GAUDI_API ISvcLocator * svcLocator()
Interface for a component that manages application configuration options.
virtual void bind(const std::string &prefix, Gaudi::Details::PropertyBase *property)=0
Register a Gaudi::Property instance to the option service.