PropertyMgr Class Reference

Property manager helper class. More...

#include <GaudiKernel/PropertyMgr.h>

Inheritance diagram for PropertyMgr:
Collaboration diagram for PropertyMgr:

Public Member Functions

 PropertyMgr (IInterface *iface=0)
 constructor from the interface More...
 
 PropertyMgr (const PropertyMgr &)
 
virtual ~PropertyMgr ()
 virtual destructor More...
 
PropertyMgroperator= (const PropertyMgr &)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Declare a property (templated) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, SimpleProperty< TYPE > &prop, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, SimplePropertyRef< TYPE > &prop, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ToolHandle< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ServiceHandle< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ToolHandleArray< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ServiceHandleArray< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Property &p)
 set the property form another property More...
 
StatusCode setProperty (const std::string &s)
 set the property from the property formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v)
 set the property from name and the value More...
 
StatusCode getProperty (Property *p) const
 get the property More...
 
const PropertygetProperty (const std::string &name) const
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const
 convert the property to the string More...
 
const std::vector< Property * > & getProperties () const
 get all properties More...
 
bool hasProperty (const std::string &name) const
 Return true if we have a property with the given name. More...
 
StatusCode queryInterface (const InterfaceID &iid, void **pinterface)
 Set the void** to the pointer to the requested interface of the instance. More...
 
 PropertyMgr (IInterface *iface=0)
 constructor from the interface More...
 
 PropertyMgr (const PropertyMgr &)
 
virtual ~PropertyMgr ()
 virtual destructor More...
 
PropertyMgroperator= (const PropertyMgr &)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Declare a property (templated) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, SimpleProperty< TYPE > &prop, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, SimplePropertyRef< TYPE > &prop, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ToolHandle< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ServiceHandle< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ToolHandleArray< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ServiceHandleArray< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization) More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Property &p)
 set the property form another property More...
 
StatusCode setProperty (const std::string &s)
 set the property from the property formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v)
 set the property from name and the value More...
 
StatusCode getProperty (Property *p) const
 get the property More...
 
const PropertygetProperty (const std::string &name) const
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const
 convert the property to the string More...
 
const std::vector< Property * > & getProperties () const
 get all properties More...
 
bool hasProperty (const std::string &name) const
 Return true if we have a property with the given name. More...
 
StatusCode queryInterface (const InterfaceID &iid, void **pinterface)
 Set the void** to the pointer to the requested interface of the instance. More...
 
- Public Member Functions inherited from extend_interfaces1< IProperty >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 1)
 InterfaceID. More...
 
 DeclareInterfaceID (IProperty, 2, 1)
 InterfaceID. More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 

Protected Member Functions

Propertyproperty (const std::string &name) const
 
Propertyproperty (const std::string &name) const
 

Private Types

typedef std::vector< Property * > Properties
 
typedef std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
 
typedef std::vector< RemPropertyRemoteProperties
 
typedef std::vector< Property * > Properties
 
typedef std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
 
typedef std::vector< RemPropertyRemoteProperties
 

Private Member Functions

Propertyproperty (const std::string &name, const std::vector< Property * > &props) const
 get the property by name form the proposed list More...
 
void assertUniqueName (const std::string &name) const
 Throw an exception if the name is already present in the list of properties (see GAUDI-1023). More...
 
Propertyproperty (const std::string &name, const std::vector< Property * > &props) const
 get the property by name form the proposed list More...
 
void assertUniqueName (const std::string &name) const
 Throw an exception 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...
 
Properties m_todelete
 Properties to be deleted. More...
 
std::vector< bool > m_isOwned
 Flag to decide to delete or not a propertyRef. More...
 
IInterfacem_pOuter
 Interface hub reference (ApplicationMgr) More...
 

Additional Inherited Members

- Public Types inherited from implements1< IProperty >
typedef implements1 base_class
 Typedef to this class. More...
 
typedef implements1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1< IPropertyextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces1< IPropertyextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces1< IProperty >
typedef IProperty::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef IProperty::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 

Detailed Description

Property manager helper class.

This class is used by algorithms and services for helping to manage its own set of properties. It implements the IProperty interface.

Author
Paul Maley
David Quarrie

Definition at line 34 of file PropertyMgr.h.

Member Typedef Documentation

typedef std::vector<Property*> PropertyMgr::Properties
private

Definition at line 158 of file PropertyMgr.h.

typedef std::vector<Property*> PropertyMgr::Properties
private

Definition at line 158 of file PropertyMgr.h.

typedef std::vector<RemProperty> PropertyMgr::RemoteProperties
private

Definition at line 161 of file PropertyMgr.h.

typedef std::vector<RemProperty> PropertyMgr::RemoteProperties
private

Definition at line 161 of file PropertyMgr.h.

typedef std::pair<std::string, std::pair<IProperty*, std::string> > PropertyMgr::RemProperty
private

Definition at line 160 of file PropertyMgr.h.

typedef std::pair<std::string, std::pair<IProperty*, std::string> > PropertyMgr::RemProperty
private

Definition at line 160 of file PropertyMgr.h.

Constructor & Destructor Documentation

PropertyMgr::PropertyMgr ( IInterface iface = 0)

constructor from the interface

Definition at line 54 of file PropertyMgr.cpp.

55  : m_properties ()
57  , m_todelete ()
58  , m_pOuter ( iface )
59 {
60  addRef(); // initial reference count set to 1
61 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:174
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:168
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
PropertyMgr::PropertyMgr ( const PropertyMgr right)

Definition at line 65 of file PropertyMgr.cpp.

66  : IInterface(right),
67  IProperty(right),
69  base_class(right)
70  , m_properties ( right.m_properties )
72  , m_todelete ( right.m_todelete )
73  , m_pOuter ( right.m_pOuter )
74 {
75  addRef(); // initial reference count set to 1
76  std::transform
77  ( m_todelete.begin() , m_todelete.end () ,
78  m_todelete.begin() , std::mem_fun(&Property::clone));
79 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:174
extend_interfaces1< IProperty > extend_interfaces_base
Typedef to the base of this class.
Definition: implements.h:137
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:168
Definition of the basic interface.
Definition: IInterface.h:160
implements1 base_class
Typedef to this class.
Definition: implements.h:135
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:22
virtual Property * clone() const =0
clone: "virtual constructor"
PropertyMgr::~PropertyMgr ( )
virtual

virtual destructor

delete all owned properties

Definition at line 83 of file PropertyMgr.cpp.

84 {
86  for ( Properties::iterator ip = m_todelete.begin() ;
87  m_todelete.end() != ip ; ++ip ) { delete *ip ; }
88 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
PropertyMgr::PropertyMgr ( IInterface iface = 0)

constructor from the interface

PropertyMgr::PropertyMgr ( const PropertyMgr )
virtual PropertyMgr::~PropertyMgr ( )
virtual

virtual destructor

Member Function Documentation

void PropertyMgr::assertUniqueName ( const std::string &  name) const
private

Throw an exception if the name is already present in the list of properties (see GAUDI-1023).

Definition at line 270 of file PropertyMgr.cpp.

270  {
271  if (UNLIKELY(hasProperty(name))) {
272  // TODO: queryInterface should be const
273  // Note: using SmartIF causes a segfault in genconf (wrong ref. count)
274  INamedInterface* owner = nullptr;
275  std::string ownerName{"PropertyMgr"};
276  if (m_pOuter &&
277  const_cast<IInterface*>(m_pOuter)->queryInterface(INamedInterface::interfaceID(), (void**)&owner).isSuccess()) {
278  ownerName = owner->name();
279  }
280  auto msgSvc = Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc");
281  MsgStream log(msgSvc, ownerName);
282  log << MSG::WARNING
283  << "duplicated property name '" << name
284  << "', see https://its.cern.ch/jira/browse/GAUDI-1023"<< endmsg;
285  }
286 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool hasProperty(const std::string &name) const
Return true if we have a property with the given name.
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:174
StatusCode queryInterface(const InterfaceID &iid, void **pinterface)
Set the void** to the pointer to the requested interface of the instance.
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:82
GAUDI_API ISvcLocator * svcLocator()
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
IInterface compliant class extending IInterface with the name() method.
#define UNLIKELY(x)
Definition: Kernel.h:127
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:171
void PropertyMgr::assertUniqueName ( const std::string &  name) const
private

Throw an exception if the name is already present in the list of properties (see GAUDI-1023).

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
TYPE &  value,
const std::string &  doc = "none" 
)
inline

Declare a property (templated)

Definition at line 182 of file PropertyMgr.h.

185 {
186  assertUniqueName(name);
187  Property* p = new SimplePropertyRef<TYPE> ( name , value ) ;
188  //
189  p->setDocumentation( doc );
190  m_properties .push_back( p ) ;
191  m_todelete .push_back( p ) ;
192  //
193  return p ;
194 }
SimplePropertyRef templated class.
Definition: HistoProperty.h:16
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
void setDocumentation(const std::string &documentation)
set the documentation string
Definition: Property.h:92
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
TYPE &  value,
const std::string &  doc = "none" 
)

Declare a property (templated)

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
SimpleProperty< TYPE > &  prop,
const std::string &  doc = "none" 
)
inline

Declare a property (specialization)

Declare a property (templated)

Definition at line 201 of file PropertyMgr.h.

204 {
205  assertUniqueName(name);
206  Property* p = &prop ;
207  //
208  p -> setName ( name ) ;
209  p -> setDocumentation ( doc ) ;
210  m_properties.push_back ( p ) ;
211  //
212  return p ;
213 }
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
SimpleProperty< TYPE > &  prop,
const std::string &  doc = "none" 
)

Declare a property (specialization)

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
SimplePropertyRef< TYPE > &  prop,
const std::string &  doc = "none" 
)
inline

Declare a property (specialization)

Declare a property (templated)

Definition at line 220 of file PropertyMgr.h.

223 {
224  assertUniqueName(name);
225  Property* p = &prop ;
226  //
227  p -> setName ( name ) ;
228  p -> setDocumentation ( doc ) ;
229  m_properties.push_back ( p ) ;
230  //
231  return p ;
232 }
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
SimplePropertyRef< TYPE > &  prop,
const std::string &  doc = "none" 
)

Declare a property (specialization)

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
ToolHandle< TYPE > &  ref,
const std::string &  doc = "none" 
)
inline

Declare a property (specialization)

Definition at line 239 of file PropertyMgr.h.

242 {
243  assertUniqueName(name);
244  Property* p = new GaudiHandleProperty( name, ref );
245  //
246  p -> setDocumentation ( doc ) ;
247  m_properties . push_back ( p ) ;
248  m_todelete . push_back ( p ) ;
249  //
250  return p ;
251 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
ToolHandle< TYPE > &  ref,
const std::string &  doc = "none" 
)

Declare a property (specialization)

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
ServiceHandle< TYPE > &  ref,
const std::string &  doc = "none" 
)
inline

Declare a property (specialization)

Definition at line 256 of file PropertyMgr.h.

259 {
260  assertUniqueName(name);
261  Property* p = new GaudiHandleProperty( name, ref );
262  //
263  p -> setDocumentation ( doc ) ;
264  m_properties . push_back ( p ) ;
265  m_todelete . push_back ( p ) ;
266  //
267  return p ;
268 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
ServiceHandle< TYPE > &  ref,
const std::string &  doc = "none" 
)

Declare a property (specialization)

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
ToolHandleArray< TYPE > &  ref,
const std::string &  doc = "none" 
)
inline

Declare a property (specialization)

Definition at line 273 of file PropertyMgr.h.

276 {
277  assertUniqueName(name);
278  Property* p = new GaudiHandleArrayProperty( name, ref );
279  //
280  p -> setDocumentation ( doc ) ;
281  m_properties . push_back ( p ) ;
282  m_todelete . push_back ( p ) ;
283  //
284  return p ;
285 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
ToolHandleArray< TYPE > &  ref,
const std::string &  doc = "none" 
)

Declare a property (specialization)

template<class TYPE >
Property * PropertyMgr::declareProperty ( const std::string &  name,
ServiceHandleArray< TYPE > &  ref,
const std::string &  doc = "none" 
)
inline

Declare a property (specialization)

Definition at line 290 of file PropertyMgr.h.

293 {
294  assertUniqueName(name);
295  Property* p = new GaudiHandleArrayProperty( name, ref );
296  //
297  p -> setDocumentation ( doc ) ;
298  m_properties . push_back ( p ) ;
299  m_todelete . push_back ( p ) ;
300  //
301  return p ;
302 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
template<class TYPE >
Property* PropertyMgr::declareProperty ( const std::string &  name,
ServiceHandleArray< TYPE > &  ref,
const std::string &  doc = "none" 
)

Declare a property (specialization)

Property * PropertyMgr::declareRemoteProperty ( const std::string &  name,
IProperty rsvc,
const std::string &  rname = "" 
)

Declare a remote property.

Definition at line 114 of file PropertyMgr.cpp.

117 {
118  if ( 0 == rsvc ) { return 0 ; }
119  const std::string& nam = rname.empty() ? name : rname ;
120  Property* p = property ( nam , rsvc->getProperties() ) ;
121  m_remoteProperties.push_back ( RemProperty ( name , std::make_pair ( rsvc , nam ) ) ) ;
122  return p ;
123 }
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:168
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:160
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * property(const std::string &name) const
Property* PropertyMgr::declareRemoteProperty ( const std::string &  name,
IProperty rsvc,
const std::string &  rname = "" 
)

Declare a remote property.

const std::vector< Property * > & PropertyMgr::getProperties ( ) const
virtual

get all properties

See also
IProperty

Implements IProperty.

Definition at line 249 of file PropertyMgr.cpp.

249 { return m_properties; }
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
const std::vector<Property*>& PropertyMgr::getProperties ( ) const
virtual

get all properties

See also
IProperty

Implements IProperty.

StatusCode PropertyMgr::getProperty ( Property p) const
virtual

get the property

See also
IProperty

Implements IProperty.

StatusCode PropertyMgr::getProperty ( Property p) const
virtual

get the property

See also
IProperty

Implements IProperty.

Definition at line 205 of file PropertyMgr.cpp.

206 {
207  try
208  {
209  const Property* pp = property( p->name() ) ;
210  if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN
211  if ( !pp->load( *p ) ) { return StatusCode::FAILURE ; } // RETURN
212  }
213  catch ( ... ) { return StatusCode::FAILURE; } // RETURN
214  return StatusCode::SUCCESS ; // RETURN
215 }
const std::string & name() const
property name
Definition: Property.h:47
virtual bool load(Property &dest) const =0
export the property value to the destination
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * property(const std::string &name) const
const Property& PropertyMgr::getProperty ( const std::string &  name) const
virtual

get the property by name

See also
IProperty

Implements IProperty.

const Property & PropertyMgr::getProperty ( const std::string &  name) const
virtual

get the property by name

See also
IProperty

Implements IProperty.

Definition at line 221 of file PropertyMgr.cpp.

222 {
223  const Property* p = property( name ) ;
224  if ( 0 != p ) { return *p ; } // RETURN
225  //
226  throw std::out_of_range( "Property "+name+" not found." ); // Not found
227 }
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * property(const std::string &name) const
StatusCode PropertyMgr::getProperty ( const std::string &  n,
std::string &  v 
) const
virtual

convert the property to the string

See also
IProperty

Implements IProperty.

StatusCode PropertyMgr::getProperty ( const std::string &  n,
std::string &  v 
) const
virtual

convert the property to the string

See also
IProperty

Implements IProperty.

Definition at line 234 of file PropertyMgr.cpp.

236 {
237  // get the property
238  const Property* p = property( n ) ;
239  if ( 0 == p ) { return StatusCode::FAILURE ; }
240  // convert the value into the string
241  v = p->toString() ;
242  //
243  return StatusCode::SUCCESS ;
244 }
virtual std::string toString() const =0
value -> string
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * property(const std::string &name) const
bool PropertyMgr::hasProperty ( const std::string &  name) const
virtual

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

See also
IProperty

Implements IProperty.

bool PropertyMgr::hasProperty ( const std::string &  name) const
virtual

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

See also
IProperty

Implements IProperty.

Definition at line 264 of file PropertyMgr.cpp.

264  {
265  return any_of(begin(m_properties), end(m_properties),
266  [&name](Property* prop) {
267  return Nocase()(prop->name(), name);
268  });
269 }
const std::string & name() const
property name
Definition: Property.h:47
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
tuple end
Definition: IOTest.py:101
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
PropertyMgr & PropertyMgr::operator= ( const PropertyMgr right)

Definition at line 92 of file PropertyMgr.cpp.

93 {
94  if ( &right == this ) { return *this ; }
95  //
96  for ( Properties::iterator ip = m_todelete.begin() ;
97  m_todelete.end() != ip ; ++ip ) { delete *ip ; }
98  //
99  m_properties = right.m_properties ;
101  m_todelete = right.m_todelete ;
102  m_pOuter = right.m_pOuter ;
103  //
104  std::transform
105  ( m_todelete.begin() , m_todelete.end () ,
106  m_todelete.begin() , std::mem_fun(&Property::clone));
107  //
108  return *this ;
109 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:170
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:174
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:168
virtual Property * clone() const =0
clone: "virtual constructor"
PropertyMgr& PropertyMgr::operator= ( const PropertyMgr )
Property * PropertyMgr::property ( const std::string &  name) const
protected

Definition at line 140 of file PropertyMgr.cpp.

141 {
142  // local property ?
143  Property* lp = property ( name , m_properties ) ;
144  if ( 0 != lp ) { return lp ; } // RETURN
145  // look for remote property
146  Nocase cmp ;
147  for ( RemoteProperties::const_iterator it = m_remoteProperties.begin() ;
148  m_remoteProperties.end() != it ; ++it )
149  {
150  if ( !cmp(it->first,name) ) { continue ; } // CONTINUE
151  const IProperty* p = it->second.first ;
152  if ( 0 == p ) { continue ; } // CONITNUE
153  return property ( it->second.second , p->getProperties() ) ; // RETURN
154  }
155  return 0 ; // RETURN
156 }
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:166
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:168
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:22
Property * property(const std::string &name) const
Property* PropertyMgr::property ( const std::string &  name) const
protected
Property * PropertyMgr::property ( const std::string &  name,
const std::vector< Property * > &  props 
) const
private

get the property by name form the proposed list

Definition at line 128 of file PropertyMgr.cpp.

130 {
131  Properties::const_iterator it =
132  std::find_if ( props.begin() , props.end() , PropByName( name ) ) ;
133  if ( props.end() != it ) { return *it ; } // RETURN
134  return 0 ; // RETURN
135 }
Property* PropertyMgr::property ( const std::string &  name,
const std::vector< Property * > &  props 
) const
private

get the property by name form the proposed list

StatusCode PropertyMgr::queryInterface ( const InterfaceID ti,
void **  pp 
)
virtual

Set the void** to the pointer to the requested interface of the instance.

Implements IInterface.

StatusCode PropertyMgr::queryInterface ( const InterfaceID ti,
void **  pp 
)
virtual

Set the void** to the pointer to the requested interface of the instance.

Implements IInterface.

Definition at line 253 of file PropertyMgr.cpp.

253  {
254  // try local interfaces
255  StatusCode sc= base_class::queryInterface(iid, pinterface);
256  if (sc.isSuccess()) return sc;
257  // fall back on the owner
258  return (0 != m_pOuter)? m_pOuter->queryInterface(iid, pinterface)
259  : sc; // FAILURE
260 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:174
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:164
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
StatusCode PropertyMgr::setProperty ( const Property p)
virtual

set the property form another property

See also
IProperty

Implements IProperty.

StatusCode PropertyMgr::setProperty ( const Property p)
virtual

set the property form another property

See also
IProperty

Implements IProperty.

Definition at line 162 of file PropertyMgr.cpp.

163 {
164  Property* pp = property( p.name() ) ;
165  if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN
166  //
167  try
168  { if ( !pp->assign(p) ) { return StatusCode::FAILURE ; } } // RETURN
169  catch(...) { return StatusCode::FAILURE ; } // RETURN
170  //
171  return StatusCode::SUCCESS; // Property value set
172 }
virtual bool assign(const Property &source)=0
import the property value form the source
const std::string & name() const
property name
Definition: Property.h:47
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * property(const std::string &name) const
StatusCode PropertyMgr::setProperty ( const std::string &  s)
virtual

set the property from the property formatted string

See also
IProperty

Implements IProperty.

Definition at line 179 of file PropertyMgr.cpp.

180 {
181  std::string name ;
182  std::string value ;
183  StatusCode sc = Gaudi::Parsers::parse( name , value , i ) ;
184  if ( sc.isFailure() ) { return sc ; }
185  return setProperty ( name , value ) ;
186 }
StatusCode setProperty(const Property &p)
set the property form another property
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
list i
Definition: ana.py:128
StatusCode PropertyMgr::setProperty ( const std::string &  s)
virtual

set the property from the property formatted string

See also
IProperty

Implements IProperty.

StatusCode PropertyMgr::setProperty ( const std::string &  n,
const std::string &  v 
)
virtual

set the property from name and the value

See also
IProperty

Implements IProperty.

Definition at line 193 of file PropertyMgr.cpp.

194 {
195  Property* p = property( n ) ;
196  if ( 0 == p ) { return StatusCode::FAILURE ; } // RETURN
197  bool result = p->fromString( v ) != 0 ;
198  return result ? StatusCode::SUCCESS : StatusCode::FAILURE ;
199 }
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * property(const std::string &name) const
virtual StatusCode fromString(const std::string &value)=0
string -> value
StatusCode PropertyMgr::setProperty ( const std::string &  n,
const std::string &  v 
)
virtual

set the property from name and the value

See also
IProperty

Implements IProperty.

Member Data Documentation

std::vector< bool > PropertyMgr::m_isOwned
private

Flag to decide to delete or not a propertyRef.

Definition at line 172 of file PropertyMgr.h.

IInterface * PropertyMgr::m_pOuter
private

Interface hub reference (ApplicationMgr)

Definition at line 174 of file PropertyMgr.h.

Properties PropertyMgr::m_properties
private

Collection of all declared properties.

Definition at line 166 of file PropertyMgr.h.

RemoteProperties PropertyMgr::m_remoteProperties
private

Collection of all declared remote properties.

Definition at line 168 of file PropertyMgr.h.

Properties PropertyMgr::m_todelete
private

Properties to be deleted.

Definition at line 170 of file PropertyMgr.h.


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