Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
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 // ============================================================================
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,
51  >::type >
53  const std::string& doc = "none" );
55  template <class TYPE>
57  const std::string& doc = "none" );
59  template <class TYPE>
61  const std::string& doc = "none" );
62 
63  // partial specializations for various GaudiHandles
67  const std::string& doc = "none" ) ;
71  const std::string& doc = "none" ) ;
75  const std::string& doc = "none" ) ;
78  const std::string& rname = "" );
79  // ==========================================================================
80  // IProperty implementation
81  // ==========================================================================
86  // ==========================================================================
90  StatusCode setProperty( const std::string& s ) override;
91  // ==========================================================================
95  StatusCode setProperty( const std::string& n, const std::string& v ) override;
96  // ==========================================================================
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  // ==========================================================================
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:
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
142 
144  Properties m_properties; // local properties
146  RemoteProperties m_remoteProperties; // Remote properties
150  IInterface* m_pOuter; // Interface hub reference
151 };
152 // ============================================================================
154 // ============================================================================
155 template<class TYPE, typename >
158  TYPE& value,
159  const std::string& doc )
160 {
161  assertUniqueName( name );
162  m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
164  //
165  p->setDocumentation( doc );
166  m_properties.push_back( p );
167  //
168  return p;
169 }
170 // ============================================================================
172 // ============================================================================
173 template <class TYPE>
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>
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 // ============================================================================
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:141
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:314
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:140
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:139
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:38
T push_back(T...args)
Interface ID class.
Definition: IInterface.h:30
class GAUDI_API[[deprecated("will be removed in v29r0, consider using PropertyHolder instead")]] PropertyMgr
Definition: PropertyMgr.h:32
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:26
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:234
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:364
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:144
Helper class to implement the IProperty interface.
T back(T...args)
string s
Definition: gaudirun.py:245
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:148
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:22
~PropertyMgr() override=default
virtual destructor
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:107
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:150
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:146
T emplace_back(T...args)