The Gaudi Framework  v30r3 (a5ef0a68)
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 // ============================================================================
17 #include "GaudiKernel/IProperty.h"
18 #include "GaudiKernel/Property.h"
19 
20 // ============================================================================
21 
33 class GAUDI_API[[deprecated( "will be removed in v29r0, consider using PropertyHolder instead" )]] PropertyMgr
34  : public implements<IProperty>
35 {
36 public:
38  PropertyMgr( IInterface* iface = nullptr );
39  // copy constructor
40  PropertyMgr( const PropertyMgr& ) = delete;
41  // assignment operator
42  PropertyMgr& operator=( const PropertyMgr& ) = delete;
43 
44 public:
46  template <class TYPE, typename = std::enable_if_t<!std::is_base_of<GaudiHandleBase, TYPE>::value &&
50  const std::string& doc = "none" );
52  template <class TYPE>
54  const std::string& doc = "none" );
56  template <class TYPE>
58  const std::string& doc = "none" );
59 
60  // partial specializations for various GaudiHandles
63  const std::string& doc = "none" );
66  const std::string& doc = "none" );
69  const std::string& doc = "none" );
72  const std::string& rname = "" );
73  // ==========================================================================
74  // IProperty implementation
75  // ==========================================================================
80  // ==========================================================================
84  StatusCode setProperty( const std::string& s ) override;
85  // ==========================================================================
89  StatusCode setProperty( const std::string& n, const std::string& v ) override;
90  // ==========================================================================
95  // ==========================================================================
99  const Gaudi::Details::PropertyBase& getProperty( const std::string& name ) const override;
100  // ==========================================================================
104  StatusCode getProperty( const std::string& n, std::string& v ) const override;
105  // ==========================================================================
110  // ==========================================================================
114  bool hasProperty( const std::string& name ) const override;
115  // ==========================================================================
116  // IInterface implementation
117  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
118  // ==========================================================================
119 protected:
120  // get local or remote property by name
121  Gaudi::Details::PropertyBase* property( const std::string& name ) const;
122 
123 private:
126  const std::vector<Gaudi::Details::PropertyBase*>& props ) const;
127 
130  void assertUniqueName( const std::string& name ) const;
131 
132  // Some typedef to simply typing
136 
138  Properties m_properties; // local properties
140  RemoteProperties m_remoteProperties; // Remote properties
144  IInterface* m_pOuter; // Interface hub reference
145 };
146 // ============================================================================
148 // ============================================================================
149 template <class TYPE, typename>
151  const std::string& doc )
152 {
153  assertUniqueName( name );
154  m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
156  //
157  p->setDocumentation( doc );
158  m_properties.push_back( p );
159  //
160  return p;
161 }
162 // ============================================================================
164 // ============================================================================
165 template <class TYPE>
167  const std::string& doc )
168 {
169  assertUniqueName( name );
170  Gaudi::Details::PropertyBase* p = &prop;
171  //
172  p->setName( name );
173  p->setDocumentation( doc );
174  m_properties.push_back( p );
175  //
176  return p;
177 }
178 // ============================================================================
180 // ============================================================================
181 template <class TYPE>
184 {
185  assertUniqueName( name );
186  Gaudi::Details::PropertyBase* p = &prop;
187  //
188  p->setName( name );
189  p->setDocumentation( doc );
190  m_properties.push_back( p );
191  //
192  return p;
193 }
194 
195 // ============================================================================
196 // The END
197 // ============================================================================
198 #endif // GAUDIKERNEL_PROPERTYMGR_H
199 // ============================================================================
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:135
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:381
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:134
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:133
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:33
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:51
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:354
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:138
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:142
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:94
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:20
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:104
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:144
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:140
T emplace_back(T...args)