| The Gaudi Framework v32r1 (f65d50dc)

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 // ============================================================================
15 #include "GaudiKernel/DataObjectHandleBase.h"
16 #include "GaudiKernel/GaudiHandle.h"
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>
52 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
53 const std::string& doc = "none" );
55 template <class TYPE>
56 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop,
57 const std::string& doc = "none" );
58
59 // partial specializations for various GaudiHandles
61 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, GaudiHandleBase& ref,
62 const std::string& doc = "none" );
64 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, GaudiHandleArrayBase& ref,
65 const std::string& doc = "none" );
67 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, DataObjectHandleBase& ref,
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 // ==========================================================================
78 StatusCode setProperty( const Gaudi::Details::PropertyBase& p ) override;
79 // ==========================================================================
83 StatusCode setProperty( const std::string& s ) override;
84 // ==========================================================================
88 StatusCode setProperty( const std::string& n, const std::string& v ) override;
89 // ==========================================================================
93 StatusCode getProperty( Gaudi::Details::PropertyBase * p ) const override;
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:
124 Gaudi::Details::PropertyBase* property( const std::string& name,
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
132 typedef std::vector<Gaudi::Details::PropertyBase*> Properties;
133 typedef std::pair<std::string, std::pair<IProperty*, std::string>> RemProperty;
134 typedef std::vector<RemProperty> RemoteProperties;
135
137 Properties m_properties; // local properties
139 RemoteProperties m_remoteProperties; // Remote properties
141 std::vector<std::unique_ptr<Gaudi::Details::PropertyBase>> m_todelete; // properties to be deleted
143 IInterface* m_pOuter; // Interface hub reference
144 };
145 // ============================================================================
147 // ============================================================================
148 template <class TYPE, typename>
149 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, TYPE& value,
150 const std::string& doc ) {
151 assertUniqueName( name );
152 m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
153 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
154 //
155 p->setDocumentation( doc );
156 m_properties.push_back( p );
157 //
158 return p;
159 }
160 // ============================================================================
162 // ============================================================================
163 template <class TYPE>
164 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
165 const std::string& doc ) {
166 assertUniqueName( name );
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>
179 inline Gaudi::Details::PropertyBase*
180 PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop, const std::string& doc ) {
181 assertUniqueName( name );
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
implements
Base class used to implement the interfaces.
Definition: implements.h:9
PropertyMgr::m_pOuter
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:143
PropertyMgr::m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:141
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:86
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
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:95
getProperty
const char *PyHelper() getProperty(IInterface *p, char *name)
Definition: Bootstrap.cpp:237
PropertyMgr
Property manager helper class.
Definition: PropertyMgr.h:33
PropertyMgr::assertUniqueName
void assertUniqueName(const std::string &name) const
Throw an exception if the name is already present in the list of properties (see GAUDI-1023).
Definition: PropertyMgr.cpp:212
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
implements::operator=
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:34
std::vector::push_back
T push_back(T... args)
InterfaceID
Interface ID class.
Definition: IInterface.h:29
PropertyMgr::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:137
PropertyMgr::m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:139
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
PropertyMgr::RemProperty
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:133
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:233
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
PropertyMgr::Properties
std::vector< Gaudi::Details::PropertyBase * > Properties
Definition: PropertyMgr.h:132
Gaudi::Details::PropertyBase::setName
void setName(std::string value)
set the new value for the property name
Definition: Property.h:84
std::pair
DataObjectHandleBase.h
std::unique_ptr::get
T get(T... args)
GaudiHandleArrayBase
Base class of array's of various gaudihandles.
Definition: GaudiHandle.h:330
IProperty.h
std::vector< Gaudi::Details::PropertyBase * >
PropertyMgr::declareProperty
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:149
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:26
Property.h
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:71
std::vector::back
T back(T... args)
gaudirun.s
string s
Definition: gaudirun.py:316
GaudiHandleBase
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:89
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:20
PropertyMgr::RemoteProperties
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:134
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
GaudiHandle.h
std::vector::emplace_back
T emplace_back(T... args)