The Gaudi Framework  master (adcf1ca6)
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 <typename TYPE, typename VERIFIER = Details::Property::NullVerifier,
34 typename 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 <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
185 operator std::string_view() const {
186 m_handlers.useReadHandler( *this );
187 return m_value;
188 }
189
191 template <typename T>
192 bool operator==( const T& other ) const
193 requires requires {
194 { m_value == other } -> std::convertible_to<bool>;
195 }
196 {
197 return m_value == other;
198 }
199
201 template <typename T>
202 bool operator!=( const T& other ) const
203 requires requires {
204 { m_value != other } -> std::convertible_to<bool>;
205 }
206 {
207 return m_value != other;
208 }
209
211 template <typename T>
212 bool operator<( const T& other ) const
213 requires requires {
214 { m_value < other } -> std::convertible_to<bool>;
215 }
216 {
217 return m_value < other;
218 }
219
221 template <typename T>
222 auto operator+( const T& other ) const
223 requires requires { m_value + other; }
224 {
225 return m_value + other;
226 }
227
229 template <typename T>
230 requires( std::assignable_from<TYPE&, T &&> || std::constructible_from<TYPE, T &&> )
231 Property& operator=( T&& v ) {
232 m_verifier( v );
233 m_value = std::forward<T>( v );
234 m_handlers.useUpdateHandler( *this );
235 return *this;
236 }
237
238 template <typename T = TYPE>
239 requires requires { typename T::value_type; } &&
240 std::constructible_from<TYPE, std::initializer_list<typename T::value_type>>
241 Property& operator=( std::initializer_list<typename T::value_type> ilist ) {
242 return *this = TYPE{ ilist };
243 }
244
246 const VerifierType& verifier() const { return m_verifier; }
249
251 const ValueType& value() const { return *this; }
252 ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
253 bool setValue( const ValueType& v ) {
254 *this = v;
255 return true;
256 }
257 bool set( const ValueType& v ) {
258 *this = v;
259 return true;
260 }
261 Details::PropertyBase* clone() const override { return new Property( *this ); }
263
267 auto size() const
268 requires requires { value().size(); }
269 {
270 return value().size();
271 }
272 auto length() const
273 requires requires { value().length(); }
274 {
275 return value().length();
276 }
277 auto empty() const
278 requires requires { value().empty(); }
279 {
280 return value().empty();
281 }
282 void clear()
283 requires requires { value().clear(); }
284 {
285 value().clear();
286 }
287 auto begin() const
288 requires requires { value().begin(); }
289 {
290 return value().begin();
291 }
292 auto end() const
293 requires requires { value().end(); }
294 {
295 return value().end();
296 }
297 auto begin()
298 requires requires { value().begin(); }
299 {
300 return value().begin();
301 }
302 auto end()
303 requires requires { value().end(); }
304 {
305 return value().end();
306 }
307 template <typename ARG>
308 decltype( auto ) operator[]( const ARG& arg ) const
309 requires requires { value()[arg]; }
310 {
311 return value()[arg];
312 }
313 template <typename ARG>
314 decltype( auto ) operator[]( const ARG& arg )
315 requires requires { value()[arg]; }
316 {
317 return value()[arg];
318 }
319 template <typename K>
320 decltype( auto ) find( const K& key ) const
321 requires requires { value().find( key ); }
322 {
323 return value().find( key );
324 }
325 template <typename K>
326 decltype( auto ) find( const K& key )
327 requires requires { value().find( key ); }
328 {
329 return value().find( key );
330 }
331 template <typename T>
332 decltype( auto ) erase( T arg )
333 requires requires { value().erase( arg ); }
334 {
335 return value().erase( arg );
336 }
338 requires requires { ++m_value; }
339 {
340 ++value();
341 return *this;
342 }
343 auto operator++( int )
344 requires requires { m_value++; }
345 {
346 return m_value++;
347 }
349 requires requires { --value(); }
350 {
351 --value();
352 return *this;
353 }
354 auto operator--( int )
355 requires requires { m_value--; }
356 {
357 return m_value--;
358 }
359 template <typename T>
360 Property& operator+=( const T& other )
361 requires requires { m_value += other; }
362 {
363 m_value += other;
364 return *this;
365 }
366 template <typename T>
367 Property& operator-=( const T& other )
368 requires requires { m_value -= other; }
369 {
370 m_value -= other;
371 return *this;
372 }
373
374 decltype( auto ) key() const
375 requires requires { value().key(); }
376 {
377 return value().key();
378 }
379 decltype( auto ) objKey() const
380 requires requires { value().objKey(); }
381 {
382 return value().objKey();
383 }
384 decltype( auto ) fullKey() const
385 requires requires { value().fullKey(); }
386 {
387 return value().fullKey();
388 }
389 decltype( auto ) initialize()
390 requires requires { value().initialize(); }
391 {
392 return value().initialize();
393 }
394 decltype( auto ) makeHandles() const
395 requires requires { value().makeHandles(); }
396 {
397 return value().makeHandles();
398 }
399 template <typename ARG>
400 decltype( auto ) makeHandles( const ARG& arg ) const
401 requires requires { value().makeHandles( arg ); }
402 {
403 return value().makeHandles( arg );
404 }
405
406
407 // Delegate operator() to the value
408 template <typename... Args>
409 requires std::invocable<ValueType&, Args...>
410 constexpr decltype( auto ) operator()( Args&&... args ) const
411 noexcept( std::is_nothrow_invocable_v<ValueType&, Args...> ) {
412 return std::invoke( value(), std::forward<Args>( args )... );
413 }
414
415 public:
417 bool assign( const Details::PropertyBase& source ) override {
418 // Check if the property is of "the same" type, except for strings
419 const Property* p =
420 ( std::is_same_v<ValueType, std::string> ) ? nullptr : dynamic_cast<const Property*>( &source );
421 if ( p ) {
422 *this = p->value();
423 } else {
424 return this->fromString( source.toString() ).isSuccess();
425 }
426 return true;
427 }
428
429 bool load( Details::PropertyBase& dest ) const override {
430 // delegate to the 'opposite' method
431 return dest.assign( *this );
432 }
433
434 StatusCode fromString( const std::string& source ) override {
435 try {
437 *this = Converter().fromString( m_value, source );
438 return StatusCode::SUCCESS;
439 } catch ( const std::exception& err ) {
442 const std::string errMsg =
443 "Cannot convert '" + source + "' for property '" + name() + "' in class '" + ownerTypeName() + "'";
444 switch ( parsingErrorPolicy() ) {
445 case ParsingErrorPolicy::Ignore:
446 break;
447 case ParsingErrorPolicy::Exception:
448 throw GaudiException( errMsg, "Property::fromString", StatusCode::FAILURE, err );
449 break;
450 case ParsingErrorPolicy::Warning:
451 std::cerr << "WARNING: " << errMsg << "': " << err.what() << '\n';
452 break;
453 case ParsingErrorPolicy::Abort:
454 std::cerr << "FATAL: " << errMsg << "': " << err.what() << '\n';
455 std::abort();
456 break;
457 }
458 return StatusCode::FAILURE;
459 }
460 }
461
462 std::string toString() const override {
464 return Converter().toString( *this );
465 }
466
467 void toStream( std::ostream& out ) const override {
468 m_handlers.useReadHandler( *this );
469 using Utils::toStream;
470 toStream( m_value, out );
471 }
472 }; // namespace Gaudi
473
475 template <typename T, typename TP, typename V, typename H>
476 bool operator==( const T& v, const Property<TP, V, H>& p ) {
477 return p.operator==( v );
478 }
479
481 template <typename T, typename TP, typename V, typename H>
482 bool operator!=( const T& v, const Property<TP, V, H>& p ) {
483 return p.operator!=( v );
484 }
485
487 template <typename T, typename TP, typename V, typename H>
488 requires( !std::is_base_of_v<Details::PropertyBase, T> )
489 decltype( auto ) operator+( const T& v, const Property<TP, V, H>& p ) {
490 return v + p.value();
491 }
492
493 template <typename TYPE, typename HANDLERS = Details::Property::UpdateHandler>
494 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
495
496 template <typename TYPE>
498 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
499
500} // namespace Gaudi
501
502template <typename TYPE>
504
505template <typename TYPE>
507
508// Typedef Properties for built-in types
524
526
527// Typedef PropertyRefs for built-in types
543
545
546// Typedef "Arrays" of Properties for built-in types
562
564
565// Typedef "Arrays" of PropertyRefs for built-in types
581
583
586template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
588 Handler m_handlers;
589
590public:
592
594 PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override {
595 m_handlers.setReadHandler( std::move( fun ) );
596 return *this;
597 }
598
599 PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override {
600 m_handlers.setUpdateHandler( std::move( fun ) );
601 return *this;
602 }
603
605 const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
607 const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
608
610 void useReadHandler() const { m_handlers.useReadHandler( *this ); }
611
613 bool useUpdateHandler() override {
614 m_handlers.useUpdateHandler( *this );
615 return true;
616 }
617};
618
619// forward-declaration is sufficient here
620class GaudiHandleBase;
621
622// implementation in header file only where the GaudiHandleBase class
623// definition is not needed. The rest goes into the .cpp file.
624// The goal is to decouple the header files, to avoid that the whole
625// world depends on GaudiHandle.h
627public:
628 GaudiHandleProperty( std::string name, GaudiHandleBase& ref );
629
631 setValue( value );
632 return *this;
633 }
634
635 GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
636
637 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
638
639 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
640
641 std::string toString() const override;
642
643 void toStream( std::ostream& out ) const override;
644
645 StatusCode fromString( const std::string& s ) override;
646
647 const GaudiHandleBase& value() const {
649 return *m_pValue;
650 }
651
652 bool setValue( const GaudiHandleBase& value );
653
654private:
658};
659
660// forward-declaration is sufficient here
662
664public:
666
668 setValue( value );
669 return *this;
670 }
671
672 GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
673
674 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
675
676 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
677
678 std::string toString() const override;
679
680 void toStream( std::ostream& out ) const override;
681
682 StatusCode fromString( const std::string& s ) override;
683
686 return *m_pValue;
687 }
688
689 bool setValue( const GaudiHandleArrayBase& value );
690
691private:
695};
696
697namespace Gaudi {
698 namespace Utils {
716 GAUDI_API bool hasProperty( const IProperty* p, std::string_view name );
734 GAUDI_API bool hasProperty( const IInterface* p, std::string_view name );
752 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IProperty* p, std::string_view name );
770 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IInterface* p, std::string_view name );
793 GAUDI_API bool hasProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
817 getProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
841 template <typename TYPE>
842 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
865 template <typename TYPE>
866 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value ) {
867 return setProperty( component, name, value, std::string() );
868 }
869
882 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
883 const std::string& doc = "" );
897 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
898 const std::string& doc = "" );
912 template <unsigned N>
913 StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
914 const std::string& doc = "" ) {
915 return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
916 }
917
947 template <typename TYPE>
948 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc ) {
950 return component && hasProperty( component, name )
951 ? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
953 }
954
975 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
976 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
998 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
999 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1022 template <typename TYPE>
1023 StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1024 const std::string& doc = "" ) {
1025 return setProperty( component, name, &value, doc );
1026 }
1027
1047 template <typename TYPE>
1048 StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1049 const std::string& doc = "" ) {
1050 if ( !component ) { return StatusCode::FAILURE; }
1051 auto property = SmartIF<IProperty>{ component };
1052 return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
1053 }
1054
1066 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1067 const std::string& doc = "" );
1080 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1081 const std::string& doc = "" );
1095 template <unsigned N>
1096 StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1097 const std::string& doc = "" ) {
1098 if ( !component ) { return StatusCode::FAILURE; }
1099 return setProperty( component, name, std::string{ value, value + N }, doc );
1100 }
1101
1122 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1123 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1145 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1146 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1169 template <typename TYPE>
1170 StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1171 const std::string& doc = "" ) {
1172 return setProperty( component, name, &value, doc );
1173 }
1174 } // namespace Utils
1175} // namespace Gaudi
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Definition Property.h:575
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Definition Property.h:572
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition Property.h:547
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition Property.h:539
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition Property.h:535
Gaudi::Property< float & > FloatPropertyRef
Definition Property.h:540
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition Property.h:553
Gaudi::Property< TYPE > SimpleProperty
Definition Property.h:503
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition Property.h:582
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition Property.h:570
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition Property.h:516
Gaudi::Property< int & > IntegerPropertyRef
Definition Property.h:534
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition Property.h:555
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition Property.h:574
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition Property.h:533
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition Property.h:568
Gaudi::Property< std::vector< short > > ShortArrayProperty
Definition Property.h:551
Gaudi::Property< bool & > BooleanPropertyRef
Definition Property.h:528
Gaudi::Property< int > IntegerProperty
Definition Property.h:515
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition Property.h:518
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition Property.h:571
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition Property.h:580
Gaudi::Property< double & > DoublePropertyRef
Definition Property.h:541
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Definition Property.h:579
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition Property.h:569
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition Property.h:558
Gaudi::Property< long double & > LongDoublePropertyRef
Definition Property.h:542
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition Property.h:557
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition Property.h:560
Gaudi::Property< long long > LongLongProperty
Definition Property.h:519
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Definition Property.h:550
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition Property.h:559
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition Property.h:512
Gaudi::Property< char & > CharPropertyRef
Definition Property.h:529
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition Property.h:514
Gaudi::Property< float > FloatProperty
Definition Property.h:521
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition Property.h:577
Gaudi::Property< long double > LongDoubleProperty
Definition Property.h:523
Gaudi::Property< bool > BooleanProperty
Definition Property.h:509
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition Property.h:549
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition Property.h:552
Gaudi::Property< long > LongProperty
Definition Property.h:517
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition Property.h:567
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition Property.h:530
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition Property.h:561
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition Property.h:578
Gaudi::Property< signed char > SignedCharProperty
Definition Property.h:511
Gaudi::Property< TYPE & > SimplePropertyRef
Definition Property.h:506
Gaudi::Property< long long & > LongLongPropertyRef
Definition Property.h:538
Gaudi::Property< char > CharProperty
Definition Property.h:510
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition Property.h:563
Gaudi::Property< long & > LongPropertyRef
Definition Property.h:536
Gaudi::Property< short & > ShortPropertyRef
Definition Property.h:532
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition Property.h:554
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition Property.h:537
Gaudi::Property< short > ShortProperty
Definition Property.h:513
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition Property.h:576
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition Property.h:520
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition Property.h:548
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition Property.h:566
Gaudi::Property< std::string & > StringPropertyRef
Definition Property.h:544
Gaudi::Property< std::string > StringProperty
Definition Property.h:525
Gaudi::Property< double > DoubleProperty
Definition Property.h:522
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Definition Property.h:556
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition Property.h:573
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition Property.h:531
#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
Property & operator=(std::initializer_list< typename T::value_type > ilist)
Definition Property.h:241
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:343
Property(T &&v)
Construct an anonymous property from a value.
Definition Property.h:117
void toStream(std::ostream &out) const override
value -> stream
Definition Property.h:467
bool operator!=(const T &other) const
inequality comparison
Definition Property.h:202
auto operator--(int)
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
Property & operator+=(const T &other)
Definition Property.h:360
Details::PropertyBase * clone() const override
clones the current property
Definition Property.h:261
decltype(auto) erase(T arg)
Definition Property.h:332
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:429
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:246
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:252
bool operator==(const T &other) const
equality comparison
Definition Property.h:192
Property & operator++()
Definition Property.h:337
auto length() const
Definition Property.h:272
decltype(auto) initialize()
Definition Property.h:389
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition Property.h:135
Property & operator--()
Definition Property.h:348
auto size() const
Definition Property.h:267
auto operator+(const T &other) const
allow addition if possible between the property and the other types
Definition Property.h:222
auto empty() const
Definition Property.h:277
std::string toString() const override
value -> string
Definition Property.h:462
decltype(auto) find(const K &key)
Definition Property.h:326
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:257
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition Property.h:417
auto begin() const
Definition Property.h:287
decltype(auto) makeHandles() const
Definition Property.h:394
bool setValue(const ValueType &v)
Definition Property.h:253
decltype(auto) makeHandles(const ARG &arg) const
Definition Property.h:400
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:384
decltype(auto) find(const K &key) const
Definition Property.h:320
Property & operator-=(const T &other)
Definition Property.h:367
auto end() const
Definition Property.h:292
bool operator<(const T &other) const
"less" comparison
Definition Property.h:212
StatusCode fromString(const std::string &source) override
string -> value
Definition Property.h:434
GaudiUtils::HashMap< std::string, T > StorageType
Definition Property.h:38
Property()
Construct an anonymous property with default constructed value.
Definition Property.h:124
decltype(auto) objKey() const
Definition Property.h:379
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:248
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:672
bool load(PropertyBase &destination) const override
Definition Property.h:674
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:676
const GaudiHandleArrayBase & value() const
Definition Property.h:684
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition Property.h:694
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition Property.h:667
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:657
const GaudiHandleBase & value() const
Definition Property.h:647
GaudiHandleProperty(std::string name, GaudiHandleBase &ref)
Definition Property.cpp:94
GaudiHandleProperty * clone() const override
clones the current property
Definition Property.h:635
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition Property.h:630
bool setValue(const GaudiHandleBase &value)
Definition Property.cpp:99
bool load(PropertyBase &destination) const override
Definition Property.h:637
bool assign(const PropertyBase &source) override
Definition Property.h:639
Property< TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler > PropertyWithReadHandler
Definition Property.h:497
Property< TYPE, Details::Property::BoundedVerifier< TYPE >, HANDLERS > CheckedProperty
Definition Property.h:494
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:587
bool useUpdateHandler() override
use the call-back function at update, if available
Definition Property.h:613
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition Property.h:605
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition Property.h:599
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition Property.h:607
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition Property.h:594
void useReadHandler() const
use the call-back function at reading, if available
Definition Property.h:610
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:948
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:482
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition Property.h:476
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition Property.h:489
STL namespace.