The Gaudi Framework  master (37c0b60a)
PropertyMgr.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_PROPERTYMGR_H
12 #define GAUDIKERNEL_PROPERTYMGR_H
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 // STD & STL
17 // ============================================================================
18 #include <iostream>
19 #include <stdexcept>
20 #include <utility>
21 #include <vector>
22 // ============================================================================
23 // GaudiKernel
24 // ============================================================================
25 #include <Gaudi/Property.h>
26 #include <GaudiKernel/DataHandle.h>
28 #include <GaudiKernel/IProperty.h>
29 
30 // ============================================================================
31 
43 class [[deprecated( "will be removed in v29r0, consider using PropertyHolder instead" )]] PropertyMgr
44  : public implements<IProperty> {
45 public:
47  PropertyMgr( IInterface* iface = nullptr );
48  // copy constructor
49  PropertyMgr( const PropertyMgr& ) = delete;
50  // assignment operator
51  PropertyMgr& operator=( const PropertyMgr& ) = delete;
52 
53 public:
55  template <class TYPE, typename = std::enable_if_t<!std::is_base_of_v<GaudiHandleBase, TYPE> &&
56  !std::is_base_of_v<GaudiHandleArrayBase, TYPE> &&
57  !std::is_base_of_v<Gaudi::DataHandle, TYPE>>>
58  Gaudi::Details::PropertyBase* declareProperty( const std::string& name, TYPE& value,
59  const std::string& doc = "none" );
61  template <class TYPE>
63  const std::string& doc = "none" );
65  template <class TYPE>
67  const std::string& doc = "none" );
68 
69  // partial specializations for various GaudiHandles
72  const std::string& doc = "none" );
75  const std::string& doc = "none" );
78  const std::string& doc = "none" );
80  Gaudi::Details::PropertyBase* declareRemoteProperty( const std::string& name, IProperty* rsvc,
81  const std::string& rname = "" );
82  // ==========================================================================
83  // IProperty implementation
84  // ==========================================================================
89  // ==========================================================================
93  StatusCode setProperty( const std::string& s ) override;
94  // ==========================================================================
98  StatusCode setPropertyRepr( const std::string& n, const std::string& v ) override;
99  // ==========================================================================
104  // ==========================================================================
108  const Gaudi::Details::PropertyBase& getProperty( std::string_view name ) const override;
109  // ==========================================================================
113  StatusCode getProperty( std::string_view n, std::string& v ) const override;
114  // ==========================================================================
118  const std::vector<Gaudi::Details::PropertyBase*>& getProperties() const override;
119  // ==========================================================================
123  bool hasProperty( std::string_view name ) const override;
124  // ==========================================================================
125  // IInterface implementation
126  StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
127  // ==========================================================================
128 protected:
129  // get local or remote property by name
130  Gaudi::Details::PropertyBase* property( std::string_view name ) const;
131 
132 private:
134  Gaudi::Details::PropertyBase* property( std::string_view name,
136 
139  void assertUniqueName( const std::string& name ) const;
140 
141  // Some typedef to simply typing
145 
147  Properties m_properties; // local properties
149  RemoteProperties m_remoteProperties; // Remote properties
153  IInterface* m_pOuter; // Interface hub reference
154 };
155 // ============================================================================
157 // ============================================================================
158 template <class TYPE, typename>
160  const std::string& doc ) {
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 ) {
177  Gaudi::Details::PropertyBase* p = &prop;
178  //
179  p->setName( name );
180  p->setDocumentation( doc );
181  m_properties.push_back( p );
182  //
183  return p;
184 }
185 // ============================================================================
187 // ============================================================================
188 template <class TYPE>
192  Gaudi::Details::PropertyBase* p = &prop;
193  //
194  p->setName( name );
195  p->setDocumentation( doc );
196  m_properties.push_back( p );
197  //
198  return p;
199 }
200 
201 // ============================================================================
202 // The END
203 // ============================================================================
204 #endif // GAUDIKERNEL_PROPERTYMGR_H
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:30
GaudiHandle.h
std::string
STL class.
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:247
std::pair
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector< Gaudi::Details::PropertyBase * >
check_ParticleID.props
props
Definition: check_ParticleID.py:21
PropertyMgr::m_pOuter
IInterface * m_pOuter
Interface hub reference (ApplicationMgr)
Definition: PropertyMgr.h:153
PropertyMgr
Definition: PropertyMgr.h:44
PropertyMgr::PropertyMgr
PropertyMgr(const PropertyMgr &)=delete
Gaudi::DataHandle
Definition: DataHandle.h:38
std::unique_ptr::get
T get(T... args)
PropertyMgr::declareProperty
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:159
std::vector::back
T back(T... args)
PropertyHolder
Helper class to implement the IProperty interface.
Definition: PropertyHolder.h:82
PropertyMgr::RemProperty
std::pair< std::string, std::pair< IProperty *, std::string > > RemProperty
Definition: PropertyMgr.h:143
PropertyMgr::operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
GaudiHandleBase
Definition: GaudiHandle.h:105
Properties
Definition: Properties.py:1
std::vector::push_back
T push_back(T... args)
IProperty
Definition: IProperty.h:33
PropertyMgr::RemoteProperties
std::vector< RemProperty > RemoteProperties
Definition: PropertyMgr.h:144
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: PropertyBase.h:91
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
StatusCode
Definition: StatusCode.h:65
PropertyMgr::m_todelete
std::vector< std::unique_ptr< Gaudi::Details::PropertyBase > > m_todelete
Properties to be deleted.
Definition: PropertyMgr.h:151
GaudiHandleArrayBase
Base class of array's of various gaudihandles.
Definition: GaudiHandle.h:348
cpluginsvc.n
n
Definition: cpluginsvc.py:234
PropertyMgr::Properties
std::vector< Gaudi::Details::PropertyBase * > Properties
Definition: PropertyMgr.h:142
implements
Base class used to implement the interfaces.
Definition: implements.h:19
std::vector::emplace_back
T emplace_back(T... args)
PropertyMgr::m_remoteProperties
RemoteProperties m_remoteProperties
Collection of all declared remote properties.
Definition: PropertyMgr.h:149
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
PropertyMgr::m_properties
Properties m_properties
Collection of all declared properties.
Definition: PropertyMgr.h:147
IInterface
Definition: IInterface.h:239
DataHandle.h
Properties.v
v
Definition: Properties.py:122
Gaudi::Details::PropertyBase::setName
void setName(std::string value)
set the new value for the property name
Definition: PropertyBase.h:89
IProperty.h
InterfaceID
Definition: IInterface.h:39
compareRootHistos.ref
ref
Definition: compareRootHistos.py:27
getProperty
const char *PyHelper() getProperty(IInterface *p, char *name)
Definition: Bootstrap.cpp:251
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
Gaudi::Utils::hasProperty
GAUDI_API bool hasProperty(const IProperty *p, std::string_view name)
simple function which check the existence of the property with the given name.
Definition: Property.cpp:106
Property.h