The Gaudi Framework  v32r2 (46d42edc)
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 public:
37  PropertyMgr( IInterface* iface = nullptr );
38  // copy constructor
39  PropertyMgr( const PropertyMgr& ) = delete;
40  // assignment operator
41  PropertyMgr& operator=( const PropertyMgr& ) = delete;
42 
43 public:
45  template <class TYPE, typename = std::enable_if_t<!std::is_base_of_v<GaudiHandleBase, TYPE> &&
46  !std::is_base_of_v<GaudiHandleArrayBase, TYPE> &&
47  !std::is_base_of_v<DataObjectHandleBase, TYPE>>>
48  Gaudi::Details::PropertyBase* declareProperty( const std::string& name, TYPE& value,
49  const std::string& doc = "none" );
51  template <class TYPE>
53  const std::string& doc = "none" );
55  template <class TYPE>
57  const std::string& doc = "none" );
58 
59  // partial specializations for various GaudiHandles
62  const std::string& doc = "none" );
65  const std::string& doc = "none" );
68  const std::string& doc = "none" );
70  Gaudi::Details::PropertyBase* declareRemoteProperty( const std::string& name, IProperty* rsvc,
71  const std::string& rname = "" );
72  // ==========================================================================
73  // IProperty implementation
74  // ==========================================================================
79  // ==========================================================================
83  StatusCode setProperty( const std::string& s ) override;
84  // ==========================================================================
88  StatusCode setProperty( const std::string& n, const std::string& v ) override;
89  // ==========================================================================
94  // ==========================================================================
98  const Gaudi::Details::PropertyBase& getProperty( const std::string& name ) const override;
99  // ==========================================================================
103  StatusCode getProperty( const std::string& n, std::string& v ) const override;
104  // ==========================================================================
108  const std::vector<Gaudi::Details::PropertyBase*>& getProperties() const override;
109  // ==========================================================================
113  bool hasProperty( const std::string& name ) const override;
114  // ==========================================================================
115  // IInterface implementation
116  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
117  // ==========================================================================
118 protected:
119  // get local or remote property by name
120  Gaudi::Details::PropertyBase* property( const std::string& name ) const;
121 
122 private:
125  const std::vector<Gaudi::Details::PropertyBase*>& props ) const;
126 
129  void assertUniqueName( const std::string& name ) const;
130 
131  // Some typedef to simply typing
135 
137  Properties m_properties; // local properties
139  RemoteProperties m_remoteProperties; // Remote properties
143  IInterface* m_pOuter; // Interface hub reference
144 };
145 // ============================================================================
147 // ============================================================================
148 template <class TYPE, typename>
150  const std::string& doc ) {
154  //
155  p->setDocumentation( doc );
156  m_properties.push_back( p );
157  //
158  return p;
159 }
160 // ============================================================================
162 // ============================================================================
163 template <class TYPE>
165  const std::string& doc ) {
167  Gaudi::Details::PropertyBase* p = &prop;
168  //
169  p->setName( name );
170  p->setDocumentation( doc );
171  m_properties.push_back( p );
172  //
173  return p;
174 }
175 // ============================================================================
177 // ============================================================================
178 template <class TYPE>
182  Gaudi::Details::PropertyBase* p = &prop;
183  //
184  p->setName( name );
185  p->setDocumentation( doc );
186  m_properties.push_back( p );
187  //
188  return p;
189 }
190 
191 // ============================================================================
192 // The END
193 // ============================================================================
194 #endif // GAUDIKERNEL_PROPERTYMGR_H
Base class used to implement the interfaces.
Definition: implements.h:9
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:143
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:141
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:86
Implementation of property with value of concrete type.
Definition: Property.h:352
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:95
const char *PyHelper() getProperty(IInterface *p, char *name)
Definition: Bootstrap.cpp:237
Property manager helper class.
Definition: PropertyMgr.h:33
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
STL class.
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:34
T push_back(T... args)
Interface ID class.
Definition: IInterface.h:29
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:137
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:139
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Definition of the basic interface.
Definition: IInterface.h:244
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:133
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:233
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::vector< Gaudi::Details::PropertyBase * > Properties
Definition: PropertyMgr.h:132
void setName(std::string value)
set the new value for the property name
Definition: Property.h:84
T get(T... args)
Base class of array's of various gaudihandles.
Definition: GaudiHandle.h:330
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:149
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Helper class to implement the IProperty interface.
T back(T... args)
string s
Definition: gaudirun.py:318
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:89
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:20
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:134
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20
#define GAUDI_API
Definition: Kernel.h:71
T emplace_back(T... args)