The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
Property.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
15#include <Gaudi/PropertyFwd.h>
17#include <GaudiKernel/Kernel.h>
18#include <GaudiKernel/SmartIF.h>
21#include <string>
22#include <string_view>
23#include <utility>
24
25namespace Gaudi {
33 template <class TYPE, class VERIFIER = Details::Property::NullVerifier,
34 class HANDLERS = Details::Property::UpdateHandler>
35 class Property : public Details::PropertyBase {
36 public:
38 using StorageType = TYPE;
39 using ValueType = typename std::remove_reference<StorageType>::type;
40 using VerifierType = VERIFIER;
41 using HandlersType = HANDLERS;
42
43 private:
47
48 public:
50 template <class T = StorageType>
51 Property( std::string name, T&& value, std::string doc = "", std::string semantics = "" )
52 : Details::PropertyBase( typeid( ValueType ), std::move( name ), std::move( doc ), std::move( semantics ) )
53 , m_value( std::forward<T>( value ) ) {
55 }
56
58 template <std::derived_from<IProperty> OWNER, typename T = ValueType>
59 requires( std::is_default_constructible_v<T> )
60 Property( OWNER* owner, std::string name ) : Property( std::move( name ), ValueType{}, "" ) {
61 owner->declareProperty( *this );
63 }
64
67 template <std::derived_from<IProperty> OWNER, class T = StorageType>
68 Property( OWNER* owner, std::string name, T&& value, std::string doc = "", std::string semantics = "" )
69 : Property( std::move( name ), std::forward<T>( value ), std::move( doc ), std::move( semantics ) ) {
70 owner->declareProperty( *this );
72 }
73
76 template <std::derived_from<IProperty> OWNER, class T = StorageType>
77 Property( OWNER* owner, std::string name, T&& value, std::function<void( PropertyBase& )> handler,
78 std::string doc = "", std::string semantics = "" )
79 : Property( owner, std::move( name ), std::forward<T>( value ), std::move( doc ), std::move( semantics ) ) {
80 declareUpdateHandler( std::move( handler ) );
81 }
82
85 template <std::derived_from<IProperty> OWNER, class T = StorageType>
86 Property( OWNER* owner, std::string name, T&& value, void ( OWNER::*handler )( PropertyBase& ),
87 std::string doc = "", std::string semantics = "" )
88 : Property(
89 owner, std::move( name ), std::forward<T>( value ),
90 [owner, handler]( PropertyBase& p ) { ( owner->*handler )( p ); }, std::move( doc ),
91 std::move( semantics ) ) {}
92
94 template <std::derived_from<IProperty> OWNER, class T = StorageType>
95 Property( OWNER* owner, std::string name, T&& value, void ( OWNER::*handler )(), std::string doc = "",
96 std::string semantics = "" )
97 : Property(
98 owner, std::move( name ), std::forward<T>( value ),
99 [owner, handler]( PropertyBase& ) { ( owner->*handler )(); }, std::move( doc ), std::move( semantics ) ) {
100 }
101
104 template <std::derived_from<IProperty> OWNER, class T = StorageType>
105 Property( OWNER* owner, std::string name, T&& value, std::function<void( PropertyBase& )> handler,
106 Details::Property::ImmediatelyInvokeHandler invoke, std::string doc = "", std::string semantics = "" )
107 : Property( owner, std::move( name ), std::forward<T>( value ), std::move( handler ), std::move( doc ),
108 std::move( semantics ) ) {
109 if ( invoke ) useUpdateHandler();
110 }
111
115 template <typename T>
116 requires( !std::is_same_v<Property, std::remove_reference_t<T>> )
117 [[deprecated( "anonymous properties are deprecated" )]] Property( T&& v )
118 : Details::PropertyBase( typeid( ValueType ), "", "", "" ), m_value( std::forward<T>( v ) ) {}
119
122 template <typename T = StorageType>
123 requires( !std::is_reference_v<T> )
124 Property() : Details::PropertyBase( typeid( ValueType ), "", "", "" ), m_value() {}
125
128
130 Details::PropertyBase& declareReadHandler( std::function<void( Details::PropertyBase& )> fun ) override {
131 m_handlers.setReadHandler( std::move( fun ) );
132 return *this;
133 }
134
135 Details::PropertyBase& declareUpdateHandler( std::function<void( Details::PropertyBase& )> fun ) override {
136 m_handlers.setUpdateHandler( std::move( fun ) );
137 return *this;
138 }
139
141 const std::function<void( Details::PropertyBase& )> readCallBack() const override {
142 return m_handlers.getReadHandler();
143 }
144
145 const std::function<void( Details::PropertyBase& )> updateCallBack() const override {
146 return m_handlers.getUpdateHandler();
147 }
148
150 bool useUpdateHandler() override {
151 m_handlers.useUpdateHandler( *this );
152 return true;
153 }
154
156 operator const ValueType&() const {
157 m_handlers.useReadHandler( *this );
158 return m_value;
159 }
160 // /// Automatic conversion to value (reference).
161 // operator ValueType& () {
162 // useReadHandler();
163 // return m_value;
164 // }
165
166 template <typename Dummy = TYPE>
167 requires( std::is_constructible_v<std::string_view, Dummy> )
168 operator std::string_view() const {
169 m_handlers.useReadHandler( *this );
170 return m_value;
171 }
172
174 std::ostream& fillStream( std::ostream& stream ) const override {
175 stream << " '" << name() << "':";
176 if constexpr ( std::is_same_v<ValueType, std::string> ) {
178 toStream( value(), stream );
179 } else {
180 stream << toString();
181 }
182 return stream;
183 }
184
185 operator std::string_view() const {
186 m_handlers.useReadHandler( *this );
187 return m_value;
188 }
189
191 template <class T>
192 bool operator==( const T& other ) const {
193 return m_value == other;
194 }
195
197 template <class T>
198 bool operator!=( const T& other ) const {
199 return m_value != other;
200 }
201
203 template <class T>
204 bool operator<( const T& other ) const {
205 return m_value < other;
206 }
207
209 template <class T>
210 decltype( auto ) operator+( const T& other ) const {
211 return m_value + other;
212 }
213
215 template <class T = ValueType>
216 Property& operator=( T&& v ) {
217 m_verifier( v );
218 m_value = std::forward<T>( v );
219 m_handlers.useUpdateHandler( *this );
220 return *this;
221 }
222
224 const VerifierType& verifier() const { return m_verifier; }
227
229 const ValueType& value() const { return *this; }
230 ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
231 bool setValue( const ValueType& v ) {
232 *this = v;
233 return true;
234 }
235 bool set( const ValueType& v ) {
236 *this = v;
237 return true;
238 }
239 Details::PropertyBase* clone() const override { return new Property( *this ); }
241
245 template <class T = const ValueType>
246 decltype( auto ) size() const {
247 return value().size();
248 }
249 template <class T = const ValueType, typename = decltype( std::declval<const T>().length() )>
250 decltype( auto ) length() const {
251 return value().length();
252 }
253 template <class T = const ValueType>
254 decltype( auto ) empty() const {
255 return value().empty();
256 }
257 template <class T = ValueType>
258 decltype( auto ) clear() {
259 value().clear();
260 }
261 template <class T = const ValueType, typename = decltype( std::declval<const T>().begin() )>
262 decltype( auto ) begin() const {
263 return value().begin();
264 }
265 template <class T = const ValueType>
266 decltype( auto ) end() const {
267 return value().end();
268 }
269 template <class T = ValueType, typename = decltype( std::declval<T>().begin() )>
270 decltype( auto ) begin() {
271 return value().begin();
272 }
273 template <class T = ValueType>
274 decltype( auto ) end() {
275 return value().end();
276 }
277 template <class ARG>
278 decltype( auto ) operator[]( const ARG& arg ) const {
279 return value()[arg];
280 }
281 template <class ARG>
282 decltype( auto ) operator[]( const ARG& arg ) {
283 return value()[arg];
284 }
285 template <class T = const ValueType>
286 decltype( auto ) find( const typename T::key_type& key ) const {
287 return value().find( key );
288 }
289 template <class T = ValueType>
290 decltype( auto ) find( const typename T::key_type& key ) {
291 return value().find( key );
292 }
293 template <class ARG, class T = ValueType>
294 decltype( auto ) erase( ARG arg ) {
295 return value().erase( arg );
296 }
297 template <class = ValueType>
299 ++value();
300 return *this;
301 }
302 template <class = ValueType>
304 return m_value++;
305 }
306 template <class = ValueType>
308 --value();
309 return *this;
310 }
311 template <class = ValueType>
313 return m_value--;
314 }
315 template <class T = ValueType>
316 Property& operator+=( const T& other ) {
317 m_value += other;
318 return *this;
319 }
320 template <class T = ValueType>
321 Property& operator-=( const T& other ) {
322 m_value -= other;
323 return *this;
324 }
325
326 template <class T = const ValueType>
327 decltype( auto ) key() const {
328 return value().key();
329 }
330 template <class T = const ValueType>
331 decltype( auto ) objKey() const {
332 return value().objKey();
333 }
334 template <class T = const ValueType>
335 decltype( auto ) fullKey() const {
336 return value().fullKey();
337 }
338 template <class T = ValueType>
339 decltype( auto ) initialize() {
340 return value().initialize();
341 }
342 template <class T = ValueType>
343 decltype( auto ) makeHandles() const {
344 return value().makeHandles();
345 }
346 template <class ARG, class T = ValueType>
347 decltype( auto ) makeHandles( const ARG& arg ) const {
348 return value().makeHandles( arg );
349 }
350
351
352 // Delegate operator() to the value
353 template <class... Args>
354 decltype( std::declval<ValueType>()( std::declval<Args&&>()... ) ) operator()( Args&&... args ) const
355 noexcept( noexcept( std::declval<ValueType>()( std::declval<Args&&>()... ) ) ) {
356 return value()( std::forward<Args>( args )... );
357 }
358
359 public:
361 bool assign( const Details::PropertyBase& source ) override {
362 // Check if the property is of "the same" type, except for strings
363 const Property* p =
364 ( std::is_same_v<ValueType, std::string> ) ? nullptr : dynamic_cast<const Property*>( &source );
365 if ( p ) {
366 *this = p->value();
367 } else {
368 return this->fromString( source.toString() ).isSuccess();
369 }
370 return true;
371 }
372
373 bool load( Details::PropertyBase& dest ) const override {
374 // delegate to the 'opposite' method
375 return dest.assign( *this );
376 }
377
378 StatusCode fromString( const std::string& source ) override {
379 try {
381 *this = Converter().fromString( m_value, source );
382 return StatusCode::SUCCESS;
383 } catch ( const std::exception& err ) {
386 const std::string errMsg =
387 "Cannot convert '" + source + "' for property '" + name() + "' in class '" + ownerTypeName() + "'";
388 switch ( parsingErrorPolicy() ) {
389 case ParsingErrorPolicy::Ignore:
390 break;
391 case ParsingErrorPolicy::Exception:
392 throw GaudiException( errMsg, "Property::fromString", StatusCode::FAILURE, err );
393 break;
394 case ParsingErrorPolicy::Warning:
395 std::cerr << "WARNING: " << errMsg << "': " << err.what() << '\n';
396 break;
397 case ParsingErrorPolicy::Abort:
398 std::cerr << "FATAL: " << errMsg << "': " << err.what() << '\n';
399 std::abort();
400 break;
401 }
402 return StatusCode::FAILURE;
403 }
404 }
405
406 std::string toString() const override {
408 return Converter().toString( *this );
409 }
410
411 void toStream( std::ostream& out ) const override {
412 m_handlers.useReadHandler( *this );
413 using Utils::toStream;
414 toStream( m_value, out );
415 }
416 }; // namespace Gaudi
417
419 template <class T, class TP, class V, class H>
420 bool operator==( const T& v, const Property<TP, V, H>& p ) {
421 return p.operator==( v );
422 }
423
425 template <class T, class TP, class V, class H>
426 bool operator!=( const T& v, const Property<TP, V, H>& p ) {
427 return p.operator!=( v );
428 }
429
431 template <class T, class TP, class V, class H>
432 decltype( auto ) operator+( const T& v, const Property<TP, V, H>& p ) {
433 return v + p.value();
434 }
435
436 template <class TYPE, class HANDLERS = Details::Property::UpdateHandler>
437 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
438
439 template <class TYPE>
441 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
442
443} // namespace Gaudi
444
445template <class TYPE>
447
448template <class TYPE>
450
451// Typedef Properties for built-in types
467
469
470// Typedef PropertyRefs for built-in types
486
488
489// Typedef "Arrays" of Properties for built-in types
505
507
508// Typedef "Arrays" of PropertyRefs for built-in types
524
526
529template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
531 Handler m_handlers;
532
533public:
535
537 PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override {
538 m_handlers.setReadHandler( std::move( fun ) );
539 return *this;
540 }
541
542 PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override {
543 m_handlers.setUpdateHandler( std::move( fun ) );
544 return *this;
545 }
546
548 const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
550 const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
551
553 void useReadHandler() const { m_handlers.useReadHandler( *this ); }
554
556 bool useUpdateHandler() override {
557 m_handlers.useUpdateHandler( *this );
558 return true;
559 }
560};
561
562// forward-declaration is sufficient here
563class GaudiHandleBase;
564
565// implementation in header file only where the GaudiHandleBase class
566// definition is not needed. The rest goes into the .cpp file.
567// The goal is to decouple the header files, to avoid that the whole
568// world depends on GaudiHandle.h
570public:
571 GaudiHandleProperty( std::string name, GaudiHandleBase& ref );
572
574 setValue( value );
575 return *this;
576 }
577
578 GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
579
580 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
581
582 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
583
584 std::string toString() const override;
585
586 void toStream( std::ostream& out ) const override;
587
588 StatusCode fromString( const std::string& s ) override;
589
590 const GaudiHandleBase& value() const {
592 return *m_pValue;
593 }
594
595 bool setValue( const GaudiHandleBase& value );
596
597private:
601};
602
603// forward-declaration is sufficient here
605
607public:
609
611 setValue( value );
612 return *this;
613 }
614
615 GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
616
617 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
618
619 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
620
621 std::string toString() const override;
622
623 void toStream( std::ostream& out ) const override;
624
625 StatusCode fromString( const std::string& s ) override;
626
629 return *m_pValue;
630 }
631
632 bool setValue( const GaudiHandleArrayBase& value );
633
634private:
638};
639
640namespace Gaudi {
641 namespace Utils {
659 GAUDI_API bool hasProperty( const IProperty* p, std::string_view name );
677 GAUDI_API bool hasProperty( const IInterface* p, std::string_view name );
695 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IProperty* p, std::string_view name );
713 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IInterface* p, std::string_view name );
736 GAUDI_API bool hasProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
760 getProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
784 template <class TYPE>
785 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
808 template <class TYPE>
809 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value ) {
810 return setProperty( component, name, value, std::string() );
811 }
812
825 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
826 const std::string& doc = "" );
840 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
841 const std::string& doc = "" );
855 template <unsigned N>
856 StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
857 const std::string& doc = "" ) {
858 return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
859 }
860
890 template <class TYPE>
891 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc ) {
893 return component && hasProperty( component, name )
894 ? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
896 }
897
918 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
919 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
941 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
942 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
965 template <class TYPE>
966 StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
967 const std::string& doc = "" ) {
968 return setProperty( component, name, &value, doc );
969 }
970
990 template <class TYPE>
991 StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
992 const std::string& doc = "" ) {
993 if ( !component ) { return StatusCode::FAILURE; }
994 auto property = SmartIF<IProperty>{ component };
995 return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
996 }
997
1009 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1010 const std::string& doc = "" );
1023 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1024 const std::string& doc = "" );
1038 template <unsigned N>
1039 StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1040 const std::string& doc = "" ) {
1041 if ( !component ) { return StatusCode::FAILURE; }
1042 return setProperty( component, name, std::string{ value, value + N }, doc );
1043 }
1044
1065 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1066 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1088 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1089 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1112 template <class TYPE>
1113 StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1114 const std::string& doc = "" ) {
1115 return setProperty( component, name, &value, doc );
1116 }
1117 } // namespace Utils
1118} // namespace Gaudi
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Definition Property.h:518
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Definition Property.h:515
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition Property.h:490
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition Property.h:482
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition Property.h:478
Gaudi::Property< float & > FloatPropertyRef
Definition Property.h:483
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition Property.h:496
Gaudi::Property< TYPE > SimpleProperty
Definition Property.h:446
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition Property.h:525
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition Property.h:513
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition Property.h:459
Gaudi::Property< int & > IntegerPropertyRef
Definition Property.h:477
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition Property.h:498
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition Property.h:517
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition Property.h:476
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition Property.h:511
Gaudi::Property< std::vector< short > > ShortArrayProperty
Definition Property.h:494
Gaudi::Property< bool & > BooleanPropertyRef
Definition Property.h:471
Gaudi::Property< int > IntegerProperty
Definition Property.h:458
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition Property.h:461
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition Property.h:514
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition Property.h:523
Gaudi::Property< double & > DoublePropertyRef
Definition Property.h:484
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Definition Property.h:522
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition Property.h:512
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition Property.h:501
Gaudi::Property< long double & > LongDoublePropertyRef
Definition Property.h:485
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition Property.h:500
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition Property.h:503
Gaudi::Property< long long > LongLongProperty
Definition Property.h:462
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Definition Property.h:493
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition Property.h:502
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition Property.h:455
Gaudi::Property< char & > CharPropertyRef
Definition Property.h:472
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition Property.h:457
Gaudi::Property< float > FloatProperty
Definition Property.h:464
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition Property.h:520
Gaudi::Property< long double > LongDoubleProperty
Definition Property.h:466
Gaudi::Property< bool > BooleanProperty
Definition Property.h:452
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition Property.h:492
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition Property.h:495
Gaudi::Property< long > LongProperty
Definition Property.h:460
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition Property.h:510
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition Property.h:473
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition Property.h:504
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition Property.h:521
Gaudi::Property< signed char > SignedCharProperty
Definition Property.h:454
Gaudi::Property< TYPE & > SimplePropertyRef
Definition Property.h:449
Gaudi::Property< long long & > LongLongPropertyRef
Definition Property.h:481
Gaudi::Property< char > CharProperty
Definition Property.h:453
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition Property.h:506
Gaudi::Property< long & > LongPropertyRef
Definition Property.h:479
Gaudi::Property< short & > ShortPropertyRef
Definition Property.h:475
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition Property.h:497
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition Property.h:480
Gaudi::Property< short > ShortProperty
Definition Property.h:456
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition Property.h:519
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition Property.h:463
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition Property.h:491
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition Property.h:509
Gaudi::Property< std::string & > StringPropertyRef
Definition Property.h:487
Gaudi::Property< std::string > StringProperty
Definition Property.h:468
Gaudi::Property< double > DoubleProperty
Definition Property.h:465
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Definition Property.h:499
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition Property.h:516
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition Property.h:474
#define GAUDI_API
Definition Kernel.h:49
implementation of various functions for streaming.
Converter base class.
Definition Converter.h:33
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
PropertyBase(const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
constructor from the property name and the type
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
void setOwnerType()
set the type of the owner class (used for documentation)
virtual std::string toString() const =0
value -> string
virtual void toStream(std::ostream &out) const =0
value -> stream
virtual StatusCode fromString(const std::string &value)=0
string -> value
std::string semantics() const
property semantics
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
const std::string name() const
property name
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
bool operator<(const T &other) const
"less" comparison
Definition Property.h:204
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
Definition Property.h:51
decltype(auto) objKey() const
Definition Property.h:331
Property & operator++()
Definition Property.h:298
Property(T &&v)
Construct an anonymous property from a value.
Definition Property.h:117
decltype(auto) erase(ARG arg)
Definition Property.h:294
bool operator!=(const T &other) const
inequality comparison
Definition Property.h:198
void toStream(std::ostream &out) const override
value -> stream
Definition Property.h:411
decltype(std::declval< ValueType >()(std::declval< Args && >()...)) operator()(Args &&... args) const noexcept(noexcept(std::declval< ValueType >()(std::declval< Args && >()...)))
Definition Property.h:354
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(), std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
Definition Property.h:95
decltype(auto) empty() const
Definition Property.h:254
Details::PropertyBase * clone() const override
clones the current property
Definition Property.h:239
decltype(auto) makeHandles() const
Definition Property.h:343
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(PropertyBase &), std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
Definition Property.h:86
bool load(Details::PropertyBase &dest) const override
set value to another property
Definition Property.h:373
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, Details::Property::ImmediatelyInvokeHandler invoke, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
Definition Property.h:105
std::ostream & fillStream(std::ostream &stream) const override
Properly quote string properties when printing them.
Definition Property.h:174
const VerifierType & verifier() const
Accessor to verifier.
Definition Property.h:224
Property(OWNER *owner, std::string name, T &&value, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value and documentation.
Definition Property.h:68
ValueType & value()
Definition Property.h:230
decltype(auto) end() const
Definition Property.h:266
Property & operator-=(const T &other)
Definition Property.h:321
decltype(auto) size() const
Definition Property.h:246
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition Property.h:135
decltype(auto) find(const typename T::key_type &key)
Definition Property.h:290
decltype(auto) end()
Definition Property.h:274
Property & operator--()
Definition Property.h:307
ValueType operator++(int)
Definition Property.h:303
decltype(auto) makeHandles(const ARG &arg) const
Definition Property.h:347
decltype(auto) find(const typename T::key_type &key) const
Definition Property.h:286
bool operator==(const T &other) const
equality comparison
Definition Property.h:192
Property & operator+=(const T &other)
Definition Property.h:316
Property & operator=(T &&v)
Assignment from value.
Definition Property.h:216
decltype(auto) begin() const
Definition Property.h:262
decltype(auto) initialize()
Definition Property.h:339
std::string toString() const override
value -> string
Definition Property.h:406
ValueType operator--(int)
Definition Property.h:312
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition Property.h:145
bool set(const ValueType &v)
Definition Property.h:235
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition Property.h:361
decltype(auto) begin()
Definition Property.h:270
bool setValue(const ValueType &v)
Definition Property.h:231
decltype(auto) clear()
Definition Property.h:258
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
Definition Property.h:77
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
Definition Property.h:60
bool useUpdateHandler() override
manual trigger for callback for update
Definition Property.h:150
decltype(auto) fullKey() const
Definition Property.h:335
StatusCode fromString(const std::string &source) override
string -> value
Definition Property.h:378
GaudiUtils::HashMap< std::string, T > StorageType
Definition Property.h:38
decltype(auto) length() const
Definition Property.h:250
Property()
Construct an anonymous property with default constructed value.
Definition Property.h:124
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
Definition Property.h:130
typename std::remove_reference< StorageType >::type ValueType
Definition Property.h:39
VerifierType & verifier()
Accessor to verifier.
Definition Property.h:226
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition Property.h:141
Define general base for Gaudi exception.
Base class of array's of various gaudihandles.
GaudiHandleArrayProperty * clone() const override
clones the current property
Definition Property.h:615
bool load(PropertyBase &destination) const override
Definition Property.h:617
bool setValue(const GaudiHandleArrayBase &value)
Definition Property.cpp:133
GaudiHandleArrayProperty(std::string name, GaudiHandleArrayBase &ref)
Definition Property.cpp:128
bool assign(const PropertyBase &source) override
Definition Property.h:619
const GaudiHandleArrayBase & value() const
Definition Property.h:627
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition Property.h:637
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition Property.h:610
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
GaudiHandleBase * m_pValue
Pointer to the real property.
Definition Property.h:600
const GaudiHandleBase & value() const
Definition Property.h:590
GaudiHandleProperty(std::string name, GaudiHandleBase &ref)
Definition Property.cpp:94
GaudiHandleProperty * clone() const override
clones the current property
Definition Property.h:578
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition Property.h:573
bool setValue(const GaudiHandleBase &value)
Definition Property.cpp:99
bool load(PropertyBase &destination) const override
Definition Property.h:580
bool assign(const PropertyBase &source) override
Definition Property.h:582
Property< TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler > PropertyWithReadHandler
Definition Property.h:440
Property< TYPE, Details::Property::BoundedVerifier< TYPE >, HANDLERS > CheckedProperty
Definition Property.h:437
Definition of the basic interface.
Definition IInterface.h:225
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition IProperty.h:32
PropertyBase(const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
constructor from the property name and the type
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
virtual std::string toString() const =0
value -> string
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition Property.h:530
bool useUpdateHandler() override
use the call-back function at update, if available
Definition Property.h:556
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition Property.h:548
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition Property.h:542
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition Property.h:550
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition Property.h:537
void useReadHandler() const
use the call-back function at reading, if available
Definition Property.h:553
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
Gaudi::tagged_bool< class ImmediatelyInvokeHandler_tag > ImmediatelyInvokeHandler
Definition Property.h:23
ParsingErrorPolicy parsingErrorPolicy()
Definition Property.cpp:476
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition Property.h:891
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:326
GAUDI_API Gaudi::Details::PropertyBase * getProperty(const IProperty *p, std::string_view name)
simple function which gets the property with given name from the component
Definition Property.cpp:191
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition ToStream.h:304
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:87
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition Property.h:426
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition Property.h:420
STL namespace.