All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 // ============================================================================
16 #include "GaudiKernel/IProperty.h"
17 #include "GaudiKernel/Property.h"
18 
19 // ============================================================================
20 
21 // pre-declaration of GaudiHandles is sufficient
22 template <class T>
23 class ToolHandle;
24 template <class T>
25 class ServiceHandle;
26 template <class T>
27 class ToolHandleArray;
28 template <class T>
29 class ServiceHandleArray;
30 template <class T>
32 
44 class GAUDI_API[[deprecated( "will be removed in v28r1, consider using PropertyHolder instead" )]] PropertyMgr
45  : public implements<IProperty>
46 {
47 public:
49  PropertyMgr( IInterface* iface = nullptr );
50  // copy constructor
51  PropertyMgr( const PropertyMgr& ) = delete;
52  // assignment operator
53  PropertyMgr& operator=( const PropertyMgr& ) = delete;
55  ~PropertyMgr() override = default;
56 
57 public:
59  template <class TYPE>
61  const std::string& doc = "none" );
63  template <class TYPE>
65  const std::string& doc = "none" );
67  template <class TYPE>
69  const std::string& doc = "none" );
70  // partial specializations for various GaudiHandles
72  template <class TYPE>
74  const std::string& doc = "none" );
76  template <class TYPE>
78  const std::string& doc = "none" );
80  template <class TYPE>
82  const std::string& doc = "none" );
84  template <class TYPE>
86  const std::string& doc = "none" );
88  template <class TYPE>
90  const std::string& doc = "none" );
93  const std::string& rname = "" );
94  // ==========================================================================
95  // IProperty implementation
96  // ==========================================================================
101  // ==========================================================================
105  StatusCode setProperty( const std::string& s ) override;
106  // ==========================================================================
110  StatusCode setProperty( const std::string& n, const std::string& v ) override;
111  // ==========================================================================
116  // ==========================================================================
120  const Gaudi::Details::PropertyBase& getProperty( const std::string& name ) const override;
121  // ==========================================================================
125  StatusCode getProperty( const std::string& n, std::string& v ) const override;
126  // ==========================================================================
131  // ==========================================================================
135  bool hasProperty( const std::string& name ) const override;
136  // ==========================================================================
137  // IInterface implementation
138  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
139  // ==========================================================================
140 protected:
141  // get local or remote property by name
142  Gaudi::Details::PropertyBase* property( const std::string& name ) const;
143 
144 private:
147  const std::vector<Gaudi::Details::PropertyBase*>& props ) const;
148 
151  void assertUniqueName( const std::string& name ) const;
152 
153  // Some typedef to simply typing
157 
159  Properties m_properties; // local properties
161  RemoteProperties m_remoteProperties; // Remote properties
165  IInterface* m_pOuter; // Interface hub reference
166 };
167 // ============================================================================
169 // ============================================================================
170 template <class TYPE>
172  const std::string& doc )
173 {
174  assertUniqueName( name );
175  m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
177  //
178  p->setDocumentation( doc );
179  m_properties.push_back( p );
180  //
181  return p;
182 }
183 // ============================================================================
185 // ============================================================================
186 template <class TYPE>
188  const std::string& doc )
189 {
190  assertUniqueName( name );
191  Gaudi::Details::PropertyBase* p = &prop;
192  //
193  p->setName( name );
194  p->setDocumentation( doc );
195  m_properties.push_back( p );
196  //
197  return p;
198 }
199 // ============================================================================
201 // ============================================================================
202 template <class TYPE>
205 {
206  assertUniqueName( name );
207  Gaudi::Details::PropertyBase* p = &prop;
208  //
209  p->setName( name );
210  p->setDocumentation( doc );
211  m_properties.push_back( p );
212  //
213  return p;
214 }
215 // ============================================================================
216 // Declare a property (templated)
217 // ============================================================================
218 template <class TYPE>
220  const std::string& doc )
221 {
222  assertUniqueName( name );
223  m_todelete.emplace_back( new GaudiHandleProperty( name, ref ) );
225  //
226  p->setDocumentation( doc );
227  m_properties.push_back( p );
228  //
229  return p;
230 }
231 // ============================================================================
232 template <class TYPE>
234  const std::string& doc )
235 {
236  assertUniqueName( name );
237  m_todelete.emplace_back( new GaudiHandleProperty( name, ref ) );
239  //
240  p->setDocumentation( doc );
241  m_properties.push_back( p );
242  //
243  return p;
244 }
245 // ============================================================================
246 template <class TYPE>
248  const std::string& doc )
249 {
250  assertUniqueName( name );
253  //
254  p->setDocumentation( doc );
255  m_properties.push_back( p );
256  //
257  return p;
258 }
259 // ============================================================================
260 template <class TYPE>
263 {
264  assertUniqueName( name );
267  //
268  p->setDocumentation( doc );
269  m_properties.push_back( p );
270  //
271  return p;
272 }
273 
274 // ============================================================================
275 template <class TYPE>
277  const std::string& doc )
278 {
279  assertUniqueName( name );
282  //
283  p->setDocumentation( doc );
284  m_properties.push_back( p );
285  //
286  return p;
287 }
288 
289 // ============================================================================
290 // The END
291 // ============================================================================
292 #endif // GAUDIKERNEL_PROPERTYMGR_H
293 // ============================================================================
Handle to be used in lieu of naked pointers to services.
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:156
Base class used to implement the interfaces.
Definition: implements.h:9
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Implementation of property with value of concrete type.
Definition: Property.h:313
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:155
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Gaudi::Details::PropertyBase * property(const std::string &name) const
Array of Handles to be used in lieu of vector of naked pointers to tools.
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Declare a remote property.
std::vector< Gaudi::Details::PropertyBase * > Properties
Definition: PropertyMgr.h:154
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
Property manager helper class.
Definition: PropertyMgr.h:31
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
STL class.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
Definition: AlgTool.h:25
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:38
T push_back(T...args)
Interface ID class.
Definition: IInterface.h:30
class GAUDI_API[[deprecated("will be removed in v28r1, consider using PropertyHolder instead")]] PropertyMgr
Definition: PropertyMgr.h:44
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
Array of Handles to be used in lieu of vector of naked pointers to tools.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
void setName(std::string value)
set the new value for the property name
Definition: Property.h:90
T get(T...args)
Handle to be used in lieu of naked pointers to tools.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:159
Helper class to implement the IProperty interface.
T back(T...args)
string s
Definition: gaudirun.py:245
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:163
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:22
~PropertyMgr() override=default
virtual destructor
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
#define GAUDI_API
Definition: Kernel.h:107
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:165
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:161
T emplace_back(T...args)