| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PropertyHolder< BASE > Class Template Reference

Helper class to implement the IProperty interface. More...

`#include <GaudiKernel/PropertyHolder.h>`

Inheritance diagram for PropertyHolder< BASE >:
[legend]
Collaboration diagram for PropertyHolder< BASE >:
[legend]

## Public Types
using | PropertyHolderImpl = PropertyHolder< BASE >
| Typedef used to refer to this class from derived classes, as in. More...

## Public Member Functions
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
template<class TYPE , typename = std::enable_if_t<!std::is_base_of<GaudiHandleBase, TYPE>::value && !std::is_base_of<GaudiHandleArrayBase, TYPE>::value && !std::is_base_of<DataObjectHandleBase, TYPE>::value>>
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. More...
template<class TYPE , typename = std::enable_if_t<!std::is_base_of<GaudiHandleBase, TYPE>::value && !std::is_base_of<GaudiHandleArrayBase, TYPE>::value && !std::is_base_of<DataObjectHandleBase, TYPE>::value>>
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
template<class TYPE , class VERIFIER , class HANDLERS >
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. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")

## Protected Member Functions
Gaudi::Details::PropertyBase * | property (const std::string &name) const

## Private Types
typedef std::vector< Gaudi::Details::PropertyBase * > | Properties
typedef std::pair< std::string, std::pair< IProperty *, std::string > > | RemProperty
typedef std::vector< RemProperty > | RemoteProperties

## Private Member Functions
Gaudi::Details::PropertyBase * | property (const std::string &name, const std::vector< Gaudi::Details::PropertyBase * > &props) const
| get the property by name form the proposed list More...
void | assertUniqueName (const std::string &name) const
| Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023). More...

## Private Attributes
Properties | m_properties
| Collection of all declared properties. More...
RemoteProperties | m_remoteProperties
| Collection of all declared remote properties. More...
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > | m_todelete
| Properties owned by PropertyHolder, to be deleted. More...

## Detailed Description

### template<class BASE>
class PropertyHolder< BASE >

Helper class to implement the IProperty interface.

PropertyHolder is used by components base classes (Algorithm, Service, etc.) to provide a default implementation the IProperty interface.

When needing to implement the IProperty interface in a class, it is enough to wrap the base of the class with PropertyHolder, as in

class MyClass : public PropertyHolder<BaseClass> {
// ...
};

where `BaseClass` should inherit from IProperty and INamedInterface.

Author
  Paul Maley
  David Quarrie
  Marco Clemencic

Definition at line 73 of file PropertyHolder.h.

## Member Typedef Documentation

template<class BASE>

typedef std::vector<Gaudi::Details::PropertyBase*> PropertyHolder< BASE >::Properties
| private

Definition at line 390 of file PropertyHolder.h.

template<class BASE>

using PropertyHolder< BASE >::PropertyHolderImpl = PropertyHolder<BASE>

Typedef used to refer to this class from derived classes, as in.

class MyClass : public PropertyHolder<BaseClass> {
using PropertyHolderImpl::declareProperty;
};

Definition at line 85 of file PropertyHolder.h.

template<class BASE>

typedef std::vector<RemProperty> PropertyHolder< BASE >::RemoteProperties
| private

Definition at line 392 of file PropertyHolder.h.

template<class BASE>

typedef std::pair<std::string, std::pair<IProperty*, std::string> > PropertyHolder< BASE >::RemProperty
| private

Definition at line 391 of file PropertyHolder.h.

## Constructor & Destructor Documentation

template<class BASE>

PropertyHolder< BASE >::PropertyHolder | ( |  | ) |
| default

template<class BASE>

PropertyHolder< BASE >::~PropertyHolder | ( |  | ) |
| override default

template<class BASE>

PropertyHolder< BASE >::PropertyHolder | ( | const PropertyHolder< BASE > & |  | ) |
| delete

prevent copies

## Member Function Documentation

template<class BASE>

void PropertyHolder< BASE >::assertUniqueName | ( | const std::string & | name | ) | const
| inline private

Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023).

Definition at line 377 of file PropertyHolder.h.

378 {
379 if ( UNLIKELY( hasProperty( name ) ) ) {
380 auto msgSvc = Gaudi::svcLocator()->service<IMessageSvc>( "MessageSvc" );
381 if ( !msgSvc ) {
382 std::cerr << "error: cannot get MessageSvc!" << std::endl;
383 }
384 MsgStream log( msgSvc, this->name() );
385 log << MSG::WARNING << "duplicated property name '" << name << "', see https://its.cern.ch/jira/browse/GAUDI-1023"
386 << endmsg;
387 }
388 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
PropertyHolder::hasProperty
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
Definition: PropertyHolder.h:334
std::endl
T endl(T...args)
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
MSG::WARNING
Definition: IMessageSvc.h:16
std::cerr
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13
template<class BASE>

Gaudi::Details::PropertyBase& PropertyHolder< BASE >::declareProperty | ( | Gaudi::Details::PropertyBase & | prop | ) |
| inline

Declare a property.

Record a PropertyBase instance to be managed by PropertyHolder.

Definition at line 99 of file PropertyHolder.h.

100 {
101 assertUniqueName( prop.name() );
102 m_properties.push_back( &prop );
103 return prop;
104 }
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::assertUniqueName
void assertUniqueName(const std::string &name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023)...
Definition: PropertyHolder.h:377
std::vector::push_back
T push_back(T...args)
template<class BASE>
template<class TYPE , typename = std::enable_if_t<!std::is_base_of<GaudiHandleBase, TYPE>::value && !std::is_base_of<GaudiHandleArrayBase, TYPE>::value && !std::is_base_of<DataObjectHandleBase, TYPE>::value>>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::declareProperty | ( | const std::string & | name,
|  | TYPE & | value,
|  | const std::string & | doc = `"none"`
| ) |  |
| inline

Helper to wrap a regular data member and use it as a regular property.

Deprecated:
  Prefer the signatures using a a fully initialized PropertyBase instance.

Definition at line 111 of file PropertyHolder.h.

112 {
113 assertUniqueName( name );
114 m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
115 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
116 p->setDocumentation( doc );
117 m_properties.push_back( p );
118 return p;
119 }
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::assertUniqueName
void assertUniqueName(const std::string &name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023)...
Definition: PropertyHolder.h:377
std::vector::push_back
T push_back(T...args)
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::unique_ptr::get
T get(T...args)
std::vector::back
T back(T...args)
PropertyHolder::m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties owned by PropertyHolder, to be deleted.
Definition: PropertyHolder.h:399
std::vector::emplace_back
T emplace_back(T...args)
template<class BASE>
template<class TYPE , typename = std::enable_if_t<!std::is_base_of<GaudiHandleBase, TYPE>::value && !std::is_base_of<GaudiHandleArrayBase, TYPE>::value && !std::is_base_of<DataObjectHandleBase, TYPE>::value>>

Gaudi:: Details::PropertyBase* PropertyHolder< BASE >::declareProperty | ( | const std::string & | name,
|  | TYPE & | value,
|  | const std::string & | doc = `"none"`
| ) |  | const
| inline

Deprecated:
  Kept for backward compatibility, use the non-const version instead, will be removed in v29r0.

Definition at line 128 of file PropertyHolder.h.

129 {
130 return const_cast<PropertyHolder*>( this )->declareProperty<TYPE>( name, value, doc );
131 }
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:73
template<class BASE>
template<class TYPE , class VERIFIER , class HANDLERS >

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::declareProperty | ( | const std::string & | name,
|  | Gaudi::Property< TYPE, VERIFIER, HANDLERS > & | prop,
|  | const std::string & | doc = `"none"`
| ) |  |
| inline

Declare a PropertyBase instance setting name and documentation.

Deprecated:
  Prefer the signatures using a fully initialized PropertyBase instance.

Definition at line 136 of file PropertyHolder.h.

139 {
140 assertUniqueName( name );
141 Gaudi::Details::PropertyBase* p = &prop;
142 p->setName( name );
143 p->setDocumentation( doc );
144 m_properties.push_back( p );
145 return p;
146 }
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::assertUniqueName
void assertUniqueName(const std::string &name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023)...
Definition: PropertyHolder.h:377
std::vector::push_back
T push_back(T...args)
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
Gaudi::Details::PropertyBase::setName
void setName(std::string value)
set the new value for the property name
Definition: Property.h:90
template<class BASE>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::declareProperty | ( | const std::string & | name,
|  | GaudiHandleBase & | ref,
|  | const std::string & | doc = `"none"`
| ) |  |
| inline

Specializations for various GaudiHandles.

Definition at line 164 of file PropertyHolder.h.

166 {
167 assertUniqueName( name );
168 m_todelete.emplace_back( new GaudiHandleProperty( name, ref ) );
169 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
170
171 p->setDocumentation( doc );
172 m_properties.push_back( p );
173
174 return p;
175 }
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::assertUniqueName
void assertUniqueName(const std::string &name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023)...
Definition: PropertyHolder.h:377
std::vector::push_back
T push_back(T...args)
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::unique_ptr::get
T get(T...args)
std::vector::back
T back(T...args)
GaudiPython.Bindings.GaudiHandleProperty
GaudiHandleProperty
Definition: Bindings.py:53
PropertyHolder::m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties owned by PropertyHolder, to be deleted.
Definition: PropertyHolder.h:399
std::vector::emplace_back
T emplace_back(T...args)
template<class BASE>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::declareProperty | ( | const std::string & | name,
|  | GaudiHandleArrayBase & | ref,
|  | const std::string & | doc = `"none"`
| ) |  |
| inline

Definition at line 176 of file PropertyHolder.h.

178 {
179 assertUniqueName( name );
180 m_todelete.emplace_back( new GaudiHandleArrayProperty( name, ref ) );
181 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
182
183 p->setDocumentation( doc );
184 m_properties.push_back( p );
185
186 return p;
187 }
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::assertUniqueName
void assertUniqueName(const std::string &name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023)...
Definition: PropertyHolder.h:377
std::vector::push_back
T push_back(T...args)
GaudiPython.Bindings.GaudiHandleArrayProperty
GaudiHandleArrayProperty
Definition: Bindings.py:54
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::unique_ptr::get
T get(T...args)
std::vector::back
T back(T...args)
PropertyHolder::m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties owned by PropertyHolder, to be deleted.
Definition: PropertyHolder.h:399
std::vector::emplace_back
T emplace_back(T...args)
template<class BASE>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::declareProperty | ( | const std::string & | name,
|  | DataObjectHandleBase & | ref,
|  | const std::string & | doc = `"none"`
| ) |  |
| inline

Definition at line 188 of file PropertyHolder.h.

190 {
191 assertUniqueName( name );
192 m_todelete.emplace_back( new DataObjectHandleProperty( name, ref ) );
193 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
194
195 p->setDocumentation( doc );
196 m_properties.push_back( p );
197
198 return p;
199 }
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::assertUniqueName
void assertUniqueName(const std::string &name) const
Issue a runtime warning if the name is already present in the list of properties (see GAUDI-1023)...
Definition: PropertyHolder.h:377
DataObjectHandleProperty
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
Definition: DataObjectHandleProperty.h:23
std::vector::push_back
T push_back(T...args)
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::unique_ptr::get
T get(T...args)
std::vector::back
T back(T...args)
PropertyHolder::m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties owned by PropertyHolder, to be deleted.
Definition: PropertyHolder.h:399
std::vector::emplace_back
T emplace_back(T...args)
template<class BASE>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::declareRemoteProperty | ( | const std::string & | name,
|  | IProperty * | rsvc,
|  | const std::string & | rname = `""`
| ) |  |
| inline

Declare a remote property.

Bind `name` to the property `rname` of `rsvc`.

Definition at line 150 of file PropertyHolder.h.

152 {
153 if ( !rsvc ) {
154 return nullptr;
155 }
156 const std::string& nam = rname.empty() ? name : rname;
157 Gaudi::Details::PropertyBase* p = property( nam, rsvc->getProperties() );
158 m_remoteProperties.emplace_back( name, std::make_pair( rsvc, nam ) );
159 return p;
160 }
std::string::empty
T empty(T...args)
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
std::string
STL class.
PropertyHolder::m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyHolder.h:397
std::make_pair
T make_pair(T...args)
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
IProperty::getProperties
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
std::vector::emplace_back
T emplace_back(T...args)
template<class BASE>

const std::vector<Gaudi::Details::PropertyBase*>& PropertyHolder< BASE >::getProperties | ( |  | ) | const
| inline override

get all properties

See also
  IProperty

Definition at line 329 of file PropertyHolder.h.

329 { return m_properties; }
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
template<class BASE>

StatusCode PropertyHolder< BASE >::getProperty | ( | Gaudi::Details::PropertyBase * | p | ) | const
| inline override

get the property

See also
  IProperty

Definition at line 291 of file PropertyHolder.h.

292 {
293 try {
294 const Gaudi::Details::PropertyBase* pp = property( p->name() );
295 if ( pp && pp->load( *p ) ) return StatusCode::SUCCESS;
296 } catch ( ... ) {
297 }
298 return StatusCode::FAILURE;
299 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
Gaudi::Details::PropertyBase::load
virtual bool load(PropertyBase &dest) const =0
export the property value to the destination
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:467
StatusCode::FAILURE
Definition: StatusCode.h:29
template<class BASE>

const Gaudi::Details::PropertyBase& PropertyHolder< BASE >::getProperty | ( | const std::string & | name | ) | const
| inline override

get the property by name

See also
  IProperty

Definition at line 304 of file PropertyHolder.h.

305 {
306 const Gaudi::Details::PropertyBase* p = property( name );
307 if ( !p ) throw std::out_of_range( "Property " + name + " not found." );
308 return *p;
309 }
std::out_of_range
STL class.
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
template<class BASE>

StatusCode PropertyHolder< BASE >::getProperty | ( | const std::string & | n,
|  | std::string & | v
| ) |  | const
| inline override

convert the property to the string

See also
  IProperty

Definition at line 314 of file PropertyHolder.h.

315 {
316 // get the property
317 const Gaudi::Details::PropertyBase* p = property( n );
318 if ( !p ) {
319 return StatusCode::FAILURE;
320 }
321 // convert the value into the string
322 v = p->toString();
323 return StatusCode::SUCCESS;
324 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
StatusCode::FAILURE
Definition: StatusCode.h:29
template<class BASE>

bool PropertyHolder< BASE >::hasProperty | ( | const std::string & | name | ) | const
| inline override

Return true if we have a property with the given name.

See also
  IProperty

Definition at line 334 of file PropertyHolder.h.

335 {
336 return any_of( begin( m_properties ), end( m_properties ), [&name]( const Gaudi::Details::PropertyBase* prop ) {
337 return Gaudi::Utils::iequal( prop->name(), name );
338 } );
339 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
Gaudi::Utils::iequal
bool iequal(const std::string &v1, const std::string &v2)
Helper for case insensitive string comparison.
Definition: PropertyHolder.h:45
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::any_of
T any_of(T...args)
template<class BASE>

PropertyHolder& PropertyHolder< BASE >::operator= | ( | const PropertyHolder< BASE > & |  | ) |
| delete

template<class BASE>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::property | ( | const std::string & | name | ) | const
| inline protected

Definition at line 343 of file PropertyHolder.h.

344 {
345 // local property ?
346 Gaudi::Details::PropertyBase* lp = property( name, m_properties );
347 if ( lp ) {
348 return lp;
349 }
350 // look for remote property
351 for ( const auto& it : m_remoteProperties ) {
352 if ( !Gaudi::Utils::iequal( it.first, name ) ) {
353 continue;
354 }
355 const IProperty* p = it.second.first;
356 if ( !p ) {
357 continue;
358 }
359 return property( it.second.second, p->getProperties() );
360 }
361 return nullptr; // RETURN
362 }
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
PropertyHolder::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyHolder.h:395
PropertyHolder::m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyHolder.h:397
Gaudi::Utils::iequal
bool iequal(const std::string &v1, const std::string &v2)
Helper for case insensitive string comparison.
Definition: PropertyHolder.h:45
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
IProperty::getProperties
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
template<class BASE>

Gaudi::Details::PropertyBase* PropertyHolder< BASE >::property | ( | const std::string & | name,
|  | const std::vector< Gaudi::Details::PropertyBase * > & | props
| ) |  | const
| inline private

get the property by name form the proposed list

Definition at line 366 of file PropertyHolder.h.

368 {
369 auto it = std::find_if( props.begin(), props.end(), [&name]( Gaudi::Details::PropertyBase* p ) {
370 return p && Gaudi::Utils::iequal( p->name(), name );
371 } );
372 return ( it != props.end() ) ? *it : nullptr; // RETURN
373 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
std::vector::end
T end(T...args)
Gaudi::Utils::iequal
bool iequal(const std::string &v1, const std::string &v2)
Helper for case insensitive string comparison.
Definition: PropertyHolder.h:45
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::find_if
T find_if(T...args)
std::vector::begin
T begin(T...args)
template<class BASE>

StatusCode PropertyHolder< BASE >::setProperty | ( | const Gaudi::Details::PropertyBase & | p | ) |
| inline override

set the property form another property

See also
  IProperty

Definition at line 208 of file PropertyHolder.h.

209 {
210 Gaudi::Details::PropertyBase* pp = property( p.name() );
211 try {
212 if ( pp && pp->assign( p ) ) {
213 return StatusCode::SUCCESS;
214 }
215 } catch ( ... ) {
216 }
217 return StatusCode::FAILURE;
218 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
Gaudi::Details::PropertyBase::assign
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:467
StatusCode::FAILURE
Definition: StatusCode.h:29
template<class BASE>

StatusCode PropertyHolder< BASE >::setProperty | ( | const std::string & | s | ) |
| inline override

set the property from the formatted string

See also
  IProperty

Definition at line 223 of file PropertyHolder.h.

224 {
225 std::string name;
226 std::string value;
227 StatusCode sc = Gaudi::Parsers::parse( name, value, s );
228 if ( sc.isFailure() ) {
229 return sc;
230 }
231 return setProperty( name, value );
232 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
PropertyHolder::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
Definition: PropertyHolder.h:208
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:13
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:61
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
template<class BASE>

StatusCode PropertyHolder< BASE >::setProperty | ( | const std::string & | n,
|  | const std::string & | v
| ) |  |
| inline override

set the property from name and the value

See also
  IProperty

Definition at line 237 of file PropertyHolder.h.

238 {
239 Gaudi::Details::PropertyBase* p = property( n );
240 return ( p && p->fromString( v ) ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
241 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
PropertyHolder::property
Gaudi::Details::PropertyBase * property(const std::string &name) const
Definition: PropertyHolder.h:343
Gaudi::Details::PropertyBase::fromString
virtual StatusCode fromString(const std::string &value)=0
string -> value
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
StatusCode::FAILURE
Definition: StatusCode.h:29
template<class BASE>
template<class TYPE >

StatusCode PropertyHolder< BASE >::setProperty | ( | const std::string & | name,
|  | const TYPE & | value
| ) |  |
| inline

set the property form the value

std::vector<double> data = ... ;
setProperty( "Data" , data ) ;
std::map<std::string,double> cuts = ... ;
setProperty( "Cuts" , cuts ) ;
std::map<std::string,std::string> dict = ... ;
setProperty( "Dictionary" , dict ) ;

Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only

This is very convenient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty

setProperty ( "OutputLevel" , "1" ) ;
setProperty ( "Enable" , "True" ) ;
setProperty ( "ErrorMax" , "10" ) ;

For simple cases it is more or less ok, but for complicated properties it is just ugly..

Parameters

  name | name of the property
  value | value of the property

See also
  Gaudi::Utils::setProperty

Author
  Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u

Date
  2007-05-13

Definition at line 283 of file PropertyHolder.h.

284 {
285 return Gaudi::Utils::setProperty( this, name, value );
286 }
Gaudi::Utils::setProperty
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition: Property.h:1172

## Member Data Documentation

template<class BASE>

Properties PropertyHolder< BASE >::m_properties
| private

Collection of all declared properties.

Definition at line 395 of file PropertyHolder.h.

template<class BASE>

RemoteProperties PropertyHolder< BASE >::m_remoteProperties
| private

Collection of all declared remote properties.

Definition at line 397 of file PropertyHolder.h.

template<class BASE>

std::vector<std::unique_ptr<Gaudi::Details::PropertyBase> > PropertyHolder< BASE >::m_todelete
| private

Properties owned by PropertyHolder, to be deleted.

Definition at line 399 of file PropertyHolder.h.

The documentation for this class was generated from the following file:

- GaudiKernel/GaudiKernel/PropertyHolder.h