15 #include "GaudiKernel/PropertyMgr.h"
16 #include "GaudiKernel/INamedInterface.h"
17 #include "GaudiKernel/GaudiException.h"
18 #include "GaudiKernel/Bootstrap.h"
19 #include "GaudiKernel/ISvcLocator.h"
20 #include "GaudiKernel/IMessageSvc.h"
26 struct Nocase :
public std::binary_function<std::string,std::string,bool>
28 inline bool operator() (
const std::string& v1 ,
29 const std::string& v2 )
const
31 std::string::const_iterator i1 = v1.begin() ;
32 std::string::const_iterator i2 = v2.begin() ;
33 for ( ; v1.end() != i1 && v2.end() != i2 ; ++i1 , ++i2 )
35 return v1.size() == v2.size() ;
40 struct PropByName :
public std::unary_function<const Property*,bool>
42 PropByName (
const std::string& name ) : m_name ( name ) {} ;
43 inline bool operator() (
const Property* p )
const
44 {
return ( 0 == p ) ?
false : m_cmp ( p->
name() , m_name ) ; }
56 , m_remoteProperties ()
70 , m_properties ( right.m_properties )
71 , m_remoteProperties ( right.m_remoteProperties )
72 , m_todelete ( right.m_todelete )
73 , m_pOuter ( right.m_pOuter )
86 for ( Properties::iterator ip =
m_todelete.begin() ;
87 m_todelete.end() != ip ; ++ip ) {
delete *ip ; }
94 if ( &right ==
this ) {
return *this ; }
96 for ( Properties::iterator ip =
m_todelete.begin() ;
97 m_todelete.end() != ip ; ++ip ) {
delete *ip ; }
114 (
const std::string& name ,
116 const std::string& rname )
118 if ( 0 == rsvc ) {
return 0 ; }
119 const std::string& nam = rname.empty() ? name : rname ;
121 m_remoteProperties.push_back (
RemProperty ( name , std::make_pair ( rsvc , nam ) ) ) ;
128 (
const std::string& name ,
129 const std::vector<Property*>& props )
const
131 Properties::const_iterator it =
132 std::find_if ( props.begin() , props.end() , PropByName( name ) ) ;
133 if ( props.end() != it ) {
return *it ; }
140 (
const std::string& name )
const
144 if ( 0 != lp ) {
return lp ; }
147 for ( RemoteProperties::const_iterator it = m_remoteProperties.begin() ;
148 m_remoteProperties.end() != it ; ++it )
150 if ( !cmp(it->first,name) ) { continue ; }
152 if ( 0 == p ) { continue ; }
224 if ( 0 != p ) {
return *p ; }
226 throw std::out_of_range(
"Property "+name+
" not found." );
234 (
const std::string&
n ,
235 std::string& v )
const
248 const std::vector<Property*>&
255 StatusCode sc= base_class::queryInterface(iid, pinterface);
267 return Nocase()(prop->
name(), name);
275 std::string ownerName{
"PropertyMgr"};
278 ownerName = owner->
name();
283 <<
"duplicated property name '" << name
284 <<
"', see https://its.cern.ch/jira/browse/GAUDI-1023"<<
endmsg;
Definition of the MsgStream class used to transmit messages.
StatusCode setProperty(const Property &p)
set the property form another property
virtual bool assign(const Property &source)=0
import the property value form the source
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
virtual std::string toString() const =0
value -> string
const std::string & name() const
property name
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
bool isSuccess() const
Test for a status code of SUCCESS.
Properties m_todelete
Properties to be deleted.
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
virtual bool load(Property &dest) const =0
export the property value to the destination
Property manager helper class.
bool hasProperty(const std::string &name) const
Return true if we have a property with the given name.
bool isFailure() const
Test for a status code of FAILURE.
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
PropertyMgr(IInterface *iface=0)
constructor from the interface
StatusCode queryInterface(const InterfaceID &iid, void **pinterface)
Set the void** to the pointer to the requested interface of the instance.
virtual const std::string & name() const =0
Retrieve the name of the instance.
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Base class used to implement the interfaces.
Properties m_properties
Collection of all declared properties.
GAUDI_API ISvcLocator * svcLocator()
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
virtual ~PropertyMgr()
virtual destructor
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
The IMessage is the interface implemented by the message service.
PropertyMgr & operator=(const PropertyMgr &)
StatusCode getProperty(Property *p) const
get the property
const std::vector< Property * > & getProperties() const
get all properties
IInterface compliant class extending IInterface with the name() method.
Property base class allowing Property* collections to be "homogeneous".
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
Property * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Declare a remote property.
The IProperty is the basic interface for all components which have properties that can be set or get...
virtual Property * clone() const =0
clone: "virtual constructor"
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
void toupper(std::string &s)
Property * property(const std::string &name) const
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
virtual StatusCode fromString(const std::string &value)=0
string -> value