The Gaudi Framework  v29r0 (ff2e7097)
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 
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 &&
51  const std::string& doc = "none" );
53  template <class TYPE>
55  const std::string& doc = "none" );
57  template <class TYPE>
59  const std::string& doc = "none" );
60 
61  // partial specializations for various GaudiHandles
64  const std::string& doc = "none" );
67  const std::string& doc = "none" );
70  const std::string& doc = "none" );
73  const std::string& rname = "" );
74  // ==========================================================================
75  // IProperty implementation
76  // ==========================================================================
81  // ==========================================================================
85  StatusCode setProperty( const std::string& s ) override;
86  // ==========================================================================
90  StatusCode setProperty( const std::string& n, const std::string& v ) override;
91  // ==========================================================================
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  // ==========================================================================
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:
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
137 
139  Properties m_properties; // local properties
141  RemoteProperties m_remoteProperties; // Remote properties
145  IInterface* m_pOuter; // Interface hub reference
146 };
147 // ============================================================================
149 // ============================================================================
150 template <class TYPE, typename>
152  const std::string& doc )
153 {
154  assertUniqueName( name );
155  m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
157  //
158  p->setDocumentation( doc );
159  m_properties.push_back( p );
160  //
161  return p;
162 }
163 // ============================================================================
165 // ============================================================================
166 template <class TYPE>
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>
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 // ============================================================================
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:136
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:319
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:135
Gaudi::Details::PropertyBase * property(const std::string &name) const
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:134
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.
STL class.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:35
T push_back(T...args)
Interface ID class.
Definition: IInterface.h:29
class GAUDI_API[[deprecated("will be removed in v29r0, consider using PropertyHolder instead")]] PropertyMgr
Definition: PropertyMgr.h:32
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:28
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition of the basic interface.
Definition: IInterface.h:277
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
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)
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:348
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:139
Helper class to implement the IProperty interface.
T back(T...args)
string s
Definition: gaudirun.py:253
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:143
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:83
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:20
~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:110
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:145
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:141
T emplace_back(T...args)