| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# PropertyMgr Class Reference

Property manager helper class. More...

`#include <GaudiKernel/PropertyMgr.h>`

Inheritance diagram for PropertyMgr:

[legend]
Collaboration diagram for PropertyMgr:

[legend]

List of all members.

## Public Member Functions
| PropertyMgr (IInterface *iface=0)
| constructor 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).
template<class TYPE>
Property * | declareProperty (const std::string &name, ServiceHandleArray< 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 name and the value
StatusCode | getProperty (Property *p) const
| get the property
const Property & | getProperty (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
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).

## 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::pair<std::string, std::pair<IProperty*, std::string> > PropertyMgr::RemProperty`[private]`

Definition at line 155 of file PropertyMgr.h.

typedef std::vector<RemProperty> PropertyMgr::RemoteProperties`[private]`

Definition at line 156 of file PropertyMgr.h.

## Constructor & Destructor Documentation

PropertyMgr::PropertyMgr | ( | IInterface * | iface = `0` | ) |

constructor 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 {
    00058   addRef(); // initial reference count set to 1
    00059 }

PropertyMgr::PropertyMgr | ( | const PropertyMgr & | right | ) |

Definition at line 63 of file PropertyMgr.cpp.

    00064   : IInterface(right),
    00065     IProperty(right),
    00066     extend_interfaces_base(right),
    00067     base_class(right)
    00068   , m_properties       ( right.m_properties       )
    00069   , m_remoteProperties ( right.m_remoteProperties )
    00070   , m_todelete         ( right.m_todelete         )
    00071   , m_pOuter           ( right.m_pOuter )
    00072 {
    00073   addRef(); // initial reference count set to 1
    00074   std::transform
    00075     ( m_todelete.begin() , m_todelete.end  () ,
    00076       m_todelete.begin() , std::mem_fun(&Property::clone));
    00077 }

PropertyMgr::~PropertyMgr | ( |  | ) | `[virtual]`

virtual destructor

delete all owned properties

Definition at line 81 of file PropertyMgr.cpp.

    00082 {
    00084   for ( Properties::iterator ip  = m_todelete.begin() ;
    00085         m_todelete.end() != ip ; ++ip ) { delete *ip ; }
    00086 }

## Member Function Documentation

PropertyMgr & PropertyMgr::operator= | ( | const PropertyMgr & | right | ) |

Definition at line 90 of file PropertyMgr.cpp.

    00091 {
    00092   if  ( &right == this ) { return *this ; }
    00093   //
    00094   for ( Properties::iterator ip  = m_todelete.begin() ;
    00095         m_todelete.end() != ip ; ++ip ) { delete *ip ; }
    00096   //
    00097   m_properties       = right.m_properties       ;
    00098   m_remoteProperties = right.m_remoteProperties ;
    00099   m_todelete         = right.m_todelete         ;
    00100   m_pOuter           = right.m_pOuter           ;
    00101   //
    00102   std::transform
    00103     ( m_todelete.begin() , m_todelete.end  () ,
    00104       m_todelete.begin() , std::mem_fun(&Property::clone));
    00105   //
    00106   return *this ;
    00107 }

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.

    00180 {
    00181   Property* p = new SimplePropertyRef<TYPE> ( name , value ) ;
    00182   //
    00183   p->setDocumentation( doc );
    00184   m_properties .push_back( p ) ;
    00185   m_todelete   .push_back( p ) ;
    00186   //
    00187   return p ;
    00188 }

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.

    00198 {
    00199   Property* p = &prop ;
    00200   //
    00201   p -> setName           ( name  ) ;
    00202   p -> setDocumentation  ( doc   ) ;
    00203   m_properties.push_back ( p     ) ;
    00204   //
    00205   return p ;
    00206 }

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.

    00216 {
    00217   Property* p = &prop ;
    00218   //
    00219   p -> setName             ( name  ) ;
    00220   p -> setDocumentation    ( doc   ) ;
    00221   m_properties.push_back   ( p     ) ;
    00222   //
    00223   return p ;
    00224 }

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.

    00234 {
    00235   Property* p = new GaudiHandleProperty( name, ref );
    00236   //
    00237   p -> setDocumentation    ( doc ) ;
    00238   m_properties . push_back ( p   ) ;
    00239   m_todelete   . push_back ( p   ) ;
    00240   //
    00241   return p ;
    00242 }

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.

    00250 {
    00251   Property* p = new GaudiHandleProperty( name, ref );
    00252   //
    00253   p -> setDocumentation    ( doc ) ;
    00254   m_properties . push_back ( p   ) ;
    00255   m_todelete   . push_back ( p   ) ;
    00256   //
    00257   return p ;
    00258 }

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.

    00266 {
    00267   Property* p = new GaudiHandleArrayProperty( name, ref );
    00268   //
    00269   p -> setDocumentation    ( doc ) ;
    00270   m_properties . push_back ( p   ) ;
    00271   m_todelete   . push_back ( p   ) ;
    00272   //
    00273   return p ;
    00274 }

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.

    00282 {
    00283   Property* p = new GaudiHandleArrayProperty( name, ref );
    00284   //
    00285   p -> setDocumentation    ( doc ) ;
    00286   m_properties . push_back ( p   ) ;
    00287   m_todelete   . push_back ( p   ) ;
    00288   //
    00289   return p ;
    00290 }

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.

    00115 {
    00116   if ( 0 == rsvc ) { return 0 ; }
    00117   const std::string& nam = rname.empty() ? name : rname ;
    00118   Property* p = property ( nam , rsvc->getProperties() )  ;
    00119   m_remoteProperties.push_back ( RemProperty ( name , std::make_pair ( rsvc , nam ) ) ) ;
    00120   return p ;
    00121 }

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.

    00161 {
    00162   Property* pp = property( p.name() ) ;
    00163   if ( 0 == pp            ) { return StatusCode::FAILURE ; } // RETURN
    00164   //
    00165   try
    00166   { if ( !pp->assign(p) ) { return StatusCode::FAILURE ; } } // RETURN
    00167   catch(...)              { return StatusCode::FAILURE ;   } // RETURN
    00168   //
    00169   return StatusCode::SUCCESS;      // Property value set
    00170 }

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.

    00178 {
    00179   std::string name  ;
    00180   std::string value ;
    00181   StatusCode sc = Gaudi::Parsers::parse( name , value , i ) ;
    00182   if ( sc.isFailure() ) { return sc ; }
    00183   return setProperty ( name , value ) ;
    00184 }

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.

    00192 {
    00193   Property* p = property( n ) ;
    00194   if ( 0 == p ) { return StatusCode::FAILURE ; }  // RETURN
    00195   bool result =  p->fromString( v ) != 0 ;
    00196   return result ? StatusCode::SUCCESS : StatusCode::FAILURE ;
    00197 }

StatusCode PropertyMgr::getProperty | ( | Property * | p | ) | const`[virtual]`

get the property

See also:
  IProperty

Implements IProperty.

Definition at line 203 of file PropertyMgr.cpp.

    00204 {
    00205   try
    00206   {
    00207     const Property* pp = property( p->name() ) ;
    00208     if ( 0 == pp         ) { return StatusCode::FAILURE ; }   // RETURN
    00209     if ( !pp->load( *p ) ) { return StatusCode::FAILURE ; }   // RETURN
    00210   }
    00211   catch ( ... )            { return StatusCode::FAILURE;  }   // RETURN
    00212   return StatusCode::SUCCESS ;                                // RETURN
    00213 }

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.

    00220 {
    00221   const Property* p = property( name ) ;
    00222   if ( 0 != p ) { return *p ; }                        // RETURN
    00223   //
    00224   throw std::out_of_range( "Property "+name+" not found." );    // Not found
    00225 }

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.

    00234 {
    00235   // get the property
    00236   const Property* p = property( n ) ;
    00237   if ( 0 == p ) { return StatusCode::FAILURE ; }
    00238   // convert the value into the string
    00239   v = p->toString() ;
    00240   //
    00241   return StatusCode::SUCCESS ;
    00242 }

const std::vector< Property * > & PropertyMgr::getProperties | ( |  | ) | const`[virtual]`

get all properties

See also:
  IProperty

Implements IProperty.

Definition at line 247 of file PropertyMgr.cpp.

    00247 { return m_properties; }

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.

    00251                                                                                 {
    00252   // try local interfaces
    00253   StatusCode sc= base_class::queryInterface(iid, pinterface);
    00254   if (sc.isSuccess()) return sc;
    00255   // fall back on the owner
    00256   return (0 != m_pOuter)? m_pOuter->queryInterface(iid, pinterface)
    00257                         : sc; // FAILURE
    00258 }

Property * PropertyMgr::property | ( | const std::string & | name | ) | const`[protected]`

Definition at line 138 of file PropertyMgr.cpp.

    00139 {
    00140   // local property ?
    00141   Property* lp = property ( name , m_properties ) ;
    00142   if ( 0 != lp ) { return lp ; }                       // RETURN
    00143   // look for remote property
    00144   Nocase cmp ;
    00145   for ( RemoteProperties::const_iterator it = m_remoteProperties.begin() ;
    00146         m_remoteProperties.end() != it ; ++it )
    00147   {
    00148     if ( !cmp(it->first,name) ) { continue ; }   // CONTINUE
    00149     const IProperty* p = it->second.first ;
    00150     if ( 0 == p               ) { continue ; }   // CONITNUE
    00151     return property ( it->second.second , p->getProperties() ) ; // RETURN
    00152   }
    00153   return 0 ;                                           // RETURN
    00154 }

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.

    00128 {
    00129   Properties::const_iterator it =
    00130     std::find_if ( props.begin() , props.end() , PropByName( name ) ) ;
    00131   if ( props.end() != it ) { return *it ; }                // RETURN
    00132   return 0 ;                                               // RETURN
    00133 }

## Member Data Documentation

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.

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.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/PropertyMgr.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/src/Lib/PropertyMgr.cpp