Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

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]

List of all members.

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)

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_properties       ()
  , m_remoteProperties ()
  , m_todelete         ()
  , 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),
    extend_interfaces_base(right),
    base_class(right)
  , m_properties       ( right.m_properties       )
  , m_remoteProperties ( right.m_remoteProperties )
  , m_todelete         ( right.m_todelete         )
  , m_pOuter           ( right.m_pOuter )
{
  addRef(); // initial reference count set to 1
  std::transform
    ( m_todelete.begin() , m_todelete.end  () ,
      m_todelete.begin() , std::mem_fun(&Property::clone));
}
PropertyMgr::~PropertyMgr (  ) [virtual]

virtual destructor

delete all owned properties

Definition at line 81 of file PropertyMgr.cpp.

{
  for ( Properties::iterator ip  = m_todelete.begin() ;
        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 );
  m_properties .push_back( p ) ;
  m_todelete   .push_back( p ) ;
  //
  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   ) ;
  m_properties.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 ;
}
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,
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   ) ;
  m_properties.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 ;
}
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; }
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 ( 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
}
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() ;
  //
  return StatusCode::SUCCESS ;
}
PropertyMgr & PropertyMgr::operator= ( const PropertyMgr right )

Definition at line 90 of file PropertyMgr.cpp.

{
  if  ( &right == this ) { return *this ; }
  //
  for ( Properties::iterator ip  = m_todelete.begin() ;
        m_todelete.end() != ip ; ++ip ) { delete *ip ; }
  //
  m_properties       = right.m_properties       ;
  m_remoteProperties = right.m_remoteProperties ;
  m_todelete         = right.m_todelete         ;
  m_pOuter           = right.m_pOuter           ;
  //
  std::transform
    ( m_todelete.begin() , m_todelete.end  () ,
      m_todelete.begin() , std::mem_fun(&Property::clone));
  //
  return *this ;
}
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.

{
  Properties::const_iterator it =
    std::find_if ( props.begin() , props.end() , PropByName( name ) ) ;
  if ( props.end() != it ) { return *it ; }                // RETURN
  return 0 ;                                               // RETURN
}
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 ;
  for ( RemoteProperties::const_iterator it = m_remoteProperties.begin() ;
        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
}
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 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 ;
  return result ? StatusCode::SUCCESS : StatusCode::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
}

Member Data Documentation

Flag to decide to delete or not a propertyRef.

Definition at line 167 of file PropertyMgr.h.

Interface hub reference (ApplicationMgr)

Definition at line 169 of file PropertyMgr.h.

Collection of all declared properties.

Definition at line 161 of file PropertyMgr.h.

Collection of all declared remote properties.

Definition at line 163 of file PropertyMgr.h.

Properties to be deleted.

Definition at line 165 of file PropertyMgr.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:20 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004