File indexing completed on 2025-02-21 10:00:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_PROPERTYMGR_H
0012 #define GAUDIKERNEL_PROPERTYMGR_H
0013
0014
0015
0016
0017
0018 #include <iostream>
0019 #include <stdexcept>
0020 #include <utility>
0021 #include <vector>
0022
0023
0024
0025 #include "GaudiKernel/DataHandle.h"
0026 #include "GaudiKernel/GaudiHandle.h"
0027 #include "GaudiKernel/IProperty.h"
0028 #include <Gaudi/Property.h>
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 class [[deprecated( "will be removed in v29r0, consider using PropertyHolder instead" )]] PropertyMgr
0044 : public implements<IProperty> {
0045 public:
0046
0047 PropertyMgr( IInterface* iface = nullptr );
0048
0049 PropertyMgr( const PropertyMgr& ) = delete;
0050
0051 PropertyMgr& operator=( const PropertyMgr& ) = delete;
0052
0053 public:
0054
0055 template <class TYPE, typename = std::enable_if_t<!std::is_base_of_v<GaudiHandleBase, TYPE> &&
0056 !std::is_base_of_v<GaudiHandleArrayBase, TYPE> &&
0057 !std::is_base_of_v<Gaudi::DataHandle, TYPE>>>
0058 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, TYPE& value,
0059 const std::string& doc = "none" );
0060
0061 template <class TYPE>
0062 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
0063 const std::string& doc = "none" );
0064
0065 template <class TYPE>
0066 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop,
0067 const std::string& doc = "none" );
0068
0069
0070
0071 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, GaudiHandleBase& ref,
0072 const std::string& doc = "none" );
0073
0074 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, GaudiHandleArrayBase& ref,
0075 const std::string& doc = "none" );
0076
0077 Gaudi::Details::PropertyBase* declareProperty( const std::string& name, Gaudi::DataHandle& ref,
0078 const std::string& doc = "none" );
0079
0080 Gaudi::Details::PropertyBase* declareRemoteProperty( const std::string& name, IProperty* rsvc,
0081 const std::string& rname = "" );
0082
0083
0084
0085
0086
0087
0088 StatusCode setProperty( const std::string& name, const Gaudi::Details::PropertyBase& p ) override;
0089
0090
0091
0092
0093 StatusCode setProperty( const std::string& s ) override;
0094
0095
0096
0097
0098 StatusCode setPropertyRepr( const std::string& n, const std::string& v ) override;
0099
0100
0101
0102
0103 StatusCode getProperty( Gaudi::Details::PropertyBase* p ) const override;
0104
0105
0106
0107
0108 const Gaudi::Details::PropertyBase& getProperty( std::string_view name ) const override;
0109
0110
0111
0112
0113 StatusCode getProperty( std::string_view n, std::string& v ) const override;
0114
0115
0116
0117
0118 const std::vector<Gaudi::Details::PropertyBase*>& getProperties() const override;
0119
0120
0121
0122
0123 bool hasProperty( std::string_view name ) const override;
0124
0125
0126 StatusCode queryInterface( const InterfaceID& iid, void** pinterface ) override;
0127
0128 protected:
0129
0130 Gaudi::Details::PropertyBase* property( std::string_view name ) const;
0131
0132 private:
0133
0134 Gaudi::Details::PropertyBase* property( std::string_view name,
0135 const std::vector<Gaudi::Details::PropertyBase*>& props ) const;
0136
0137
0138
0139 void assertUniqueName( const std::string& name ) const;
0140
0141
0142 typedef std::vector<Gaudi::Details::PropertyBase*> Properties;
0143 typedef std::pair<std::string, std::pair<IProperty*, std::string>> RemProperty;
0144 typedef std::vector<RemProperty> RemoteProperties;
0145
0146
0147 Properties m_properties;
0148
0149 RemoteProperties m_remoteProperties;
0150
0151 std::vector<std::unique_ptr<Gaudi::Details::PropertyBase>> m_todelete;
0152
0153 IInterface* m_pOuter;
0154 };
0155
0156
0157
0158 template <class TYPE, typename>
0159 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, TYPE& value,
0160 const std::string& doc ) {
0161 assertUniqueName( name );
0162 m_todelete.emplace_back( new Gaudi::Property<TYPE&>( name, value ) );
0163 Gaudi::Details::PropertyBase* p = m_todelete.back().get();
0164
0165 p->setDocumentation( doc );
0166 m_properties.push_back( p );
0167
0168 return p;
0169 }
0170
0171
0172
0173 template <class TYPE>
0174 inline Gaudi::Details::PropertyBase* PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE>& prop,
0175 const std::string& doc ) {
0176 assertUniqueName( name );
0177 Gaudi::Details::PropertyBase* p = ∝
0178
0179 p->setName( name );
0180 p->setDocumentation( doc );
0181 m_properties.push_back( p );
0182
0183 return p;
0184 }
0185
0186
0187
0188 template <class TYPE>
0189 inline Gaudi::Details::PropertyBase*
0190 PropertyMgr::declareProperty( const std::string& name, Gaudi::Property<TYPE&>& prop, const std::string& doc ) {
0191 assertUniqueName( name );
0192 Gaudi::Details::PropertyBase* p = ∝
0193
0194 p->setName( name );
0195 p->setDocumentation( doc );
0196 m_properties.push_back( p );
0197
0198 return p;
0199 }
0200
0201
0202
0203
0204 #endif