| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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/DataObjectHandleProperty.h"
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,
48 typename = typename std::enable_if< !std::is_base_of<GaudiHandleBase,TYPE>::value
49 && !std::is_base_of<GaudiHandleArrayBase,TYPE>::value
50 && !std::is_base_of<DataObjectHandleBase,TYPE>::value
51 >::type >
52 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, TYPE& value,
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" );
59 template <class TYPE>
60 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop,
61 const std::string& doc = "none" );
62
63 // partial specializations for various GaudiHandles
65 Gaudi::Details::PropertyBase* declareProperty ( const std::string& name,
66 GaudiHandleBase& ref,
67 const std::string& doc = "none" ) ;
69 Gaudi::Details::PropertyBase* declareProperty ( const std::string& name,
70 GaudiHandleArrayBase& ref,
71 const std::string& doc = "none" ) ;
73 Gaudi::Details::PropertyBase* declareProperty ( const std::string& name,
74 DataObjectHandleBase& ref,
75 const std::string& doc = "none" ) ;
77 Gaudi::Details::PropertyBase* declareRemoteProperty( const std::string& name, IProperty* rsvc,
78 const std::string& rname = "" );
79 // ==========================================================================
80 // IProperty implementation
81 // ==========================================================================
85 StatusCode setProperty( const Gaudi::Details::PropertyBase& p ) override;
86 // ==========================================================================
90 StatusCode setProperty( const std::string& s ) override;
91 // ==========================================================================
95 StatusCode setProperty( const std::string& n, const std::string& v ) override;
96 // ==========================================================================
100 StatusCode getProperty( Gaudi::Details::PropertyBase * p ) const override;
101 // ==========================================================================
105 const Gaudi::Details::PropertyBase& getProperty( const std::string& name ) const override;
106 // ==========================================================================
110 StatusCode getProperty( const std::string& n, std::string& v ) const override;
111 // ==========================================================================
115 const std::vector<Gaudi::Details::PropertyBase*>& getProperties() const override;
116 // ==========================================================================
120 bool hasProperty( const std::string& name ) const override;
121 // ==========================================================================
122 // IInterface implementation
123 StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
124 // ==========================================================================
125 protected:
126 // get local or remote property by name
127 Gaudi::Details::PropertyBase* property( const std::string& name ) const;
128
129 private:
131 Gaudi::Details::PropertyBase* property( const std::string& name,
132 const std::vector<Gaudi::Details::PropertyBase*>& props ) const;
133
136 void assertUniqueName( const std::string& name ) const;
137
138 // Some typedef to simply typing
139 typedef std::vector<Gaudi::Details::PropertyBase*> Properties;
140 typedef std::pair<std::string, std::pair<IProperty*, std::string>> RemProperty;
141 typedef std::vector<RemProperty> RemoteProperties;
142
144 Properties m_properties; // local properties
146 RemoteProperties m_remoteProperties; // Remote properties
148 std::vector<std::unique_ptr<Gaudi::Details::PropertyBase>> m_todelete; // properties to be deleted
150 IInterface* m_pOuter; // Interface hub reference
151 };
152 // ============================================================================
154 // ============================================================================
155 template<class TYPE, typename >
156 inline Gaudi::Details::PropertyBase*
157 PropertyMgr::declareProperty ( const std::string& name ,
158 TYPE& value,
159 const std::string& doc )
160 {
161 assertUniqueName( name );
162 m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
163 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
164 //
165 p->setDocumentation( doc );
166 m_properties.push_back( p );
167 //
168 return p;
169 }
170 // ============================================================================
172 // ============================================================================
173 template <class TYPE>
174 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
175 const std::string& doc )
176 {
177 assertUniqueName( name );
178 Gaudi::Details::PropertyBase* p = &prop;
179 //
180 p->setName( name );
181 p->setDocumentation( doc );
182 m_properties.push_back( p );
183 //
184 return p;
185 }
186 // ============================================================================
188 // ============================================================================
189 template <class TYPE>
190 inline Gaudi::Details::PropertyBase*
191 PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop, const std::string& doc )
192 {
193 assertUniqueName( name );
194 Gaudi::Details::PropertyBase* p = &prop;
195 //
196 p->setName( name );
197 p->setDocumentation( doc );
198 m_properties.push_back( p );
199 //
200 return p;
201 }
202
203 // ============================================================================
204 // The END
205 // ============================================================================
206 #endif // GAUDIKERNEL_PROPERTYMGR_H
207 // ============================================================================
RemoteProperties
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:141
implements
Base class used to implement the interfaces.
Definition: implements.h:9
DataObjectHandleProperty.h
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
RemProperty
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:140
Gaudi::Functional::deprecated
struct deprecated("use MergingTransformer instead")]] ListTransformer
Definition: ListTransformer.h:9
property
Gaudi::Details::PropertyBase * property(const std::string &name) const
declareRemoteProperty
Gaudi::Details::PropertyBase * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="")
Declare a remote property.
Properties
std::vector< Gaudi::Details::PropertyBase * > Properties
Definition: PropertyMgr.h:139
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).
PropertyMgr
Property manager helper class.
std::enable_if
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
implements::operator=
implements & operator=(const implements &)
Assignment operator (do not touch the reference count).
Definition: implements.h:38
std::vector::push_back
T push_back(T...args)
InterfaceID
Interface ID class.
Definition: IInterface.h:30
PropertyMgr
class GAUDI_API[[deprecated("will be removed in v29r0, consider using PropertyHolder instead")]] PropertyMgr
Definition: PropertyMgr.h:32
hasProperty
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
declareProperty
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
gaudirun.type
type
Definition: gaudirun.py:125
getProperty
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
Gaudi::Details::PropertyBase::setName
void setName(std::string value)
set the new value for the property name
Definition: Property.h:90
std::pair
std::unique_ptr::get
T get(T...args)
GaudiHandleArrayBase
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:364
IProperty.h
std::vector< Gaudi::Details::PropertyBase * >
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:24
Property.h
std::is_base_of
m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:144
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:73
std::vector::back
T back(T...args)
gaudirun.s
string s
Definition: gaudirun.py:245
m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:148
GaudiHandleBase
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:94
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:22
~PropertyMgr
~PropertyMgr() override=default
virtual destructor
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
getProperties
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
m_pOuter
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:150
m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:146
std::vector::emplace_back
T emplace_back(T...args)