| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

PropertyMgr.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_PROPERTYMGR_H
2 #define GAUDIKERNEL_PROPERTYMGR_H
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <iostream>
9 #include <stdexcept>
10 #include <utility>
11 #include <vector>
12 // ============================================================================
13 // GaudiKernel
14 // ============================================================================
15 #include "GaudiKernel/DataObjectHandleProperty.h"
16 #include "GaudiKernel/IProperty.h"
17 #include "GaudiKernel/Property.h"
18
19 // ============================================================================
20
32 class GAUDI_API[[deprecated( "will be removed in v29r0, consider using PropertyHolder instead" )]] PropertyMgr
33 : public implements<IProperty>
34 {
35 public:
37 PropertyMgr( IInterface* iface = nullptr );
38 // copy constructor
39 PropertyMgr( const PropertyMgr& ) = delete;
40 // assignment operator
41 PropertyMgr& operator=( const PropertyMgr& ) = delete;
43 ~PropertyMgr() override = default;
44
45 public:
47 template <class TYPE, typename = typename std::enable_if<!std::is_base_of<GaudiHandleBase, TYPE>::value &&
48 !std::is_base_of<GaudiHandleArrayBase, TYPE>::value &&
49 !std::is_base_of<DataObjectHandleBase, TYPE>::value>::type>
50 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, TYPE& value,
51 const std::string& doc = "none" );
53 template <class TYPE>
54 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
55 const std::string& doc = "none" );
57 template <class TYPE>
58 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop,
59 const std::string& doc = "none" );
60
61 // partial specializations for various GaudiHandles
63 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, GaudiHandleBase& ref,
64 const std::string& doc = "none" );
66 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, GaudiHandleArrayBase& ref,
67 const std::string& doc = "none" );
69 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, DataObjectHandleBase& ref,
70 const std::string& doc = "none" );
72 Gaudi::Details::PropertyBase* declareRemoteProperty( const std::string& name, IProperty* rsvc,
73 const std::string& rname = "" );
74 // ==========================================================================
75 // IProperty implementation
76 // ==========================================================================
80 StatusCode setProperty( const Gaudi::Details::PropertyBase& p ) override;
81 // ==========================================================================
85 StatusCode setProperty( const std::string& s ) override;
86 // ==========================================================================
90 StatusCode setProperty( const std::string& n, const std::string& v ) override;
91 // ==========================================================================
95 StatusCode getProperty( Gaudi::Details::PropertyBase * p ) const override;
96 // ==========================================================================
100 const Gaudi::Details::PropertyBase& getProperty( const std::string& name ) const override;
101 // ==========================================================================
105 StatusCode getProperty( const std::string& n, std::string& v ) const override;
106 // ==========================================================================
110 const std::vector<Gaudi::Details::PropertyBase*>& getProperties() const override;
111 // ==========================================================================
115 bool hasProperty( const std::string& name ) const override;
116 // ==========================================================================
117 // IInterface implementation
118 StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
119 // ==========================================================================
120 protected:
121 // get local or remote property by name
122 Gaudi::Details::PropertyBase* property( const std::string& name ) const;
123
124 private:
126 Gaudi::Details::PropertyBase* property( const std::string& name,
127 const std::vector<Gaudi::Details::PropertyBase*>& props ) const;
128
131 void assertUniqueName( const std::string& name ) const;
132
133 // Some typedef to simply typing
134 typedef std::vector<Gaudi::Details::PropertyBase*> Properties;
135 typedef std::pair<std::string, std::pair<IProperty*, std::string>> RemProperty;
136 typedef std::vector<RemProperty> RemoteProperties;
137
139 Properties m_properties; // local properties
141 RemoteProperties m_remoteProperties; // Remote properties
143 std::vector<std::unique_ptr<Gaudi::Details::PropertyBase>> m_todelete; // properties to be deleted
145 IInterface* m_pOuter; // Interface hub reference
146 };
147 // ============================================================================
149 // ============================================================================
150 template <class TYPE, typename>
151 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, TYPE& value,
152 const std::string& doc )
153 {
154 assertUniqueName( name );
155 m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
156 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
157 //
158 p->setDocumentation( doc );
159 m_properties.push_back( p );
160 //
161 return p;
162 }
163 // ============================================================================
165 // ============================================================================
166 template <class TYPE>
167 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
168 const std::string& doc )
169 {
170 assertUniqueName( name );
171 Gaudi::Details::PropertyBase* p = &prop;
172 //
173 p->setName( name );
174 p->setDocumentation( doc );
175 m_properties.push_back( p );
176 //
177 return p;
178 }
179 // ============================================================================
181 // ============================================================================
182 template <class TYPE>
183 inline Gaudi::Details::PropertyBase*
184 PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop, const std::string& doc )
185 {
186 assertUniqueName( name );
187 Gaudi::Details::PropertyBase* p = &prop;
188 //
189 p->setName( name );
190 p->setDocumentation( doc );
191 m_properties.push_back( p );
192 //
193 return p;
194 }
195
196 // ============================================================================
197 // The END
198 // ============================================================================
199 #endif // GAUDIKERNEL_PROPERTYMGR_H
200 // ============================================================================
RemoteProperties
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:136
implements
Base class used to implement the interfaces.
Definition: implements.h:9
DataObjectHandleProperty.h
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
RemProperty
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:135
property
Gaudi::Details::PropertyBase * property(const std::string &name) const
declareRemoteProperty
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Declare a remote property.
Properties
std::vector< Gaudi::Details::PropertyBase * > Properties
Definition: PropertyMgr.h:134
assertUniqueName
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
PropertyMgr
Property manager helper class.
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
implements::operator=
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:35
std::vector::push_back
T push_back(T...args)
InterfaceID
Interface ID class.
Definition: IInterface.h:29
PropertyMgr
class GAUDI_API[[deprecated("will be removed in v29r0, consider using PropertyHolder instead")]] PropertyMgr
Definition: PropertyMgr.h:32
hasProperty
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
declareProperty
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
gaudirun.type
type
Definition: gaudirun.py:133
getProperty
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
Gaudi::Details::PropertyBase::setName
void setName(std::string value)
set the new value for the property name
Definition: Property.h:90
std::pair
std::unique_ptr::get
T get(T...args)
GaudiHandleArrayBase
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:348
IProperty.h
std::vector< Gaudi::Details::PropertyBase * >
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:25
Property.h
std::is_base_of
m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:139
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:73
std::vector::back
T back(T...args)
gaudirun.s
string s
Definition: gaudirun.py:253
m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:143
GaudiHandleBase
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:83
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:20
~PropertyMgr
~PropertyMgr() override=default
virtual destructor
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
getProperties
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
m_pOuter
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:145
m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:141
std::vector::emplace_back
T emplace_back(T...args)