Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PropertyMgr Class Reference

Property manager helper class. More...

#include <GaudiKernel/PropertyMgr.h>

Inheritance diagram for PropertyMgr:
Inheritance graph
[legend]
Collaboration diagram for PropertyMgr:
Collaboration graph
[legend]

Public Member Functions

 PropertyMgr (IInterface *iface=0)
 constructor from the interface
 
 PropertyMgr (const PropertyMgr &)
 
virtual ~PropertyMgr ()
 virtual destructor
 
PropertyMgroperator= (const PropertyMgr &)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Declare a property (templated)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, SimpleProperty< TYPE > &prop, const std::string &doc="none")
 Declare a property (specialization)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, SimplePropertyRef< TYPE > &prop, const std::string &doc="none")
 Declare a property (specialization)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ToolHandle< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ServiceHandle< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ToolHandleArray< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization)
 
template<class TYPE >
PropertydeclareProperty (const std::string &name, ServiceHandleArray< TYPE > &ref, const std::string &doc="none")
 Declare a property (specialization)
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const Property &p)
 set the property form another property
 
StatusCode setProperty (const std::string &s)
 set the property from the property formatted string
 
StatusCode setProperty (const std::string &n, const std::string &v)
 set the property from name and the value
 
StatusCode getProperty (Property *p) const
 get the property
 
const PropertygetProperty (const std::string &name) const
 get the property by name
 
StatusCode getProperty (const std::string &n, std::string &v) const
 convert the property to the string
 
const std::vector< Property * > & getProperties () const
 get all properties
 
StatusCode queryInterface (const InterfaceID &iid, void **pinterface)
 Set the void** to the pointer to the requested interface of the instance.
 

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
 

Private Attributes

Properties m_properties
 Collection of all declared properties.
 
RemoteProperties m_remoteProperties
 Collection of all declared remote properties.
 
Properties m_todelete
 Properties to be deleted.
 
std::vector< bool > m_isOwned
 Flag to decide to delete or not a propertyRef.
 
IInterfacem_pOuter
 Interface hub reference (ApplicationMgr)
 

Additional Inherited Members

- Public Types inherited from implements1< IProperty >
typedef implements1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IProperty
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 

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

Definition at line 153 of file PropertyMgr.h.

Definition at line 156 of file PropertyMgr.h.

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.

, m_pOuter ( iface )
{
addRef(); // initial reference count set to 1
}
PropertyMgr::PropertyMgr ( const PropertyMgr right)

Definition at line 63 of file PropertyMgr.cpp.

: IInterface(right),
IProperty(right),
base_class(right)
, m_todelete ( right.m_todelete )
, m_pOuter ( right.m_pOuter )
{
addRef(); // initial reference count set to 1
}
PropertyMgr::~PropertyMgr ( )
virtual

virtual destructor

delete all owned properties

Definition at line 81 of file PropertyMgr.cpp.

{
m_todelete.end() != ip ; ++ip ) { delete *ip ; }
}

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.

{
Property* p = new SimplePropertyRef<TYPE> ( name , value ) ;
//
p->setDocumentation( doc );
//
return p ;
}
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.

{
Property* p = &prop ;
//
p -> setName ( name ) ;
p -> setDocumentation ( doc ) ;
//
return p ;
}
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.

{
Property* p = &prop ;
//
p -> setName ( name ) ;
p -> setDocumentation ( doc ) ;
//
return p ;
}
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.

{
Property* p = new GaudiHandleProperty( name, ref );
//
p -> setDocumentation ( doc ) ;
m_properties . push_back ( p ) ;
m_todelete . push_back ( p ) ;
//
return p ;
}
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.

{
Property* p = new GaudiHandleProperty( name, ref );
//
p -> setDocumentation ( doc ) ;
m_properties . push_back ( p ) ;
m_todelete . push_back ( p ) ;
//
return p ;
}
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.

{
Property* p = new GaudiHandleArrayProperty( name, ref );
//
p -> setDocumentation ( doc ) ;
m_properties . push_back ( p ) ;
m_todelete . push_back ( p ) ;
//
return p ;
}
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.

{
Property* p = new GaudiHandleArrayProperty( name, ref );
//
p -> setDocumentation ( doc ) ;
m_properties . push_back ( p ) ;
m_todelete . push_back ( p ) ;
//
return p ;
}
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.

{
if ( 0 == rsvc ) { return 0 ; }
const std::string& nam = rname.empty() ? name : rname ;
Property* p = property ( nam , rsvc->getProperties() ) ;
m_remoteProperties.push_back ( RemProperty ( name , std::make_pair ( rsvc , nam ) ) ) ;
return p ;
}
const std::vector< Property * > & PropertyMgr::getProperties ( ) const
virtual

get all properties

See Also
IProperty

Implements IProperty.

Definition at line 247 of file PropertyMgr.cpp.

{ return m_properties; }
StatusCode PropertyMgr::getProperty ( Property p) const
virtual

get the property

See Also
IProperty

Implements IProperty.

Definition at line 203 of file PropertyMgr.cpp.

{
try
{
const Property* pp = property( p->name() ) ;
if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN
if ( !pp->load( *p ) ) { return StatusCode::FAILURE ; } // RETURN
}
catch ( ... ) { return StatusCode::FAILURE; } // RETURN
return StatusCode::SUCCESS ; // RETURN
}
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.

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

{
// get the property
const Property* p = property( n ) ;
if ( 0 == p ) { return StatusCode::FAILURE ; }
// convert the value into the string
v = p->toString() ;
//
}
PropertyMgr & PropertyMgr::operator= ( const PropertyMgr right)

Definition at line 90 of file PropertyMgr.cpp.

{
if ( &right == this ) { return *this ; }
//
m_todelete.end() != ip ; ++ip ) { delete *ip ; }
//
m_pOuter = right.m_pOuter ;
//
//
return *this ;
}
Property * PropertyMgr::property ( const std::string name) const
protected

Definition at line 138 of file PropertyMgr.cpp.

{
// local property ?
Property* lp = property ( name , m_properties ) ;
if ( 0 != lp ) { return lp ; } // RETURN
// look for remote property
Nocase cmp ;
m_remoteProperties.end() != it ; ++it )
{
if ( !cmp(it->first,name) ) { continue ; } // CONTINUE
const IProperty* p = it->second.first ;
if ( 0 == p ) { continue ; } // CONITNUE
return property ( it->second.second , p->getProperties() ) ; // RETURN
}
return 0 ; // RETURN
}
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.

{
std::find_if ( props.begin() , props.end() , PropByName( name ) ) ;
if ( props.end() != it ) { return *it ; } // RETURN
return 0 ; // RETURN
}
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.

{
// try local interfaces
StatusCode sc= base_class::queryInterface(iid, pinterface);
if (sc.isSuccess()) return sc;
// fall back on the owner
return (0 != m_pOuter)? m_pOuter->queryInterface(iid, pinterface)
: sc; // FAILURE
}
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.

{
Property* pp = property( p.name() ) ;
if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN
//
try
{ if ( !pp->assign(p) ) { return StatusCode::FAILURE ; } } // RETURN
catch(...) { return StatusCode::FAILURE ; } // RETURN
//
return StatusCode::SUCCESS; // Property value set
}
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.

{
std::string name ;
std::string value ;
StatusCode sc = Gaudi::Parsers::parse( name , value , i ) ;
if ( sc.isFailure() ) { return sc ; }
return setProperty ( name , 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.

Definition at line 191 of file PropertyMgr.cpp.

{
Property* p = property( n ) ;
if ( 0 == p ) { return StatusCode::FAILURE ; } // RETURN
bool result = p->fromString( v ) != 0 ;
}

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:

Generated at Mon Feb 17 2014 14:38:09 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004