| The Gaudi Framework v27r1

- 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 <vector>
10 #include <utility>
11 #include <stdexcept>
12 // ============================================================================
13 // GaudiKernel
14 // ============================================================================
15 #include "GaudiKernel/Property.h"
16 #include "GaudiKernel/IProperty.h"
17 #include "GaudiKernel/DataObjectHandleProperty.h"
18
19 // ============================================================================
20
21 // pre-declaration of GaudiHandles is sufficient
22 template< class T> class ToolHandle;
23 template< class T> class ServiceHandle;
24 template< class T> class ToolHandleArray;
25 template< class T> class ServiceHandleArray;
26 template< class T> class DataObjectHandle;
27
37 class GAUDI_API PropertyMgr : public implements<IProperty>
38 {
39 public:
41 PropertyMgr ( IInterface* iface = nullptr );
42 // copy constructor
43 PropertyMgr ( const PropertyMgr& ) = delete;
44 // assignment operator
45 PropertyMgr& operator=( const PropertyMgr& ) = delete;
47 ~PropertyMgr() override = default;
48 public:
50 template<class TYPE>
51 Property* declareProperty
52 ( const std::string& name ,
53 TYPE& value,
54 const std::string& doc = "none" ) ;
56 template <class TYPE>
57 Property* declareProperty
58 ( const std::string& name ,
59 SimpleProperty<TYPE>& prop,
60 const std::string& doc = "none") ;
62 template <class TYPE>
63 Property* declareProperty
64 ( const std::string& name ,
65 SimplePropertyRef<TYPE>& prop,
66 const std::string& doc = "none") ;
67 // partial specializations for various GaudiHandles
69 template<class TYPE>
70 Property* declareProperty
71 ( const std::string& name,
72 ToolHandle<TYPE>& ref,
73 const std::string& doc = "none" ) ;
75 template<class TYPE>
76 Property* declareProperty
77 ( const std::string& name,
78 ServiceHandle<TYPE>& ref,
79 const std::string& doc = "none" ) ;
81 template<class TYPE>
82 Property* declareProperty
83 ( const std::string& name,
84 ToolHandleArray<TYPE>& ref,
85 const std::string& doc = "none" ) ;
87 template<class TYPE>
88 Property* declareProperty
89 ( const std::string& name,
90 ServiceHandleArray<TYPE>& ref,
91 const std::string& doc = "none" ) ;
93 template<class TYPE>
94 Property* declareProperty
95 ( const std::string& name,
96 DataObjectHandle<TYPE>& ref,
97 const std::string& doc = "none" ) ;
99 Property* declareRemoteProperty
100 ( const std::string& name ,
101 IProperty* rsvc ,
102 const std::string& rname = "" ) ;
103 // ==========================================================================
104 // IProperty implementation
105 // ==========================================================================
109 StatusCode setProperty(const Property& p) override;
110 // ==========================================================================
114 StatusCode setProperty( const std::string& s ) override;
115 // ==========================================================================
119 StatusCode setProperty( const std::string& n, const std::string& v) override;
120 // ==========================================================================
124 StatusCode getProperty(Property* p) const override;
125 // ==========================================================================
129 const Property& getProperty( const std::string& name) const override;
130 // ==========================================================================
134 StatusCode getProperty( const std::string& n, std::string& v ) const override;
135 // ==========================================================================
139 const std::vector<Property*>& getProperties( ) const override;
140 // ==========================================================================
144 bool hasProperty(const std::string& name) const override;
145 // ==========================================================================
146 // IInterface implementation
147 StatusCode queryInterface(const InterfaceID& iid, void** pinterface) override;
148 // ==========================================================================
149 protected:
150
151 // get local or remote property by name
152 Property* property ( const std::string& name ) const ;
153
154 private:
155
157 Property* property
158 ( const std::string& name ,
159 const std::vector<Property*>& props ) const ;
160
163 void assertUniqueName(const std::string& name) const;
164
165 // Some typedef to simply typing
166 typedef std::vector<Property*> Properties ;
167 typedef std::pair<std::string,
168 std::pair<IProperty*, std::string> > RemProperty;
169 typedef std::vector<RemProperty> RemoteProperties ;
170
172 Properties m_properties ; // local properties
174 RemoteProperties m_remoteProperties; // Remote properties
176 std::vector<std::unique_ptr<Property>> m_todelete ; // properties to be deleted
178 IInterface* m_pOuter ; // Interface hub reference
179 };
180 // ============================================================================
182 // ============================================================================
183 template<class TYPE>
184 inline Property*
185 PropertyMgr::declareProperty
186 ( const std::string& name ,
187 TYPE& value,
188 const std::string& doc )
189 {
190 assertUniqueName(name);
191 m_todelete.emplace_back( new SimplePropertyRef<TYPE> ( name , value ) );
192 Property* p = m_todelete.back().get();
193 //
194 p->setDocumentation( doc );
195 m_properties .push_back( p ) ;
196 //
197 return p ;
198 }
199 // ============================================================================
201 // ============================================================================
202 template <class TYPE>
203 inline Property*
204 PropertyMgr::declareProperty
205 ( const std::string& name ,
206 SimpleProperty<TYPE>& prop,
207 const std::string& doc )
208 {
209 assertUniqueName(name);
210 Property* p = &prop ;
211 //
212 p -> setName ( name ) ;
213 p -> setDocumentation ( doc ) ;
214 m_properties.push_back ( p ) ;
215 //
216 return p ;
217 }
218 // ============================================================================
220 // ============================================================================
221 template <class TYPE>
222 inline Property*
223 PropertyMgr::declareProperty
224 ( const std::string& name ,
225 SimplePropertyRef<TYPE>& prop,
226 const std::string& doc )
227 {
228 assertUniqueName(name);
229 Property* p = &prop ;
230 //
231 p -> setName ( name ) ;
232 p -> setDocumentation ( doc ) ;
233 m_properties.push_back ( p ) ;
234 //
235 return p ;
236 }
237 // ============================================================================
238 // Declare a property (templated)
239 // ============================================================================
240 template<class TYPE>
241 inline Property*
242 PropertyMgr::declareProperty
243 ( const std::string& name,
244 ToolHandle<TYPE>& ref,
245 const std::string& doc )
246 {
247 assertUniqueName(name);
248 m_todelete . emplace_back ( new GaudiHandleProperty( name, ref ) );
249 Property* p = m_todelete.back().get();
250 //
251 p -> setDocumentation ( doc ) ;
252 m_properties . push_back ( p ) ;
253 //
254 return p ;
255 }
256 // ============================================================================
257 template<class TYPE>
258 inline Property*
259 PropertyMgr::declareProperty
260 ( const std::string& name,
261 ServiceHandle<TYPE>& ref,
262 const std::string& doc )
263 {
264 assertUniqueName(name);
265 m_todelete . emplace_back (new GaudiHandleProperty( name, ref ));
266 Property* p = m_todelete.back().get();
267 //
268 p -> setDocumentation ( doc ) ;
269 m_properties . push_back ( p ) ;
270 //
271 return p ;
272 }
273 // ============================================================================
274 template<class TYPE>
275 inline Property*
276 PropertyMgr::declareProperty
277 ( const std::string& name,
278 ToolHandleArray<TYPE>& ref,
279 const std::string& doc )
280 {
281 assertUniqueName(name);
282 m_todelete . emplace_back ( new GaudiHandleArrayProperty( name, ref ) );
283 Property* p = m_todelete.back().get();
284 //
285 p -> setDocumentation ( doc ) ;
286 m_properties . push_back ( p ) ;
287 //
288 return p ;
289 }
290 // ============================================================================
291 template<class TYPE>
292 inline Property*
293 PropertyMgr::declareProperty
294 ( const std::string& name,
295 ServiceHandleArray<TYPE>& ref,
296 const std::string& doc )
297 {
298 assertUniqueName(name);
299 m_todelete . emplace_back ( new GaudiHandleArrayProperty( name, ref ) );
300 Property* p = m_todelete.back().get();
301 //
302 p -> setDocumentation ( doc ) ;
303 m_properties . push_back ( p ) ;
304 //
305 return p ;
306 }
307
308 // ============================================================================
309 template<class TYPE>
310 inline Property*
311 PropertyMgr::declareProperty
312 ( const std::string& name,
313 DataObjectHandle<TYPE>& ref,
314 const std::string& doc )
315 {
316 assertUniqueName(name);
317 Property* p = new DataObjectHandleProperty( name, ref );
318 //
319 p -> setDocumentation ( doc ) ;
320 m_properties . push_back ( p ) ;
321 //
322 return p ;
323 }
324
325 // ============================================================================
326 // The END
327 // ============================================================================
328 #endif // GAUDIKERNEL_PROPERTYMGR_H
329 // ============================================================================
330
ServiceHandle
Handle to be used in lieu of naked pointers to services.
Definition: PropertyMgr.h:23
implements
Base class used to implement the interfaces.
Definition: implements.h:9
DataObjectHandleProperty.h
PropertyMgr::m_pOuter
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:178
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
SimplePropertyRef
SimplePropertyRef templated class.
Definition: HistoProperty.h:14
Gaudi::Utils::hasProperty
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
Definition: Property.cpp:159
Property::setDocumentation
void setDocumentation(std::string documentation)
set the documentation string
Definition: Property.h:94
ToolHandleArray
Array of Handles to be used in lieu of vector of naked pointers to tools.
Definition: PropertyMgr.h:24
getProperty
const char *PyHelper() getProperty(IInterface *p, char *name)
Definition: Bootstrap.cpp:258
PropertyMgr
Property manager helper class.
Definition: PropertyMgr.h:37
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
DataObjectHandleProperty
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
Definition: DataObjectHandleProperty.h:23
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
SimpleProperty
SimpleProperty concrete class which implements the full Property interface.
Definition: HistoProperty.h:13
DataObjectHandle
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
Definition: AlgTool.h:24
implements::operator=
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:38
InterfaceID
Interface ID class.
Definition: IInterface.h:30
PropertyMgr::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:172
PropertyMgr::m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:174
PropertyMgr::declareProperty
Property * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:186
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
PropertyMgr::RemProperty
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:168
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:254
ServiceHandleArray
Array of Handles to be used in lieu of vector of naked pointers to tools.
Definition: PropertyMgr.h:25
GaudiPython.Bindings.GaudiHandleArrayProperty
GaudiHandleArrayProperty
Definition: Bindings.py:49
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
std::pair
ToolHandle
Handle to be used in lieu of naked pointers to tools.
Definition: PropertyMgr.h:22
IProperty.h
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
std::vector< Property * >
Property.h
gaudirun.s
string s
Definition: gaudirun.py:245
GaudiPython.Bindings.GaudiHandleProperty
GaudiHandleProperty
Definition: Bindings.py:48
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:22
PropertyMgr::RemoteProperties
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:169
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
PropertyMgr::Properties
std::vector< Property * > Properties
Definition: PropertyMgr.h:166
PropertyMgr::m_todelete
std::vector< std::unique_ptr< Property > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:176