All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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...
 
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...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 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...
 

Protected Member Functions

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
 

Private Member Functions

Propertyproperty (const std::string &name, const std::vector< Property * > &props) const
 get the property by name form the proposed list 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 extend_interfaces1
< IProperty
extend_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...
 
- Public Types inherited from extend_interfaces1< IProperty >
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 }
 Return status. 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...
 

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 38 of file PropertyMgr.h.

Member Typedef Documentation

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

Definition at line 153 of file PropertyMgr.h.

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

Definition at line 156 of file PropertyMgr.h.

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

Definition at line 155 of file PropertyMgr.h.

Constructor & Destructor Documentation

PropertyMgr::PropertyMgr ( IInterface iface = 0)

constructor from the interface

Definition at line 52 of file PropertyMgr.cpp.

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

Definition at line 63 of file PropertyMgr.cpp.

64  : IInterface(right),
65  IProperty(right),
67  base_class(right)
68  , m_properties ( right.m_properties )
70  , m_todelete ( right.m_todelete )
71  , m_pOuter ( right.m_pOuter )
72 {
73  addRef(); // initial reference count set to 1
74  std::transform
75  ( m_todelete.begin() , m_todelete.end () ,
76  m_todelete.begin() , std::mem_fun(&Property::clone));
77 }
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:169
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165
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:161
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:163
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 81 of file PropertyMgr.cpp.

82 {
84  for ( Properties::iterator ip = m_todelete.begin() ;
85  m_todelete.end() != ip ; ++ip ) { delete *ip ; }
86 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165

Member Function Documentation

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 177 of file PropertyMgr.h.

180 {
181  Property* p = new SimplePropertyRef<TYPE> ( name , value ) ;
182  //
183  p->setDocumentation( doc );
184  m_properties .push_back( p ) ;
185  m_todelete .push_back( p ) ;
186  //
187  return p ;
188 }
SimplePropertyRef templated class.
Definition: HistoProperty.h:16
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
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
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 195 of file PropertyMgr.h.

198 {
199  Property* p = &prop ;
200  //
201  p -> setName ( name ) ;
202  p -> setDocumentation ( doc ) ;
203  m_properties.push_back ( p ) ;
204  //
205  return p ;
206 }
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
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 213 of file PropertyMgr.h.

216 {
217  Property* p = &prop ;
218  //
219  p -> setName ( name ) ;
220  p -> setDocumentation ( doc ) ;
221  m_properties.push_back ( p ) ;
222  //
223  return p ;
224 }
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
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 231 of file PropertyMgr.h.

234 {
235  Property* p = new GaudiHandleProperty( name, ref );
236  //
237  p -> setDocumentation ( doc ) ;
238  m_properties . push_back ( p ) ;
239  m_todelete . push_back ( p ) ;
240  //
241  return p ;
242 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
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 247 of file PropertyMgr.h.

250 {
251  Property* p = new GaudiHandleProperty( name, ref );
252  //
253  p -> setDocumentation ( doc ) ;
254  m_properties . push_back ( p ) ;
255  m_todelete . push_back ( p ) ;
256  //
257  return p ;
258 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
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 263 of file PropertyMgr.h.

266 {
267  Property* p = new GaudiHandleArrayProperty( name, ref );
268  //
269  p -> setDocumentation ( doc ) ;
270  m_properties . push_back ( p ) ;
271  m_todelete . push_back ( p ) ;
272  //
273  return p ;
274 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
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 279 of file PropertyMgr.h.

282 {
283  Property* p = new GaudiHandleArrayProperty( name, ref );
284  //
285  p -> setDocumentation ( doc ) ;
286  m_properties . push_back ( p ) ;
287  m_todelete . push_back ( p ) ;
288  //
289  return p ;
290 }
Properties m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:165
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Property * PropertyMgr::declareRemoteProperty ( const std::string &  name,
IProperty rsvc,
const std::string &  rname = "" 
)

Declare a remote property.

Definition at line 112 of file PropertyMgr.cpp.

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

get all properties

See also
IProperty

Implements IProperty.

Definition at line 247 of file PropertyMgr.cpp.

247 { return m_properties; }
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
StatusCode PropertyMgr::getProperty ( Property p) const
virtual

get the property

See also
IProperty

Implements IProperty.

Definition at line 203 of file PropertyMgr.cpp.

204 {
205  try
206  {
207  const Property* pp = property( p->name() ) ;
208  if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN
209  if ( !pp->load( *p ) ) { return StatusCode::FAILURE ; } // RETURN
210  }
211  catch ( ... ) { return StatusCode::FAILURE; } // RETURN
212  return StatusCode::SUCCESS ; // RETURN
213 }
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.

Definition at line 219 of file PropertyMgr.cpp.

220 {
221  const Property* p = property( name ) ;
222  if ( 0 != p ) { return *p ; } // RETURN
223  //
224  throw std::out_of_range( "Property "+name+" not found." ); // Not found
225 }
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.

Definition at line 232 of file PropertyMgr.cpp.

234 {
235  // get the property
236  const Property* p = property( n ) ;
237  if ( 0 == p ) { return StatusCode::FAILURE ; }
238  // convert the value into the string
239  v = p->toString() ;
240  //
241  return StatusCode::SUCCESS ;
242 }
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
PropertyMgr & PropertyMgr::operator= ( const PropertyMgr right)

Definition at line 90 of file PropertyMgr.cpp.

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

Definition at line 138 of file PropertyMgr.cpp.

139 {
140  // local property ?
141  Property* lp = property ( name , m_properties ) ;
142  if ( 0 != lp ) { return lp ; } // RETURN
143  // look for remote property
144  Nocase cmp ;
145  for ( RemoteProperties::const_iterator it = m_remoteProperties.begin() ;
146  m_remoteProperties.end() != it ; ++it )
147  {
148  if ( !cmp(it->first,name) ) { continue ; } // CONTINUE
149  const IProperty* p = it->second.first ;
150  if ( 0 == p ) { continue ; } // CONITNUE
151  return property ( it->second.second , p->getProperties() ) ; // RETURN
152  }
153  return 0 ; // RETURN
154 }
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:161
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:163
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 std::vector< Property * > &  props 
) const
private

get the property by name form the proposed list

Definition at line 126 of file PropertyMgr.cpp.

128 {
129  Properties::const_iterator it =
130  std::find_if ( props.begin() , props.end() , PropByName( name ) ) ;
131  if ( props.end() != it ) { return *it ; } // RETURN
132  return 0 ; // RETURN
133 }
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 251 of file PropertyMgr.cpp.

251  {
252  // try local interfaces
253  StatusCode sc= base_class::queryInterface(iid, pinterface);
254  if (sc.isSuccess()) return sc;
255  // fall back on the owner
256  return (0 != m_pOuter)? m_pOuter->queryInterface(iid, pinterface)
257  : sc; // FAILURE
258 }
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:169
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
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.

Definition at line 160 of file PropertyMgr.cpp.

161 {
162  Property* pp = property( p.name() ) ;
163  if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN
164  //
165  try
166  { if ( !pp->assign(p) ) { return StatusCode::FAILURE ; } } // RETURN
167  catch(...) { return StatusCode::FAILURE ; } // RETURN
168  //
169  return StatusCode::SUCCESS; // Property value set
170 }
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 177 of file PropertyMgr.cpp.

178 {
179  std::string name ;
180  std::string value ;
181  StatusCode sc = Gaudi::Parsers::parse( name , value , i ) ;
182  if ( sc.isFailure() ) { return sc ; }
183  return setProperty ( name , value ) ;
184 }
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:72
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 &  n,
const std::string &  v 
)
virtual

set the property from name and the value

See also
IProperty

Implements IProperty.

Definition at line 191 of file PropertyMgr.cpp.

192 {
193  Property* p = property( n ) ;
194  if ( 0 == p ) { return StatusCode::FAILURE ; } // RETURN
195  bool result = p->fromString( v ) != 0 ;
196  return result ? StatusCode::SUCCESS : StatusCode::FAILURE ;
197 }
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

Member Data Documentation

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

Flag to decide to delete or not a propertyRef.

Definition at line 167 of file PropertyMgr.h.

IInterface* PropertyMgr::m_pOuter
private

Interface hub reference (ApplicationMgr)

Definition at line 169 of file PropertyMgr.h.

Properties PropertyMgr::m_properties
private

Collection of all declared properties.

Definition at line 161 of file PropertyMgr.h.

RemoteProperties PropertyMgr::m_remoteProperties
private

Collection of all declared remote properties.

Definition at line 163 of file PropertyMgr.h.

Properties PropertyMgr::m_todelete
private

Properties to be deleted.

Definition at line 165 of file PropertyMgr.h.


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