![]() |
|
|
Generated: 8 Jan 2009 |
#include <GaudiKernel/PropertyMgr.h>


This class is used by algorithms and services for helping to manage its own set of properties. It implements the IProperty interface.
Definition at line 37 of file PropertyMgr.h.
Public Member Functions | |
| PropertyMgr (IInterface *iface=0) | |
| contructor from the interface | |
| PropertyMgr (const PropertyMgr &) | |
| virtual | ~PropertyMgr () |
| virtual destructor | |
| PropertyMgr & | operator= (const PropertyMgr &) |
| template<class TYPE> | |
| Property * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") |
| Declare a property (templated). | |
| template<class TYPE> | |
| Property * | declareProperty (const std::string &name, SimpleProperty< TYPE > &prop, const std::string &doc="none") |
| Declare a property (specialization). | |
| template<class TYPE> | |
| Property * | declareProperty (const std::string &name, SimplePropertyRef< TYPE > &prop, const std::string &doc="none") |
| Declare a property (specialization). | |
| template<class TYPE> | |
| Property * | declareProperty (const std::string &name, ToolHandle< TYPE > &ref, const std::string &doc="none") |
| Declare a property (specialization). | |
| template<class TYPE> | |
| Property * | declareProperty (const std::string &name, ServiceHandle< TYPE > &ref, const std::string &doc="none") |
| Declare a property (specialization). | |
| template<class TYPE> | |
| Property * | declareProperty (const std::string &name, ToolHandleArray< TYPE > &ref, const std::string &doc="none") |
| Declare a property (specialization). | |
| Property * | declareRemoteProperty (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 the property fomr name and the value | |
| StatusCode | getProperty (Property *p) const |
| get the property | |
| const Property & | getProperty (const std::string &name) const |
| get the propery 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 &riid, void **ppvInterface) |
| Query interfaces of Interface. | |
| unsigned long | addRef () |
| Increment the reference count of Interface instance. | |
| unsigned long | release () |
| Release Interface instance. | |
Protected Member Functions | |
| Property * | property (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< RemProperty > | RemoteProperties |
Private Member Functions | |
| Property * | property (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. | |
| IInterface * | m_pOuter |
| Interface hub reference (ApplicationMgr). | |
| unsigned long | m_refcount |
| Reference counter. | |
typedef std::vector<Property*> PropertyMgr::Properties [private] |
Definition at line 148 of file PropertyMgr.h.
typedef std::pair<std::string, std::pair<IProperty*, std::string> > PropertyMgr::RemProperty [private] |
Definition at line 150 of file PropertyMgr.h.
typedef std::vector<RemProperty> PropertyMgr::RemoteProperties [private] |
Definition at line 151 of file PropertyMgr.h.
| PropertyMgr::PropertyMgr | ( | IInterface * | iface = 0 |
) |
contructor from the interface
Definition at line 52 of file PropertyMgr.cpp.
00053 : m_properties () 00054 , m_remoteProperties () 00055 , m_todelete () 00056 , m_pOuter ( iface ) 00057 , m_refcount ( 1 ) 00058 {}
| PropertyMgr::PropertyMgr | ( | const PropertyMgr & | right | ) |
Definition at line 62 of file PropertyMgr.cpp.
00063 : IInterface(right), IProperty(right) 00064 , m_properties ( right.m_properties ) 00065 , m_remoteProperties ( right.m_remoteProperties ) 00066 , m_todelete ( right.m_todelete ) 00067 , m_pOuter ( right.m_pOuter ) 00068 , m_refcount ( 1 ) 00069 { 00070 std::transform 00071 ( m_todelete.begin() , m_todelete.end () , 00072 m_todelete.begin() , std::mem_fun(&Property::clone)); 00073 }
| PropertyMgr::~PropertyMgr | ( | ) | [virtual] |
virtual destructor
delete all owned properties
Definition at line 77 of file PropertyMgr.cpp.
00078 { 00080 for ( Properties::iterator ip = m_todelete.begin() ; 00081 m_todelete.end() != ip ; ++ip ) { delete *ip ; } 00082 }
| PropertyMgr & PropertyMgr::operator= | ( | const PropertyMgr & | right | ) |
Definition at line 86 of file PropertyMgr.cpp.
00087 { 00088 if ( &right == this ) { return *this ; } 00089 // 00090 for ( Properties::iterator ip = m_todelete.begin() ; 00091 m_todelete.end() != ip ; ++ip ) { delete *ip ; } 00092 // 00093 m_properties = right.m_properties ; 00094 m_remoteProperties = right.m_remoteProperties ; 00095 m_todelete = right.m_todelete ; 00096 m_pOuter = right.m_pOuter ; 00097 // 00098 std::transform 00099 ( m_todelete.begin() , m_todelete.end () , 00100 m_todelete.begin() , std::mem_fun(&Property::clone)); 00101 // 00102 return *this ; 00103 }
| Property * PropertyMgr::declareProperty | ( | const std::string & | name, | |
| TYPE & | value, | |||
| const std::string & | doc = "none" | |||
| ) | [inline] |
Declare a property (templated).
Definition at line 174 of file PropertyMgr.h.
00177 { 00178 Property* p = new SimplePropertyRef<TYPE> ( name , value ) ; 00179 // 00180 p->setDocumentation( doc ); 00181 m_properties .push_back( p ) ; 00182 m_todelete .push_back( p ) ; 00183 // 00184 return p ; 00185 }
| 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 192 of file PropertyMgr.h.
00195 { 00196 Property* p = &prop ; 00197 // 00198 p -> setName ( name ) ; 00199 p -> setDocumentation ( doc ) ; 00200 m_properties.push_back ( p ) ; 00201 // 00202 return p ; 00203 }
| 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 210 of file PropertyMgr.h.
00213 { 00214 Property* p = &prop ; 00215 // 00216 p -> setName ( name ) ; 00217 p -> setDocumentation ( doc ) ; 00218 m_properties.push_back ( p ) ; 00219 // 00220 return p ; 00221 }
| Property * PropertyMgr::declareProperty | ( | const std::string & | name, | |
| ToolHandle< TYPE > & | ref, | |||
| const std::string & | doc = "none" | |||
| ) | [inline] |
Declare a property (specialization).
Definition at line 228 of file PropertyMgr.h.
00231 { 00232 Property* p = new GaudiHandleProperty( name, ref ); 00233 // 00234 p -> setDocumentation ( doc ) ; 00235 m_properties . push_back ( p ) ; 00236 m_todelete . push_back ( p ) ; 00237 // 00238 return p ; 00239 }
| Property * PropertyMgr::declareProperty | ( | const std::string & | name, | |
| ServiceHandle< TYPE > & | ref, | |||
| const std::string & | doc = "none" | |||
| ) | [inline] |
Declare a property (specialization).
Definition at line 244 of file PropertyMgr.h.
00247 { 00248 Property* p = new GaudiHandleProperty( name, ref ); 00249 // 00250 p -> setDocumentation ( doc ) ; 00251 m_properties . push_back ( p ) ; 00252 m_todelete . push_back ( p ) ; 00253 // 00254 return p ; 00255 }
| Property * PropertyMgr::declareProperty | ( | const std::string & | name, | |
| ToolHandleArray< TYPE > & | ref, | |||
| const std::string & | doc = "none" | |||
| ) | [inline] |
Declare a property (specialization).
Definition at line 260 of file PropertyMgr.h.
00263 { 00264 Property* p = new GaudiHandleArrayProperty( name, ref ); 00265 // 00266 p -> setDocumentation ( doc ) ; 00267 m_properties . push_back ( p ) ; 00268 m_todelete . push_back ( p ) ; 00269 // 00270 return p ; 00271 }
| Property * PropertyMgr::declareRemoteProperty | ( | const std::string & | name, | |
| IProperty * | rsvc, | |||
| const std::string & | rname = "" | |||
| ) |
Declare a remote property.
Definition at line 108 of file PropertyMgr.cpp.
00111 { 00112 if ( 0 == rsvc ) { return 0 ; } 00113 const std::string& nam = rname.empty() ? name : rname ; 00114 Property* p = property ( nam , rsvc->getProperties() ) ; 00115 m_remoteProperties.push_back ( RemProperty ( name , std::make_pair ( rsvc , nam ) ) ) ; 00116 return p ; 00117 }
| StatusCode PropertyMgr::setProperty | ( | const Property & | p | ) | [virtual] |
set the property form another property
Implements IProperty.
Definition at line 156 of file PropertyMgr.cpp.
00157 { 00158 Property* pp = property( p.name() ) ; 00159 if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN 00160 // 00161 try 00162 { if ( !pp->assign(p) ) { return StatusCode::FAILURE ; } } // RETURN 00163 catch(...) { return StatusCode::FAILURE ; } // RETURN 00164 // 00165 return StatusCode::SUCCESS; // Property value set 00166 }
| StatusCode PropertyMgr::setProperty | ( | const std::string & | s | ) | [virtual] |
set the property from the property formatted string
Implements IProperty.
Definition at line 173 of file PropertyMgr.cpp.
00174 { 00175 std::string name ; 00176 std::string value ; 00177 StatusCode sc = Gaudi::Parsers::parse( name , value , i ) ; 00178 if ( sc.isFailure() ) { return sc ; } 00179 return setProperty ( name , value ) ; 00180 }
| StatusCode PropertyMgr::setProperty | ( | const std::string & | n, | |
| const std::string & | v | |||
| ) | [virtual] |
set the property from the property fomr name and the value
Implements IProperty.
Definition at line 187 of file PropertyMgr.cpp.
00188 { 00189 Property* p = property( n ) ; 00190 if ( 0 == p ) { return StatusCode::FAILURE ; } // RETURN 00191 bool result = p->fromString( v ) != 0 ; 00192 return result ? StatusCode::SUCCESS : StatusCode::FAILURE ; 00193 }
| StatusCode PropertyMgr::getProperty | ( | Property * | p | ) | const [virtual] |
get the property
Implements IProperty.
Definition at line 199 of file PropertyMgr.cpp.
00200 { 00201 try 00202 { 00203 const Property* pp = property( p->name() ) ; 00204 if ( 0 == pp ) { return StatusCode::FAILURE ; } // RETURN 00205 if ( !pp->load( *p ) ) { return StatusCode::FAILURE ; } // RETURN 00206 } 00207 catch ( ... ) { return StatusCode::FAILURE; } // RETURN 00208 return StatusCode::SUCCESS ; // RETURN 00209 }
| const Property & PropertyMgr::getProperty | ( | const std::string & | name | ) | const [virtual] |
get the propery by name
Implements IProperty.
Definition at line 215 of file PropertyMgr.cpp.
00216 { 00217 const Property* p = property( name ) ; 00218 if ( 0 != p ) { return *p ; } // RETURN 00219 // 00220 throw std::out_of_range( "Property "+name+" not found." ); // Not found 00221 }
| StatusCode PropertyMgr::getProperty | ( | const std::string & | n, | |
| std::string & | v | |||
| ) | const [virtual] |
convert the property to the string
Implements IProperty.
Definition at line 228 of file PropertyMgr.cpp.
00230 { 00231 // get the property 00232 const Property* p = property( n ) ; 00233 if ( 0 == p ) { return StatusCode::FAILURE ; } 00234 // convert the value into the string 00235 v = p->toString() ; 00236 // 00237 return StatusCode::SUCCESS ; 00238 }
| const std::vector< Property * > & PropertyMgr::getProperties | ( | ) | const [virtual] |
get all properties
Implements IProperty.
Definition at line 243 of file PropertyMgr.cpp.
00243 { return m_properties; }
| StatusCode PropertyMgr::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvInterface | |||
| ) | [virtual] |
Query interfaces of Interface.
| riid | ID of Interface to be retrieved | |
| ppvInterface | Pointer to Location for interface pointer |
Implements IInterface.
Definition at line 248 of file PropertyMgr.cpp.
00250 { 00251 // invalid destination 00252 if ( 0 == pinterface ) { return StatusCode::FAILURE ; } 00253 00254 if ( IInterface ::interfaceID () == iid ) 00255 { *pinterface = static_cast<IInterface*> ( this ) ; } 00256 else if ( IProperty ::interfaceID () == iid ) 00257 { *pinterface = static_cast<IProperty*> ( this ) ; } 00258 else if ( 0 != m_pOuter ) // get the interface from the hub 00259 { return m_pOuter->queryInterface(iid, pinterface) ; } // RETURN 00260 else { return StatusCode::FAILURE ; } // RETURN 00261 // 00262 addRef() ; 00263 return StatusCode::SUCCESS ; 00264 }
| unsigned long PropertyMgr::addRef | ( | ) | [virtual] |
Increment the reference count of Interface instance.
Implements IInterface.
Definition at line 268 of file PropertyMgr.cpp.
00268 { return ++m_refcount; }
| unsigned long PropertyMgr::release | ( | ) | [virtual] |
Release Interface instance.
Implements IInterface.
Definition at line 272 of file PropertyMgr.cpp.
00273 { 00274 unsigned long count = --m_refcount; 00275 if ( 0 == count ) { delete this; } 00276 return count; 00277 }
| Property * PropertyMgr::property | ( | const std::string & | name | ) | const [protected] |
Definition at line 134 of file PropertyMgr.cpp.
00135 { 00136 // local property ? 00137 Property* lp = property ( name , m_properties ) ; 00138 if ( 0 != lp ) { return lp ; } // RETURN 00139 // look for remote property 00140 Nocase cmp ; 00141 for ( RemoteProperties::const_iterator it = m_remoteProperties.begin() ; 00142 m_remoteProperties.end() != it ; ++it ) 00143 { 00144 if ( !cmp(it->first,name) ) { continue ; } // CONTINUE 00145 const IProperty* p = it->second.first ; 00146 if ( 0 == p ) { continue ; } // CONITNUE 00147 return property ( it->second.second , p->getProperties() ) ; // RETURN 00148 } 00149 return 0 ; // RETURN 00150 }
| 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 122 of file PropertyMgr.cpp.
00124 { 00125 Properties::const_iterator it = 00126 std::find_if ( props.begin() , props.end() , PropByName( name ) ) ; 00127 if ( props.end() != it ) { return *it ; } // RETURN 00128 return 0 ; // RETURN 00129 }
Properties PropertyMgr::m_properties [private] |
Properties PropertyMgr::m_todelete [private] |
std::vector<bool> PropertyMgr::m_isOwned [private] |
IInterface* PropertyMgr::m_pOuter [private] |
unsigned long PropertyMgr::m_refcount [private] |