The Gaudi Framework  master (bb95dfce)
Loading...
Searching...
No Matches
Property.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 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 <typename TYPE, typename VERIFIER = Details::Property::NullVerifier,
34 typename HANDLERS = Details::Property::UpdateHandler>
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 <typename 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, typename 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, typename 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, typename 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, typename 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, typename 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 operator std::string_view() const
167 requires std::constructible_from<std::string_view, TYPE>
168 {
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
186 template <typename T>
187 bool operator==( const T& other ) const
188 requires requires {
189 { m_value == other } -> std::convertible_to<bool>;
190 }
191 {
192 return m_value == other;
193 }
194
196 template <typename T>
197 bool operator!=( const T& other ) const
198 requires requires {
199 { m_value != other } -> std::convertible_to<bool>;
200 }
201 {
202 return m_value != other;
203 }
204
206 template <typename T>
207 bool operator<( const T& other ) const
208 requires requires {
209 { m_value < other } -> std::convertible_to<bool>;
210 }
211 {
212 return m_value < other;
213 }
214
216 template <typename T>
217 auto operator+( const T& other ) const
218 requires requires { m_value + other; }
219 {
220 return m_value + other;
221 }
222
224 template <typename T>
225 requires( std::assignable_from<TYPE&, T &&> || std::constructible_from<TYPE, T &&> )
226 Property& operator=( T&& v ) {
227 m_verifier( v );
228 m_value = std::forward<T>( v );
229 m_handlers.useUpdateHandler( *this );
230 return *this;
231 }
232
233 template <typename T = TYPE>
234 requires requires { typename T::value_type; } &&
235 std::constructible_from<TYPE, std::initializer_list<typename T::value_type>>
236 Property& operator=( std::initializer_list<typename T::value_type> ilist ) {
237 return *this = TYPE{ ilist };
238 }
239
241 const VerifierType& verifier() const { return m_verifier; }
244
246 const ValueType& value() const { return *this; }
247 ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
248 bool setValue( const ValueType& v ) {
249 *this = v;
250 return true;
251 }
252 bool set( const ValueType& v ) {
253 *this = v;
254 return true;
255 }
256 Details::PropertyBase* clone() const override { return new Property( *this ); }
258
262 auto size() const
263 requires requires { value().size(); }
264 {
265 return value().size();
266 }
267 auto length() const
268 requires requires { value().length(); }
269 {
270 return value().length();
271 }
272 auto empty() const
273 requires requires { value().empty(); }
274 {
275 return value().empty();
276 }
277 void clear()
278 requires requires { value().clear(); }
279 {
280 value().clear();
281 }
282 auto begin() const
283 requires requires { value().begin(); }
284 {
285 return value().begin();
286 }
287 auto end() const
288 requires requires { value().end(); }
289 {
290 return value().end();
291 }
292 auto begin()
293 requires requires { value().begin(); }
294 {
295 return value().begin();
296 }
297 auto end()
298 requires requires { value().end(); }
299 {
300 return value().end();
301 }
302 template <typename ARG>
303 decltype( auto ) operator[]( const ARG& arg ) const
304 requires requires { value()[arg]; }
305 {
306 return value()[arg];
307 }
308 template <typename ARG>
309 decltype( auto ) operator[]( const ARG& arg )
310 requires requires { value()[arg]; }
311 {
312 return value()[arg];
313 }
314 template <typename K>
315 decltype( auto ) find( const K& key ) const
316 requires requires { value().find( key ); }
317 {
318 return value().find( key );
319 }
320 template <typename K>
321 decltype( auto ) find( const K& key )
322 requires requires { value().find( key ); }
323 {
324 return value().find( key );
325 }
326 template <typename T>
327 decltype( auto ) erase( T arg )
328 requires requires { value().erase( arg ); }
329 {
330 return value().erase( arg );
331 }
333 requires requires { ++m_value; }
334 {
335 ++value();
336 return *this;
337 }
338 auto operator++( int )
339 requires requires { m_value++; }
340 {
341 return m_value++;
342 }
344 requires requires { --value(); }
345 {
346 --value();
347 return *this;
348 }
349 auto operator--( int )
350 requires requires { m_value--; }
351 {
352 return m_value--;
353 }
354 template <typename T>
355 Property& operator+=( const T& other )
356 requires requires { m_value += other; }
357 {
358 m_value += other;
359 return *this;
360 }
361 template <typename T>
362 Property& operator-=( const T& other )
363 requires requires { m_value -= other; }
364 {
365 m_value -= other;
366 return *this;
367 }
368
369 decltype( auto ) key() const
370 requires requires { value().key(); }
371 {
372 return value().key();
373 }
374 decltype( auto ) objKey() const
375 requires requires { value().objKey(); }
376 {
377 return value().objKey();
378 }
379 decltype( auto ) fullKey() const
380 requires requires { value().fullKey(); }
381 {
382 return value().fullKey();
383 }
384 decltype( auto ) initialize()
385 requires requires { value().initialize(); }
386 {
387 return value().initialize();
388 }
389 decltype( auto ) makeHandles() const
390 requires requires { value().makeHandles(); }
391 {
392 return value().makeHandles();
393 }
394 template <typename ARG>
395 decltype( auto ) makeHandles( const ARG& arg ) const
396 requires requires { value().makeHandles( arg ); }
397 {
398 return value().makeHandles( arg );
399 }
400
401
402 // Delegate operator() to the value
403 template <typename... Args>
404 requires std::invocable<ValueType&, Args...>
405 constexpr decltype( auto ) operator()( Args&&... args ) const
406 noexcept( std::is_nothrow_invocable_v<ValueType&, Args...> ) {
407 return std::invoke( value(), std::forward<Args>( args )... );
408 }
409
410 public:
412 bool assign( const Details::PropertyBase& source ) override {
413 // Check if the property is of "the same" type, except for strings
414 const Property* p =
415 ( std::is_same_v<ValueType, std::string> ) ? nullptr : dynamic_cast<const Property*>( &source );
416 if ( p ) {
417 *this = p->value();
418 } else {
419 return this->fromString( source.toString() ).isSuccess();
420 }
421 return true;
422 }
423
424 bool load( Details::PropertyBase& dest ) const override {
425 // delegate to the 'opposite' method
426 return dest.assign( *this );
427 }
428
429 StatusCode fromString( const std::string& source ) override {
430 try {
432 *this = Converter().fromString( m_value, source );
433 return StatusCode::SUCCESS;
434 } catch ( const std::exception& err ) {
437 const std::string errMsg =
438 "Cannot convert '" + source + "' for property '" + name() + "' in class '" + ownerTypeName() + "'";
439 switch ( parsingErrorPolicy() ) {
440 case ParsingErrorPolicy::Ignore:
441 break;
442 case ParsingErrorPolicy::Exception:
443 throw GaudiException( errMsg, "Property::fromString", StatusCode::FAILURE, err );
444 break;
445 case ParsingErrorPolicy::Warning:
446 std::cerr << "WARNING: " << errMsg << "': " << err.what() << '\n';
447 break;
448 case ParsingErrorPolicy::Abort:
449 std::cerr << "FATAL: " << errMsg << "': " << err.what() << '\n';
450 std::abort();
451 break;
452 }
453 return StatusCode::FAILURE;
454 }
455 }
456
457 std::string toString() const override {
459 return Converter().toString( *this );
460 }
461
462 void toStream( std::ostream& out ) const override {
463 m_handlers.useReadHandler( *this );
464 using Utils::toStream;
465 toStream( m_value, out );
466 }
467 }; // namespace Gaudi
468
470 template <typename T, typename TP, typename V, typename H>
471 bool operator==( const T& v, const Property<TP, V, H>& p ) {
472 return p.operator==( v );
473 }
474
476 template <typename T, typename TP, typename V, typename H>
477 bool operator!=( const T& v, const Property<TP, V, H>& p ) {
478 return p.operator!=( v );
479 }
480
482 template <typename T, typename TP, typename V, typename H>
483 requires( !std::is_base_of_v<Details::PropertyBase, T> )
484 decltype( auto ) operator+( const T& v, const Property<TP, V, H>& p ) {
485 return v + p.value();
486 }
487
488 template <typename TYPE, typename HANDLERS = Details::Property::UpdateHandler>
489 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
490
491 template <typename TYPE>
493 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
494
495} // namespace Gaudi
496
497template <typename TYPE>
499
500template <typename TYPE>
502
503// Typedef Properties for built-in types
519
521
522// Typedef PropertyRefs for built-in types
538
540
541// Typedef "Arrays" of Properties for built-in types
557
559
560// Typedef "Arrays" of PropertyRefs for built-in types
576
578
581template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
583 Handler m_handlers;
584
585public:
587
589 PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override {
590 m_handlers.setReadHandler( std::move( fun ) );
591 return *this;
592 }
593
594 PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override {
595 m_handlers.setUpdateHandler( std::move( fun ) );
596 return *this;
597 }
598
600 const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
602 const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
603
605 void useReadHandler() const { m_handlers.useReadHandler( *this ); }
606
608 bool useUpdateHandler() override {
609 m_handlers.useUpdateHandler( *this );
610 return true;
611 }
612};
613
614// forward-declaration is sufficient here
615class GaudiHandleBase;
616
617// implementation in header file only where the GaudiHandleBase class
618// definition is not needed. The rest goes into the .cpp file.
619// The goal is to decouple the header files, to avoid that the whole
620// world depends on GaudiHandle.h
622public:
623 GaudiHandleProperty( std::string name, GaudiHandleBase& ref );
624
626 setValue( value );
627 return *this;
628 }
629
630 GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
631
632 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
633
634 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
635
636 std::string toString() const override;
637
638 void toStream( std::ostream& out ) const override;
639
640 StatusCode fromString( const std::string& s ) override;
641
642 const GaudiHandleBase& value() const {
644 return *m_pValue;
645 }
646
647 bool setValue( const GaudiHandleBase& value );
648
649private:
653};
654
655// forward-declaration is sufficient here
657
659public:
661
663 setValue( value );
664 return *this;
665 }
666
667 GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
668
669 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
670
671 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
672
673 std::string toString() const override;
674
675 void toStream( std::ostream& out ) const override;
676
677 StatusCode fromString( const std::string& s ) override;
678
681 return *m_pValue;
682 }
683
684 bool setValue( const GaudiHandleArrayBase& value );
685
686private:
690};
691
692namespace Gaudi {
693 namespace Utils {
711 GAUDI_API bool hasProperty( const IProperty* p, std::string_view name );
729 GAUDI_API bool hasProperty( const IInterface* p, std::string_view name );
747 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IProperty* p, std::string_view name );
765 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IInterface* p, std::string_view name );
788 GAUDI_API bool hasProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
812 getProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
836 template <typename TYPE>
837 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
860 template <typename TYPE>
861 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value ) {
862 return setProperty( component, name, value, std::string() );
863 }
864
877 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
878 const std::string& doc = "" );
892 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
893 const std::string& doc = "" );
907 template <unsigned N>
908 StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
909 const std::string& doc = "" ) {
910 return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
911 }
912
942 template <typename TYPE>
943 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc ) {
945 return component && hasProperty( component, name )
946 ? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
948 }
949
970 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
971 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
993 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
994 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1017 template <typename TYPE>
1018 StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1019 const std::string& doc = "" ) {
1020 return setProperty( component, name, &value, doc );
1021 }
1022
1042 template <typename TYPE>
1043 StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1044 const std::string& doc = "" ) {
1045 if ( !component ) { return StatusCode::FAILURE; }
1046 auto property = SmartIF<IProperty>{ component };
1047 return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
1048 }
1049
1061 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1062 const std::string& doc = "" );
1075 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1076 const std::string& doc = "" );
1090 template <unsigned N>
1091 StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1092 const std::string& doc = "" ) {
1093 if ( !component ) { return StatusCode::FAILURE; }
1094 return setProperty( component, name, std::string{ value, value + N }, doc );
1095 }
1096
1117 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1118 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1140 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1141 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1164 template <typename TYPE>
1165 StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1166 const std::string& doc = "" ) {
1167 return setProperty( component, name, &value, doc );
1168 }
1169 } // namespace Utils
1170} // namespace Gaudi
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Definition Property.h:570
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Definition Property.h:567
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition Property.h:542
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition Property.h:534
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition Property.h:530
Gaudi::Property< float & > FloatPropertyRef
Definition Property.h:535
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition Property.h:548
Gaudi::Property< TYPE > SimpleProperty
Definition Property.h:498
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition Property.h:577
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition Property.h:565
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition Property.h:511
Gaudi::Property< int & > IntegerPropertyRef
Definition Property.h:529
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition Property.h:550
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition Property.h:569
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition Property.h:528
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition Property.h:563
Gaudi::Property< std::vector< short > > ShortArrayProperty
Definition Property.h:546
Gaudi::Property< bool & > BooleanPropertyRef
Definition Property.h:523
Gaudi::Property< int > IntegerProperty
Definition Property.h:510
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition Property.h:513
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition Property.h:566
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition Property.h:575
Gaudi::Property< double & > DoublePropertyRef
Definition Property.h:536
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Definition Property.h:574
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition Property.h:564
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition Property.h:553
Gaudi::Property< long double & > LongDoublePropertyRef
Definition Property.h:537
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition Property.h:552
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition Property.h:555
Gaudi::Property< long long > LongLongProperty
Definition Property.h:514
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Definition Property.h:545
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition Property.h:554
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition Property.h:507
Gaudi::Property< char & > CharPropertyRef
Definition Property.h:524
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition Property.h:509
Gaudi::Property< float > FloatProperty
Definition Property.h:516
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition Property.h:572
Gaudi::Property< long double > LongDoubleProperty
Definition Property.h:518
Gaudi::Property< bool > BooleanProperty
Definition Property.h:504
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition Property.h:544
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition Property.h:547
Gaudi::Property< long > LongProperty
Definition Property.h:512
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition Property.h:562
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition Property.h:525
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition Property.h:556
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition Property.h:573
Gaudi::Property< signed char > SignedCharProperty
Definition Property.h:506
Gaudi::Property< TYPE & > SimplePropertyRef
Definition Property.h:501
Gaudi::Property< long long & > LongLongPropertyRef
Definition Property.h:533
Gaudi::Property< char > CharProperty
Definition Property.h:505
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition Property.h:558
Gaudi::Property< long & > LongPropertyRef
Definition Property.h:531
Gaudi::Property< short & > ShortPropertyRef
Definition Property.h:527
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition Property.h:549
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition Property.h:532
Gaudi::Property< short > ShortProperty
Definition Property.h:508
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition Property.h:571
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition Property.h:515
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition Property.h:543
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition Property.h:561
Gaudi::Property< std::string & > StringPropertyRef
Definition Property.h:539
Gaudi::Property< std::string > StringProperty
Definition Property.h:520
Gaudi::Property< double > DoubleProperty
Definition Property.h:517
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Definition Property.h:551
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition Property.h:568
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition Property.h:526
#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 Property.h:35
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
Definition Property.h:51
auto operator++(int)
Definition Property.h:338
void toStream(std::ostream &out) const override
value -> stream
Definition Property.h:462
bool operator!=(const T &other) const
inequality comparison
Definition Property.h:197
auto operator--(int)
Definition Property.h:349
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
Property & operator+=(const T &other)
Definition Property.h:355
Details::PropertyBase * clone() const override
clones the current property
Definition Property.h:256
decltype(auto) erase(T arg)
Definition Property.h:327
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:424
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:241
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:247
bool operator==(const T &other) const
equality comparison
Definition Property.h:187
Property & operator++()
Definition Property.h:332
auto length() const
Definition Property.h:267
decltype(auto) initialize()
Definition Property.h:384
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition Property.h:135
Property & operator--()
Definition Property.h:343
auto size() const
Definition Property.h:262
Property()
Construct an anonymous property with default constructed value.
Definition Property.h:124
auto operator+(const T &other) const
allow addition if possible between the property and the other types
Definition Property.h:217
auto empty() const
Definition Property.h:272
std::string toString() const override
value -> string
Definition Property.h:457
decltype(auto) find(const K &key)
Definition Property.h:321
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:252
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition Property.h:412
auto begin() const
Definition Property.h:282
decltype(auto) makeHandles() const
Definition Property.h:389
bool setValue(const ValueType &v)
Definition Property.h:248
decltype(auto) makeHandles(const ARG &arg) const
Definition Property.h:395
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
bool useUpdateHandler() override
manual trigger for callback for update
Definition Property.h:150
decltype(auto) fullKey() const
Definition Property.h:379
decltype(auto) find(const K &key) const
Definition Property.h:315
Property & operator-=(const T &other)
Definition Property.h:362
auto end() const
Definition Property.h:287
bool operator<(const T &other) const
"less" comparison
Definition Property.h:207
Property(T &&v)
Construct an anonymous property from a value.
Definition Property.h:117
StatusCode fromString(const std::string &source) override
string -> value
Definition Property.h:429
GaudiUtils::HashMap< std::string, T > StorageType
Definition Property.h:38
Property & operator=(std::initializer_list< typename T::value_type > ilist)
Definition Property.h:236
Details::Property::UpdateHandler HandlersType
Definition Property.h:41
decltype(auto) objKey() const
Definition Property.h:374
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
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
Definition Property.h:60
VerifierType & verifier()
Accessor to verifier.
Definition Property.h:243
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:667
bool load(PropertyBase &destination) const override
Definition Property.h:669
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:671
const GaudiHandleArrayBase & value() const
Definition Property.h:679
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition Property.h:689
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition Property.h:662
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:652
const GaudiHandleBase & value() const
Definition Property.h:642
GaudiHandleProperty(std::string name, GaudiHandleBase &ref)
Definition Property.cpp:94
GaudiHandleProperty * clone() const override
clones the current property
Definition Property.h:630
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition Property.h:625
bool setValue(const GaudiHandleBase &value)
Definition Property.cpp:99
bool load(PropertyBase &destination) const override
Definition Property.h:632
bool assign(const PropertyBase &source) override
Definition Property.h:634
Property< TYPE, Details::Property::BoundedVerifier< TYPE >, HANDLERS > CheckedProperty
Definition Property.h:489
Property< TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler > PropertyWithReadHandler
Definition Property.h:492
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:582
bool useUpdateHandler() override
use the call-back function at update, if available
Definition Property.h:608
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition Property.h:600
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition Property.h:594
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition Property.h:602
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition Property.h:589
void useReadHandler() const
use the call-back function at reading, if available
Definition Property.h:605
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:302
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:943
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:329
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:307
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
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition Property.h:484
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition Property.h:477
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition Property.h:471
STL namespace.