Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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<GaudiHandleBase, 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" );
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  // ==========================================================================
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 ) {
151  assertUniqueName( name );
152  m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
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 ) {
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>
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
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:134
Base class used to implement the interfaces.
Definition: implements.h:9
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
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:133
struct deprecated("use MergingTransformer instead")]] ListTransformer
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:132
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:34
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:50
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:244
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:84
T get(T...args)
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:330
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:137
Helper class to implement the IProperty interface.
T back(T...args)
string s
Definition: gaudirun.py:312
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:141
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
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:71
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:143
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:139
T emplace_back(T...args)