| The Gaudi Framework v32r1 (f65d50dc)

Property.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_PROPERTY_H
2 #define GAUDIKERNEL_PROPERTY_H
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <stdexcept>
7 #include <string>
8 #include <string_view>
9 #include <typeinfo>
10 // ============================================================================
11 // Application C++ Class Headers
12 // ============================================================================
13 #include "GaudiKernel/IProperty.h"
14 #include "GaudiKernel/Kernel.h"
15 #include "GaudiKernel/PropertyFwd.h"
16 #include "GaudiKernel/SmartIF.h"
17 #include "GaudiKernel/TaggedBool.h"
18 #include "GaudiKernel/ToStream.h"
19 #include <Gaudi/Parsers/CommonParsers.h>
20 #include <Gaudi/Parsers/InputData.h>
21
22 namespace Gaudi {
23 namespace Details {
24 // ============================================================================
32 class GAUDI_API PropertyBase {
33
34 public:
36 const std::string name() const { return std::string{m_name}; }
38 std::string documentation() const { return std::string{m_documentation}; }
40 const std::type_info* type_info() const { return m_typeinfo; }
42 std::string type() const { return m_typeinfo->name(); }
44 virtual bool load( PropertyBase& dest ) const = 0;
46 virtual bool assign( const PropertyBase& source ) = 0;
47
48 public:
50 virtual std::string toString() const = 0;
52 virtual void toStream( std::ostream& out ) const = 0;
54 virtual StatusCode fromString( const std::string& value ) = 0;
55
56 public:
58 virtual PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) = 0;
60 virtual PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) = 0;
61
63 virtual const std::function<void( PropertyBase& )> readCallBack() const = 0;
65 virtual const std::function<void( PropertyBase& )> updateCallBack() const = 0;
66
68 virtual bool useUpdateHandler() = 0;
69
70 template <class HT>
71 PropertyBase& declareReadHandler( void ( HT::*MF )( PropertyBase& ), HT* instance ) {
72 return declareReadHandler( [=]( PropertyBase& p ) { ( instance->*MF )( p ); } );
73 }
74
75 template <class HT>
76 PropertyBase& declareUpdateHandler( void ( HT::*MF )( PropertyBase& ), HT* instance ) {
77 return declareUpdateHandler( [=]( PropertyBase& p ) { ( instance->*MF )( p ); } );
78 }
79
80 public:
82 virtual ~PropertyBase() = default;
84 void setName( std::string value ) { m_name = to_view( std::move( value ) ); }
86 void setDocumentation( std::string value ) { m_documentation = to_view( std::move( value ) ); }
88 virtual std::ostream& fillStream( std::ostream& ) const;
90 virtual PropertyBase* clone() const = 0;
91
93 void setOwnerType( const std::type_info& ownerType ) { m_ownerType = &ownerType; }
94
96 template <class OWNER>
97 void setOwnerType() {
98 setOwnerType( typeid( OWNER ) );
99 }
100
102 const std::type_info* ownerType() const { return m_ownerType; }
103
105 std::string ownerTypeName() const {
106 return m_ownerType ? System::typeinfoName( *m_ownerType ) : std::string( "unknown owner type" );
107 }
108
109 protected:
111 PropertyBase( const std::type_info& type, std::string name = "", std::string doc = "" )
112 : m_name( to_view( std::move( name ) ) )
113 , m_documentation( to_view( std::move( doc ) ) )
114 , m_typeinfo( &type ) {}
116 PropertyBase( std::string name, const std::type_info& type )
117 : m_name( to_view( std::move( name ) ) ), m_documentation( m_name ), m_typeinfo( &type ) {}
119 PropertyBase( const PropertyBase& ) = default;
121 PropertyBase& operator=( const PropertyBase& ) = default;
122
123 private:
125 static std::string_view to_view( std::string str );
127 std::string_view m_name;
129 std::string_view m_documentation;
131 const std::type_info* m_typeinfo;
133 const std::type_info* m_ownerType = nullptr;
134 };
135
136 inline std::ostream& operator<<( std::ostream& stream, const PropertyBase& prop ) {
137 return prop.fillStream( stream );
138 }
139
140 namespace Property {
141 using ImmediatelyInvokeHandler = Gaudi::tagged_bool<class ImmediatelyInvokeHandler_tag>;
142
143 // ==========================================================================
144 // The following code is going to be a bit unpleasant, but as far as its
145 // author can tell, it is as simple as the design constraints and C++'s
146 // implementation constraints will allow. If you disagree, please submit
147 // a patch which simplifies it. Here is the underlying design rationale:
148 //
149 // - For any given type T used in a Property, we want to have an
150 // associated StringConverter<T> struct which explains how to convert a
151 // value of that type into a string (toString) and parse that string
152 // back (fromString).
153 // - There is a default implementation, called DefaultStringConverter<T>,
154 // which is based on the overloadable parse() and toStream() global
155 // methods of Gaudi. Its exact behaviour varies depending on whether T
156 // is default-constructible or only copy-constructible, which requires a
157 // layer of SFINAE indirection.
158 // - Some people want to be able to specialize StringConverter as an
159 // alternative to defining parse/toStream overloads. This interferes
160 // with the SFINAE tricks used by DefaultStringConverter, so we cannot
161 // just call a DefaultStringConverter a StringConverter and must add one
162 // more layer to the StringConverter type hierarchy.
163
164 // This class factors out commonalities between DefaultStringConverters
165 template <class TYPE>
166 struct DefaultStringConverterImpl {
167 public:
168 virtual ~DefaultStringConverterImpl() = default;
169 std::string toString( const TYPE& v ) {
170 using Gaudi::Utils::toString;
171 return toString( v );
172 }
173
174 // Implementation of fromString depends on whether TYPE is default-
175 // constructible (fastest, easiest) or only copy-constructible (still
176 // doable as long as the caller can provide a valid value of TYPE)
177 virtual TYPE fromString( const TYPE& ref_value, const std::string& s ) = 0;
178
179 protected:
180 void fromStringImpl( TYPE& buffer, const std::string& s ) {
181 using Gaudi::Parsers::InputData;
182 if ( !parse( buffer, InputData{s} ).isSuccess() ) {
183 throw std::invalid_argument( "cannot parse '" + s + "' to " + System::typeinfoName( typeid( TYPE ) ) );
184 }
185 }
186 };
187 // Specialization of toString for strings (identity function)
188 template <>
189 inline std::string DefaultStringConverterImpl<std::string>::toString( const std::string& v ) {
190 return v;
191 }
192
193 // This class provides a default implementation of StringConverter based
194 // on the overloadable parse() and toStream() global Gaudi methods.
195 //
196 // It leverages the fact that TYPE is default-constructible if it can, and
197 // falls back fo a requirement of copy-constructibility if it must. So
198 // here is the "default" implementation for copy-constructible types...
199 //
200 template <typename TYPE, typename Enable = void>
201 struct DefaultStringConverter : DefaultStringConverterImpl<TYPE> {
202 TYPE fromString( const TYPE& ref_value, const std::string& s ) final override {
203 TYPE buffer = ref_value;
204 this->fromStringImpl( buffer, s );
205 return buffer;
206 }
207 };
208 // ...and here is the preferred impl for default-constructible types:
209 template <class TYPE>
210 struct DefaultStringConverter<TYPE, std::enable_if_t<std::is_default_constructible_v<TYPE>>>
211 : DefaultStringConverterImpl<TYPE> {
212 TYPE fromString( const TYPE& /* ref_value */, const std::string& s ) final override {
213 TYPE buffer{};
214 this->fromStringImpl( buffer, s );
215 return buffer;
216 }
217 };
218
219 // Specializable StringConverter struct with a default implementation
220 template <typename TYPE>
221 struct StringConverter : DefaultStringConverter<TYPE> {};
222
223 struct NullVerifier {
224 template <class TYPE>
225 void operator()( const TYPE& ) const {}
226 };
227 template <class TYPE>
228 struct BoundedVerifier {
229 void operator()( const TYPE& value ) const {
230 using Gaudi::Utils::toString;
231 // throw the exception if the limit is defined and value is outside
232 if ( ( m_hasLowerBound && ( value < m_lowerBound ) ) || ( m_hasUpperBound && ( m_upperBound < value ) ) )
233 throw std::out_of_range( "value " + toString( value ) + " outside range" );
234 }
235
237 bool hasLower() const { return m_hasLowerBound; }
239 bool hasUpper() const { return m_hasUpperBound; }
241 const TYPE& lower() const { return m_lowerBound; }
243 const TYPE& upper() const { return m_upperBound; }
244
246 void setLower( const TYPE& value ) {
247 m_hasLowerBound = true;
248 m_lowerBound = value;
249 }
251 void setUpper( const TYPE& value ) {
252 m_hasUpperBound = true;
253 m_upperBound = value;
254 }
256 void clearLower() {
257 m_hasLowerBound = false;
258 m_lowerBound = TYPE();
259 }
261 void clearUpper() {
262 m_hasUpperBound = false;
263 m_upperBound = TYPE();
264 }
265
267 void setBounds( const TYPE& lower, const TYPE& upper ) {
268 setLower( lower );
269 setUpper( upper );
270 }
271
273 void clearBounds() {
274 clearLower();
275 clearUpper();
276 }
277
278 private:
280 bool m_hasLowerBound{false};
281 bool m_hasUpperBound{false};
282 TYPE m_lowerBound{};
283 TYPE m_upperBound{};
284 };
285
287 struct SwapCall {
288 using callback_t = std::function<void( PropertyBase& )>;
289 callback_t tmp, &orig;
290 SwapCall( callback_t& input ) : orig( input ) { tmp.swap( orig ); }
291 ~SwapCall() { orig.swap( tmp ); }
292 void operator()( PropertyBase& p ) const { tmp( p ); }
293 };
294
295 struct NoHandler {
296 void useReadHandler( const PropertyBase& ) const {}
297 void setReadHandler( std::function<void( PropertyBase& )> ) {
298 throw std::logic_error( "setReadHandler not implemented for this class" );
299 }
300 std::function<void( PropertyBase& )> getReadHandler() const { return nullptr; }
301 void useUpdateHandler( const PropertyBase& ) const {}
302 void setUpdateHandler( std::function<void( PropertyBase& )> ) {
303 throw std::logic_error( "setUpdateHandler not implemented for this class" );
304 }
305 std::function<void( PropertyBase& )> getUpdateHandler() const { return nullptr; }
306 };
307 struct ReadHandler : NoHandler {
308 mutable std::function<void( PropertyBase& )> m_readCallBack;
309 void useReadHandler( const PropertyBase& p ) const {
310 if ( m_readCallBack ) { SwapCall{m_readCallBack}( const_cast<PropertyBase&>( p ) ); }
311 }
312 void setReadHandler( std::function<void( PropertyBase& )> fun ) { m_readCallBack = std::move( fun ); }
313 std::function<void( PropertyBase& )> getReadHandler() const { return m_readCallBack; }
314 };
315 struct UpdateHandler : NoHandler {
316 std::function<void( PropertyBase& )> m_updateCallBack;
317 void useUpdateHandler( PropertyBase& p ) {
318 if ( m_updateCallBack ) {
319 try {
320 SwapCall{m_updateCallBack}( p );
321 } catch ( const std::exception& x ) {
322 throw std::invalid_argument( "failure in update handler of '" + p.name() + "': " + x.what() );
323 }
324 }
325 }
326 void setUpdateHandler( std::function<void( PropertyBase& )> fun ) { m_updateCallBack = std::move( fun ); }
327 std::function<void( PropertyBase& )> getUpdateHandler() const { return m_updateCallBack; }
328 };
329 struct ReadUpdateHandler : ReadHandler, UpdateHandler {
330 using ReadHandler::getReadHandler;
331 using ReadHandler::setReadHandler;
332 using ReadHandler::useReadHandler;
333 using UpdateHandler::getUpdateHandler;
334 using UpdateHandler::setUpdateHandler;
335 using UpdateHandler::useUpdateHandler;
336 };
337 } // namespace Property
338
339 } // namespace Details
340
341 // ============================================================================
349 // ============================================================================
350 template <class TYPE, class VERIFIER = Details::Property::NullVerifier,
351 class HANDLERS = Details::Property::UpdateHandler>
352 class Property : public Details::PropertyBase {
353 public:
354 // ==========================================================================
356 using StorageType = TYPE;
357 using ValueType = typename std::remove_reference<StorageType>::type;
358 using VerifierType = VERIFIER;
359 using HandlersType = HANDLERS;
360 // ==========================================================================
361
362 private:
364 StorageType m_value;
365 VerifierType m_verifier;
366 HandlersType m_handlers;
369 template <class T>
370 static inline constexpr bool is_this_type_v = std::is_same_v<Property, std::remove_reference_t<T>>;
371 template <class T>
372 using not_copying = std::enable_if_t<!is_this_type_v<T>>;
374 public:
375 // ==========================================================================
377 template <class T = StorageType>
378 Property( std::string name, T&& value, std::string doc = "" )
379 : Details::PropertyBase( typeid( ValueType ), std::move( name ), std::move( doc ) )
380 , m_value( std::forward<T>( value ) ) {
381 m_verifier( m_value );
382 }
385 template <typename OWNER, typename T = ValueType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>,
386 typename = std::enable_if_t<std::is_default_constructible_v<T>>>
387 Property( OWNER* owner, std::string name ) : Property( std::move( name ), ValueType{}, "" ) {
388 owner->declareProperty( *this );
389 setOwnerType<OWNER>();
390 }
391
394 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
395 Property( OWNER* owner, std::string name, T&& value, std::string doc = "" )
396 : Property( std::move( name ), std::forward<T>( value ), std::move( doc ) ) {
397 owner->declareProperty( *this );
398 setOwnerType<OWNER>();
399 }
400
403 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
404 Property( OWNER* owner, std::string name, T&& value, std::function<void( PropertyBase& )> handler,
405 std::string doc = "" )
406 : Property( owner, std::move( name ), std::forward<T>( value ), std::move( doc ) ) {
407 declareUpdateHandler( std::move( handler ) );
408 }
409
412 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
413 Property( OWNER* owner, std::string name, T&& value, void ( OWNER::*handler )( PropertyBase& ),
414 std::string doc = "" )
415 : Property(
416 owner, std::move( name ), std::forward<T>( value ),
417 [owner, handler]( PropertyBase& p ) { ( owner->*handler )( p ); }, std::move( doc ) ) {}
420 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
421 Property( OWNER* owner, std::string name, T&& value, void ( OWNER::*handler )(), std::string doc = "" )
422 : Property(
423 owner, std::move( name ), std::forward<T>( value ),
424 [owner, handler]( PropertyBase& ) { ( owner->*handler )(); }, std::move( doc ) ) {}
425
428 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
429 Property( OWNER* owner, std::string name, T&& value, std::function<void( PropertyBase& )> handler,
430 Details::Property::ImmediatelyInvokeHandler invoke, std::string doc = "" )
431 : Property( owner, std::move( name ), std::forward<T>( value ), std::move( handler ), std::move( doc ) ) {
432 if ( invoke ) useUpdateHandler();
433 }
434
438 template <typename T, typename = not_copying<T>>
439 Property( T&& v ) : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value( std::forward<T>( v ) ) {}
440
443 template <typename T = StorageType, typename = std::enable_if_t<!std::is_reference_v<T>>>
444 Property() : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value() {}
445
446 using Details::PropertyBase::declareReadHandler;
447 using Details::PropertyBase::declareUpdateHandler;
448
450 Details::PropertyBase& declareReadHandler( std::function<void( Details::PropertyBase& )> fun ) override {
451 m_handlers.setReadHandler( std::move( fun ) );
452 return *this;
453 }
455 Details::PropertyBase& declareUpdateHandler( std::function<void( Details::PropertyBase& )> fun ) override {
456 m_handlers.setUpdateHandler( std::move( fun ) );
457 return *this;
458 }
459
461 const std::function<void( Details::PropertyBase& )> readCallBack() const override {
462 return m_handlers.getReadHandler();
463 }
465 const std::function<void( Details::PropertyBase& )> updateCallBack() const override {
466 return m_handlers.getUpdateHandler();
467 }
468
470 bool useUpdateHandler() override {
471 m_handlers.useUpdateHandler( *this );
472 return true;
473 }
474
476 operator const ValueType&() const {
477 m_handlers.useReadHandler( *this );
478 return m_value;
479 }
480 // /// Automatic conversion to value (reference).
481 // operator ValueType& () {
482 // useReadHandler();
483 // return m_value;
484 // }
485
487 template <class T>
488 bool operator==( const T& other ) const {
489 return m_value == other;
490 }
491
493 template <class T>
494 bool operator!=( const T& other ) const {
495 return m_value != other;
496 }
497
499 template <class T>
500 bool operator<( const T& other ) const {
501 return m_value < other;
502 }
503
505 template <class T>
506 decltype( auto ) operator+( const T& other ) const {
507 return m_value + other;
508 }
509
511 template <class T = ValueType>
512 Property& operator=( T&& v ) {
513 m_verifier( v );
514 m_value = std::forward<T>( v );
515 m_handlers.useUpdateHandler( *this );
516 return *this;
517 }
518
520 const VerifierType& verifier() const { return m_verifier; }
522 VerifierType& verifier() { return m_verifier; }
523
526 const ValueType& value() const { return *this; }
527 ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
528 bool setValue( const ValueType& v ) {
529 *this = v;
530 return true;
531 }
532 bool set( const ValueType& v ) {
533 *this = v;
534 return true;
535 }
536 Details::PropertyBase* clone() const override { return new Property( *this ); }
538
542 template <class T = const ValueType>
543 decltype( auto ) size() const {
544 return value().size();
545 }
546 template <class T = const ValueType>
547 decltype( auto ) length() const {
548 return value().length();
549 }
550 template <class T = const ValueType>
551 decltype( auto ) empty() const {
552 return value().empty();
553 }
554 template <class T = ValueType>
555 decltype( auto ) clear() {
556 value().clear();
557 }
558 template <class T = const ValueType>
559 decltype( auto ) begin() const {
560 return value().begin();
561 }
562 template <class T = const ValueType>
563 decltype( auto ) end() const {
564 return value().end();
565 }
566 template <class T = ValueType>
567 decltype( auto ) begin() {
568 return value().begin();
569 }
570 template <class T = ValueType>
571 decltype( auto ) end() {
572 return value().end();
573 }
574 template <class ARG>
575 decltype( auto ) operator[]( const ARG& arg ) const {
576 return value()[arg];
577 }
578 template <class ARG>
579 decltype( auto ) operator[]( const ARG& arg ) {
580 return value()[arg];
581 }
582 template <class T = const ValueType>
583 decltype( auto ) find( const typename T::key_type& key ) const {
584 return value().find( key );
585 }
586 template <class T = ValueType>
587 decltype( auto ) find( const typename T::key_type& key ) {
588 return value().find( key );
589 }
590 template <class ARG, class T = ValueType>
591 decltype( auto ) erase( ARG arg ) {
592 return value().erase( arg );
593 }
594 template <class = ValueType>
595 Property& operator++() {
596 ++value();
597 return *this;
598 }
599 template <class = ValueType>
600 ValueType operator++( int ) {
601 return m_value++;
602 }
603 template <class = ValueType>
604 Property& operator--() {
605 --value();
606 return *this;
607 }
608 template <class = ValueType>
609 ValueType operator--( int ) {
610 return m_value--;
611 }
612 template <class T = ValueType>
613 Property& operator+=( const T& other ) {
614 m_value += other;
615 return *this;
616 }
617 template <class T = ValueType>
618 Property& operator-=( const T& other ) {
619 m_value -= other;
620 return *this;
621 }
623 template <class T = const ValueType>
624 decltype( auto ) key() const {
625 return value().key();
626 }
627 template <class T = const ValueType>
628 decltype( auto ) objKey() const {
629 return value().objKey();
630 }
631 template <class T = const ValueType>
632 decltype( auto ) fullKey() const {
633 return value().fullKey();
634 }
635 template <class T = ValueType>
636 decltype( auto ) initialize() {
637 return value().initialize();
638 }
639 template <class T = ValueType>
640 decltype( auto ) makeHandles() const {
641 return value().makeHandles();
642 }
643 template <class ARG, class T = ValueType>
644 decltype( auto ) makeHandles( const ARG& arg ) const {
645 return value().makeHandles( arg );
646 }
648 // ==========================================================================
649
650 // Delegate operator() to the value
651 template <class... Args>
652 decltype( std::declval<ValueType>()( std::declval<Args&&>()... ) ) operator()( Args&&... args ) const
653 noexcept( noexcept( std::declval<ValueType>()( std::declval<Args&&>()... ) ) ) {
654 return value()( std::forward<Args>( args )... );
655 }
656
657 public:
659 bool assign( const Details::PropertyBase& source ) override {
660 // Check if the property of is of "the same" type, except for strings
661 const Property* p =
662 ( std::is_same_v<ValueType, std::string> ) ? nullptr : dynamic_cast<const Property*>( &source );
663 if ( p ) {
664 *this = p->value();
665 } else {
666 this->fromString( source.toString() ).ignore();
667 }
668 return true;
669 }
671 bool load( Details::PropertyBase& dest ) const override {
672 // delegate to the 'opposite' method
673 return dest.assign( *this );
674 }
676 StatusCode fromString( const std::string& source ) override {
677 using Converter = Details::Property::StringConverter<ValueType>;
678 *this = Converter().fromString( m_value, source );
679 return StatusCode::SUCCESS;
680 }
682 std::string toString() const override {
683 using Converter = Details::Property::StringConverter<ValueType>;
684 return Converter().toString( *this );
685 }
687 void toStream( std::ostream& out ) const override {
688 m_handlers.useReadHandler( *this );
689 using Utils::toStream;
690 toStream( m_value, out );
691 }
692 };
693
695 template <class T, class TP, class V, class H>
696 bool operator==( const T& v, const Property<TP, V, H>& p ) {
697 return p == v;
698 }
699
701 template <class T, class TP, class V, class H>
702 bool operator!=( const T& v, const Property<TP, V, H>& p ) {
703 return p != v;
704 }
705
707 template <class T, class TP, class V, class H>
708 decltype( auto ) operator+( const T& v, const Property<TP, V, H>& p ) {
709 return v + p.value();
710 }
711
712 template <class TYPE, class HANDLERS = Details::Property::UpdateHandler>
713 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
714
715 template <class TYPE>
716 using PropertyWithReadHandler =
717 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
718
719 } // namespace Gaudi
720
721 template <class TYPE>
722 using SimpleProperty = Gaudi::Property<TYPE>;
723
724 template <class TYPE>
725 using SimplePropertyRef = Gaudi::Property<TYPE&>;
726
727 // Typedef Properties for built-in types
728 typedef Gaudi::Property<bool> BooleanProperty;
729 typedef Gaudi::Property<char> CharProperty;
730 typedef Gaudi::Property<signed char> SignedCharProperty;
731 typedef Gaudi::Property<unsigned char> UnsignedCharProperty;
732 typedef Gaudi::Property<short> ShortProperty;
733 typedef Gaudi::Property<unsigned short> UnsignedShortProperty;
734 typedef Gaudi::Property<int> IntegerProperty;
735 typedef Gaudi::Property<unsigned int> UnsignedIntegerProperty;
736 typedef Gaudi::Property<long> LongProperty;
737 typedef Gaudi::Property<unsigned long> UnsignedLongProperty;
738 typedef Gaudi::Property<long long> LongLongProperty;
739 typedef Gaudi::Property<unsigned long long> UnsignedLongLongProperty;
740 typedef Gaudi::Property<float> FloatProperty;
741 typedef Gaudi::Property<double> DoubleProperty;
742 typedef Gaudi::Property<long double> LongDoubleProperty;
743
744 typedef Gaudi::Property<std::string> StringProperty;
745
746 // Typedef PropertyRefs for built-in types
747 typedef Gaudi::Property<bool&> BooleanPropertyRef;
748 typedef Gaudi::Property<char&> CharPropertyRef;
749 typedef Gaudi::Property<signed char&> SignedCharPropertyRef;
750 typedef Gaudi::Property<unsigned char&> UnsignedCharPropertyRef;
751 typedef Gaudi::Property<short&> ShortPropertyRef;
752 typedef Gaudi::Property<unsigned short&> UnsignedShortPropertyRef;
753 typedef Gaudi::Property<int&> IntegerPropertyRef;
754 typedef Gaudi::Property<unsigned int&> UnsignedIntegerPropertyRef;
755 typedef Gaudi::Property<long&> LongPropertyRef;
756 typedef Gaudi::Property<unsigned long&> UnsignedLongPropertyRef;
757 typedef Gaudi::Property<long long&> LongLongPropertyRef;
758 typedef Gaudi::Property<unsigned long long&> UnsignedLongLongPropertyRef;
759 typedef Gaudi::Property<float&> FloatPropertyRef;
760 typedef Gaudi::Property<double&> DoublePropertyRef;
761 typedef Gaudi::Property<long double&> LongDoublePropertyRef;
762
763 typedef Gaudi::Property<std::string&> StringPropertyRef;
764
765 // Typedef "Arrays" of Properties for built-in types
766 typedef Gaudi::Property<std::vector<bool>> BooleanArrayProperty;
767 typedef Gaudi::Property<std::vector<char>> CharArrayProperty;
768 typedef Gaudi::Property<std::vector<signed char>> SignedCharArrayProperty;
769 typedef Gaudi::Property<std::vector<unsigned char>> UnsignedCharArrayProperty;
770 typedef Gaudi::Property<std::vector<short>> ShortArrayProperty;
771 typedef Gaudi::Property<std::vector<unsigned short>> UnsignedShortArrayProperty;
772 typedef Gaudi::Property<std::vector<int>> IntegerArrayProperty;
773 typedef Gaudi::Property<std::vector<unsigned int>> UnsignedIntegerArrayProperty;
774 typedef Gaudi::Property<std::vector<long>> LongArrayProperty;
775 typedef Gaudi::Property<std::vector<unsigned long>> UnsignedLongArrayProperty;
776 typedef Gaudi::Property<std::vector<long long>> LongLongArrayProperty;
777 typedef Gaudi::Property<std::vector<unsigned long long>> UnsignedLongLongArrayProperty;
778 typedef Gaudi::Property<std::vector<float>> FloatArrayProperty;
779 typedef Gaudi::Property<std::vector<double>> DoubleArrayProperty;
780 typedef Gaudi::Property<std::vector<long double>> LongDoubleArrayProperty;
781
782 typedef Gaudi::Property<std::vector<std::string>> StringArrayProperty;
783
784 // Typedef "Arrays" of PropertyRefs for built-in types
785 typedef Gaudi::Property<std::vector<bool>&> BooleanArrayPropertyRef;
786 typedef Gaudi::Property<std::vector<char>&> CharArrayPropertyRef;
787 typedef Gaudi::Property<std::vector<signed char>&> SignedCharArrayPropertyRef;
788 typedef Gaudi::Property<std::vector<unsigned char>&> UnsignedCharArrayPropertyRef;
789 typedef Gaudi::Property<std::vector<short>&> ShortArrayPropertyRef;
790 typedef Gaudi::Property<std::vector<unsigned short>&> UnsignedShortArrayPropertyRef;
791 typedef Gaudi::Property<std::vector<int>&> IntegerArrayPropertyRef;
792 typedef Gaudi::Property<std::vector<unsigned int>&> UnsignedIntegerArrayPropertyRef;
793 typedef Gaudi::Property<std::vector<long>&> LongArrayPropertyRef;
794 typedef Gaudi::Property<std::vector<unsigned long>&> UnsignedLongArrayPropertyRef;
795 typedef Gaudi::Property<std::vector<long long>&> LongLongArrayPropertyRef;
796 typedef Gaudi::Property<std::vector<unsigned long long>&> UnsignedLongLongArrayPropertyRef;
797 typedef Gaudi::Property<std::vector<float>&> FloatArrayPropertyRef;
798 typedef Gaudi::Property<std::vector<double>&> DoubleArrayPropertyRef;
799 typedef Gaudi::Property<std::vector<long double>&> LongDoubleArrayPropertyRef;
800
801 typedef Gaudi::Property<std::vector<std::string>&> StringArrayPropertyRef;
802
805 template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
806 class PropertyWithHandlers : public Gaudi::Details::PropertyBase {
807 Handler m_handlers;
808
809 public:
810 using PropertyBase::PropertyBase;
811
813 PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override {
814 m_handlers.setReadHandler( std::move( fun ) );
815 return *this;
816 }
818 PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override {
819 m_handlers.setUpdateHandler( std::move( fun ) );
820 return *this;
821 }
822
824 const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
826 const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
827
829 void useReadHandler() const { m_handlers.useReadHandler( *this ); }
830
832 bool useUpdateHandler() override {
833 m_handlers.useUpdateHandler( *this );
834 return true;
835 }
836 };
837
838 // forward-declaration is sufficient here
839 class GaudiHandleBase;
840
841 // implementation in header file only where the GaudiHandleBase class
842 // definition is not needed. The rest goes into the .cpp file.
843 // The goal is to decouple the header files, to avoid that the whole
844 // world depends on GaudiHandle.h
845 class GAUDI_API GaudiHandleProperty : public PropertyWithHandlers<> {
846 public:
847 GaudiHandleProperty( std::string name, GaudiHandleBase& ref );
848
849 GaudiHandleProperty& operator=( const GaudiHandleBase& value ) {
850 setValue( value );
851 return *this;
852 }
853
854 GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
855
856 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
857
858 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
859
860 std::string toString() const override;
861
862 void toStream( std::ostream& out ) const override;
863
864 StatusCode fromString( const std::string& s ) override;
865
866 const GaudiHandleBase& value() const {
867 useReadHandler();
868 return *m_pValue;
869 }
870
871 bool setValue( const GaudiHandleBase& value );
872
873 private:
876 GaudiHandleBase* m_pValue;
877 };
878
879 // forward-declaration is sufficient here
880 class GaudiHandleArrayBase;
881
882 class GAUDI_API GaudiHandleArrayProperty : public PropertyWithHandlers<> {
883 public:
884 GaudiHandleArrayProperty( std::string name, GaudiHandleArrayBase& ref );
885
886 GaudiHandleArrayProperty& operator=( const GaudiHandleArrayBase& value ) {
887 setValue( value );
888 return *this;
889 }
890
891 GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
892
893 bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
894
895 bool assign( const PropertyBase& source ) override { return fromString( source.toString() ).isSuccess(); }
896
897 std::string toString() const override;
898
899 void toStream( std::ostream& out ) const override;
900
901 StatusCode fromString( const std::string& s ) override;
902
903 const GaudiHandleArrayBase& value() const {
904 useReadHandler();
905 return *m_pValue;
906 }
907
908 bool setValue( const GaudiHandleArrayBase& value );
909
910 private:
913 GaudiHandleArrayBase* m_pValue;
914 };
915
916 namespace Gaudi {
917 namespace Utils {
918 // ========================================================================
936 GAUDI_API bool hasProperty( const IProperty* p, const std::string& name );
937 // ========================================================================
955 GAUDI_API bool hasProperty( const IInterface* p, const std::string& name );
956 // ========================================================================
974 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IProperty* p, const std::string& name );
975 // ========================================================================
993 GAUDI_API Gaudi::Details::PropertyBase* getProperty( const IInterface* p, const std::string& name );
994 // ========================================================================
1017 GAUDI_API bool hasProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, const std::string& name );
1018 // ========================================================================
1041 GAUDI_API const Gaudi::Details::PropertyBase*
1042 getProperty( const std::vector<const Gaudi::Details::PropertyBase*>* p, const std::string& name );
1043 // ========================================================================
1067 template <class TYPE>
1068 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
1069 // ========================================================================
1092 template <class TYPE>
1093 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value ) {
1094 return setProperty( component, name, value, std::string() );
1095 }
1096 // ========================================================================
1110 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
1111 const std::string& doc = "" );
1112 // ========================================================================
1126 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
1127 const std::string& doc = "" );
1128 // ========================================================================
1142 template <unsigned N>
1143 StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
1144 const std::string& doc = "" ) {
1145 return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
1146 }
1147 // ========================================================================
1178 template <class TYPE>
1179 StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc ) {
1180 using Gaudi::Utils::toString;
1181 return component && hasProperty( component, name )
1182 ? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
1183 : StatusCode::FAILURE;
1184 }
1185 // ========================================================================
1207 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1208 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1209 // ========================================================================
1231 GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1232 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1233 // ========================================================================
1256 template <class TYPE>
1257 StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1258 const std::string& doc = "" ) {
1259 return setProperty( component, name, &value, doc );
1260 }
1261 // ========================================================================
1282 template <class TYPE>
1283 StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1284 const std::string& doc = "" ) {
1285 if ( !component ) { return StatusCode::FAILURE; }
1286 auto property = SmartIF<IProperty>{component};
1287 return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
1288 }
1289 // ========================================================================
1302 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1303 const std::string& doc = "" );
1304 // ========================================================================
1317 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1318 const std::string& doc = "" );
1319 // ========================================================================
1333 template <unsigned N>
1334 StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1335 const std::string& doc = "" ) {
1336 if ( 0 == component ) { return StatusCode::FAILURE; }
1337 return setProperty( component, name, std::string{value, value + N}, doc );
1338 }
1339 // ========================================================================
1361 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1362 const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1363 // ========================================================================
1385 GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1386 const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1387 // ========================================================================
1410 template <class TYPE>
1411 StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1412 const std::string& doc = "" ) {
1413 return setProperty( component, name, &value, doc );
1414 }
1415 // ========================================================================
1416 } // namespace Utils
1417 } // end of namespace Gaudi
1418 // ============================================================================
1419 // The END
1420 // ============================================================================
1421 #endif // GAUDIKERNEL_PROPERTY_H
FloatArrayPropertyRef
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition: Property.h:797
Gaudi::Property::toString
std::string toString() const override
value -> string
Definition: Property.h:682
Gaudi::Utils::setProperty
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:1179
SignedCharPropertyRef
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition: Property.h:749
Gaudi::Property< vector< std::string > >::VerifierType
Details::Property::NullVerifier VerifierType
Definition: Property.h:358
SignedCharArrayPropertyRef
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition: Property.h:787
Gaudi::Details::Property::SwapCall::~SwapCall
~SwapCall()
Definition: Property.h:291
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
std::out_of_range
STL class.
Gaudi::Details::Property::BoundedVerifier::m_hasLowerBound
bool m_hasLowerBound
Data members.
Definition: Property.h:280
Gaudi::Property::Property
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:387
Gaudi::Details::Property::ReadHandler::m_readCallBack
std::function< void(PropertyBase &)> m_readCallBack
Definition: Property.h:308
Gaudi::Details::Property::UpdateHandler::getUpdateHandler
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:327
SmartIF< IProperty >
UnsignedIntegerPropertyRef
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition: Property.h:754
Gaudi::Details::Property::DefaultStringConverter::fromString
TYPE fromString(const TYPE &ref_value, const std::string &s) final override
Definition: Property.h:202
Kernel.h
Gaudi::Property::Property
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, Details::Property::ImmediatelyInvokeHandler invoke, std::string doc="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
Definition: Property.h:429
Gaudi::operator!=
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:702
Gaudi::Property::setValue
bool setValue(const ValueType &v)
Definition: Property.h:528
Gaudi::Utils::toStream
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:284
UnsignedShortArrayProperty
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition: Property.h:771
Gaudi::Details::Property::BoundedVerifier
Definition: Property.h:228
SimpleProperty
Gaudi::Property< TYPE > SimpleProperty
Definition: Property.h:722
LongLongPropertyRef
Gaudi::Property< long long & > LongLongPropertyRef
Definition: Property.h:757
Gaudi::Details::PropertyBase::declareReadHandler
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:71
Gaudi::Property::is_this_type_v
static constexpr bool is_this_type_v
helper typedefs for SFINAE
Definition: Property.h:370
IntegerArrayProperty
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition: Property.h:772
Gaudi::Details::operator<<
std::ostream & operator<<(std::ostream &stream, const PropertyBase &prop)
Definition: Property.h:136
Gaudi::operator==
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition: Property.h:696
Gaudi::Property::useUpdateHandler
bool useUpdateHandler() override
manual trigger for callback for update
Definition: Property.h:470
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Details::PropertyBase::setDocumentation
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:86
LongLongProperty
Gaudi::Property< long long > LongLongProperty
Definition: Property.h:738
Gaudi::Details::Property::ReadHandler
Definition: Property.h:307
std::function
GaudiHandleArrayProperty::value
const GaudiHandleArrayBase & value() const
Definition: Property.h:903
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
LongPropertyRef
Gaudi::Property< long & > LongPropertyRef
Definition: Property.h:755
Gaudi::Property< vector< std::string > >::not_copying
std::enable_if_t<!is_this_type_v< T > > not_copying
Definition: Property.h:372
Gaudi::Details::Property::UpdateHandler::m_updateCallBack
std::function< void(PropertyBase &)> m_updateCallBack
Definition: Property.h:316
Gaudi::Details::PropertyBase::declareUpdateHandler
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
DoubleArrayPropertyRef
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Definition: Property.h:798
GaudiHandleArrayProperty::load
bool load(PropertyBase &destination) const override
Definition: Property.h:893
Gaudi::Details::PropertyBase::ownerTypeName
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
Definition: Property.h:105
std::function::swap
T swap(T... args)
Gaudi::Details::Property::SwapCall::tmp
callback_t tmp
Definition: Property.h:289
Gaudi::Details::Property::BoundedVerifier::hasLower
bool hasLower() const
Return if it has a lower bound.
Definition: Property.h:237
Gaudi::Property::operator=
Property & operator=(T &&v)
Assignment from value.
Definition: Property.h:512
FloatProperty
Gaudi::Property< float > FloatProperty
Definition: Property.h:740
PropertyWithHandlers::readCallBack
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:824
Gaudi::Utils::hasProperty
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
Definition: Property.cpp:95
IntegerProperty
Gaudi::Property< int > IntegerProperty
Definition: Property.h:734
UnsignedLongLongArrayPropertyRef
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition: Property.h:796
Gaudi::Details::PropertyBase::setOwnerType
void setOwnerType()
set the type of the owner class (used for documentation)
Definition: Property.h:97
Gaudi::Details::Property::BoundedVerifier::clearUpper
void clearUpper()
Clear upper bound value.
Definition: Property.h:261
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:334
Gaudi::Details::Property::ImmediatelyInvokeHandler
Gaudi::tagged_bool< class ImmediatelyInvokeHandler_tag > ImmediatelyInvokeHandler
Definition: Property.h:141
UnsignedLongLongProperty
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition: Property.h:739
FloatPropertyRef
Gaudi::Property< float & > FloatPropertyRef
Definition: Property.h:759
Gaudi::Property< vector< std::string > >::StorageType
vector< std::string > StorageType
Hosted type.
Definition: Property.h:356
Gaudi::Details::Property::SwapCall::orig
callback_t & orig
Definition: Property.h:289
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::Details::Property::NoHandler::getReadHandler
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:300
Gaudi::Details::PropertyBase::toStream
virtual void toStream(std::ostream &out) const =0
value -> stream
std
STL namespace.
Gaudi::Details::Property::DefaultStringConverterImpl::fromString
virtual TYPE fromString(const TYPE &ref_value, const std::string &s)=0
GaudiHandleProperty
Definition: Property.h:845
StringArrayProperty
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition: Property.h:782
UnsignedShortArrayPropertyRef
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition: Property.h:790
Gaudi::Details::Property::DefaultStringConverterImpl::toString
std::string toString(const TYPE &v)
Definition: Property.h:169
Gaudi::Property::Property
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(), std::string doc="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
Definition: Property.h:421
UnsignedCharArrayProperty
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Definition: Property.h:769
Gaudi::Details::Property::BoundedVerifier::upper
const TYPE & upper() const
Return the upper bound value.
Definition: Property.h:243
Gaudi::Details::Property::BoundedVerifier::setLower
void setLower(const TYPE &value)
Set lower bound value.
Definition: Property.h:246
Gaudi::Property::m_handlers
HandlersType m_handlers
Definition: Property.h:366
UnsignedShortProperty
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition: Property.h:733
Gaudi::Details::Property::NoHandler
Definition: Property.h:295
UnsignedLongProperty
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition: Property.h:737
GaudiHandleProperty::load
bool load(PropertyBase &destination) const override
Definition: Property.h:856
Gaudi::Property::readCallBack
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:461
StringPropertyRef
Gaudi::Property< std::string & > StringPropertyRef
Definition: Property.h:763
Gaudi::Property::m_value
StorageType m_value
Storage.
Definition: Property.h:364
Gaudi::Details::PropertyBase::m_name
std::string_view m_name
property name
Definition: Property.h:127
CharPropertyRef
Gaudi::Property< char & > CharPropertyRef
Definition: Property.h:748
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
BooleanArrayPropertyRef
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition: Property.h:785
LongDoubleArrayProperty
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition: Property.h:780
LongLongArrayProperty
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition: Property.h:776
DoubleArrayProperty
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition: Property.h:779
Gaudi::Details::PropertyBase::setOwnerType
void setOwnerType(const std::type_info &ownerType)
set the type of the owner class (used for documentation)
Definition: Property.h:93
ShortArrayProperty
Gaudi::Property< std::vector< short > > ShortArrayProperty
Definition: Property.h:770
UnsignedLongArrayPropertyRef
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Definition: Property.h:794
UnsignedIntegerArrayProperty
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition: Property.h:773
CommonParsers.h
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
Gaudi::Details::PropertyBase::PropertyBase
PropertyBase(const std::type_info &type, std::string name="", std::string doc="")
constructor from the property name and the type
Definition: Property.h:111
Gaudi::Property::declareUpdateHandler
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:455
Gaudi::Property::Property
Property()
Construct an anonymous property with default constructed value.
Definition: Property.h:444
Gaudi::Details::PropertyBase::fromString
virtual StatusCode fromString(const std::string &value)=0
string -> value
PropertyWithHandlers
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:806
std::type_info
Gaudi::Details::Property::NullVerifier::operator()
void operator()(const TYPE &) const
Definition: Property.h:225
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
PropertyFwd.h
Gaudi::Property::operator+=
Property & operator+=(const T &other)
Definition: Property.h:613
Gaudi::Details::PropertyBase::type_info
const std::type_info * type_info() const
property type-info
Definition: Property.h:40
LongArrayProperty
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition: Property.h:774
Gaudi::Details::Property::BoundedVerifier::m_lowerBound
TYPE m_lowerBound
Definition: Property.h:282
Gaudi::Property< vector< std::string > >::ValueType
typename std::remove_reference< StorageType >::type ValueType
Definition: Property.h:357
LongArrayPropertyRef
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition: Property.h:793
SignedCharProperty
Gaudi::Property< signed char > SignedCharProperty
Definition: Property.h:730
Gaudi::Property::clone
Details::PropertyBase * clone() const override
clones the current property
Definition: Property.h:536
Gaudi::Details::Property::BoundedVerifier::m_hasUpperBound
bool m_hasUpperBound
Definition: Property.h:281
CharProperty
Gaudi::Property< char > CharProperty
Definition: Property.h:729
IOTest.N
int N
Definition: IOTest.py:99
Gaudi::Property::operator-=
Property & operator-=(const T &other)
Definition: Property.h:618
IntegerPropertyRef
Gaudi::Property< int & > IntegerPropertyRef
Definition: Property.h:753
GaudiHandleProperty::m_pValue
GaudiHandleBase * m_pValue
Pointer to the real property.
Definition: Property.h:876
UnsignedLongPropertyRef
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition: Property.h:756
Gaudi::Details::Property::BoundedVerifier::lower
const TYPE & lower() const
Return the lower bound value.
Definition: Property.h:241
gaudirun.args
args
Definition: gaudirun.py:307
Gaudi::Property::Property
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(PropertyBase &), std::string doc="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
Definition: Property.h:413
GaudiHandleProperty::clone
GaudiHandleProperty * clone() const override
clones the current property
Definition: Property.h:854
Gaudi::Property::operator++
Property & operator++()
Definition: Property.h:595
std::exception::what
T what(T... args)
Gaudi::Details::PropertyBase::PropertyBase
PropertyBase(std::string name, const std::type_info &type)
constructor from the property name and the type
Definition: Property.h:116
Gaudi::Details::Property::BoundedVerifier::setBounds
void setBounds(const TYPE &lower, const TYPE &upper)
Set both bounds (lower and upper) at the same time.
Definition: Property.h:267
Gaudi::Details::Property::SwapCall::operator()
void operator()(PropertyBase &p) const
Definition: Property.h:292
LongDoubleArrayPropertyRef
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition: Property.h:799
Gaudi::Details::Property::DefaultStringConverter< TYPE, std::enable_if_t< std::is_default_constructible_v< TYPE > > >::fromString
TYPE fromString(const TYPE &, const std::string &s) final override
Definition: Property.h:212
gaudirun.dest
dest
Definition: gaudirun.py:201
Gaudi::Property::load
bool load(Details::PropertyBase &dest) const override
set value to another property
Definition: Property.h:671
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Details::Property::NoHandler::useReadHandler
void useReadHandler(const PropertyBase &) const
Definition: Property.h:296
Gaudi::Property::Property
Property(std::string name, T &&value, std::string doc="")
the constructor with property name, value and documentation.
Definition: Property.h:378
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:526
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
gaudirun.type
type
Definition: gaudirun.py:142
Gaudi::Details::PropertyBase::m_typeinfo
const std::type_info * m_typeinfo
property type
Definition: Property.h:131
UnsignedIntegerProperty
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition: Property.h:735
SmartIF.h
Gaudi::Property::toStream
void toStream(std::ostream &out) const override
value -> stream
Definition: Property.h:687
Gaudi::Details::Property::ReadHandler::getReadHandler
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:313
CharArrayProperty
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition: Property.h:767
Gaudi::Details::PropertyBase::declareReadHandler
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
BooleanProperty
Gaudi::Property< bool > BooleanProperty
Definition: Property.h:728
Gaudi::Details::PropertyBase::ownerType
const std::type_info * ownerType() const
get the type of the owner class (used for documentation)
Definition: Property.h:102
PropertyWithHandlers::declareUpdateHandler
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:818
UnsignedLongLongArrayProperty
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition: Property.h:777
GaudiPython.Bindings.GaudiHandleArrayProperty
GaudiHandleArrayProperty
Definition: Bindings.py:54
Gaudi::Property::verifier
VerifierType & verifier()
Accessor to verifier.
Definition: Property.h:522
PropertyWithHandlers::declareReadHandler
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:813
TaggedBool.h
Gaudi::Property::operator<
bool operator<(const T &other) const
"less" comparison
Definition: Property.h:500
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
IOTest.end
def end
Definition: IOTest.py:112
Gaudi::Details::PropertyBase::declareUpdateHandler
PropertyBase & declareUpdateHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:76
Gaudi::Details::Property::DefaultStringConverterImpl::fromStringImpl
void fromStringImpl(TYPE &buffer, const std::string &s)
Definition: Property.h:180
toStream
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition: DataObjID.cpp:82
Gaudi::Details::PropertyBase::m_documentation
std::string_view m_documentation
property doc string
Definition: Property.h:129
DoubleProperty
Gaudi::Property< double > DoubleProperty
Definition: Property.h:741
GaudiHandleArrayProperty::clone
GaudiHandleArrayProperty * clone() const override
clones the current property
Definition: Property.h:891
Converter
Converter base class.
Definition: Converter.h:24
std::exception
STL class.
Gaudi::Details::PropertyBase::setName
void setName(std::string value)
set the new value for the property name
Definition: Property.h:84
IntegerArrayPropertyRef
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Definition: Property.h:791
Gaudi::Details::PropertyBase::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:49
std::move
T move(T... args)
GaudiHandleArrayProperty::assign
bool assign(const PropertyBase &source) override
Definition: Property.h:895
Gaudi::Property::operator--
Property & operator--()
Definition: Property.h:604
LongLongArrayPropertyRef
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition: Property.h:795
DoublePropertyRef
Gaudi::Property< double & > DoublePropertyRef
Definition: Property.h:760
Gaudi::Details::Property::ReadHandler::useReadHandler
void useReadHandler(const PropertyBase &p) const
Definition: Property.h:309
UnsignedCharArrayPropertyRef
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition: Property.h:788
parse
StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:46
GaudiHandleArrayBase
Base class of array's of various gaudihandles.
Definition: GaudiHandle.h:330
LongDoublePropertyRef
Gaudi::Property< long double & > LongDoublePropertyRef
Definition: Property.h:761
IProperty.h
Gaudi::Property::value
ValueType & value()
Definition: Property.h:527
std::vector
STL class.
Gaudi::Details::PropertyBase::type
std::string type() const
property type
Definition: Property.h:42
Gaudi::Parsers::InputData
Helper class to enable ADL for parsers.
Definition: InputData.h:8
SignedCharArrayProperty
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition: Property.h:768
PropertyWithHandlers::useUpdateHandler
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:832
StringProperty
Gaudi::Property< std::string > StringProperty
Definition: Property.h:744
std::logic_error
STL class.
Gaudi::Details::Property::UpdateHandler::setUpdateHandler
void setUpdateHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:326
LongDoubleProperty
Gaudi::Property< long double > LongDoubleProperty
Definition: Property.h:742
GaudiHandleArrayProperty::operator=
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition: Property.h:886
Gaudi::Details::Property::DefaultStringConverterImpl::~DefaultStringConverterImpl
virtual ~DefaultStringConverterImpl()=default
Gaudi::Details::Property::SwapCall::SwapCall
SwapCall(callback_t &input)
Definition: Property.h:290
GaudiHandleArrayProperty::m_pValue
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition: Property.h:913
ShortProperty
Gaudi::Property< short > ShortProperty
Definition: Property.h:732
Gaudi::Property::set
bool set(const ValueType &v)
Definition: Property.h:532
Gaudi::Details::Property::NoHandler::getUpdateHandler
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:305
UnsignedLongArrayProperty
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Definition: Property.h:775
SimplePropertyRef
Gaudi::Property< TYPE & > SimplePropertyRef
Definition: Property.h:725
gaudirun.s
string s
Definition: gaudirun.py:316
GaudiPython.Bindings.GaudiHandleProperty
GaudiHandleProperty
Definition: Bindings.py:53
UnsignedLongLongPropertyRef
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition: Property.h:758
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Gaudi::Details::Property::BoundedVerifier::operator()
void operator()(const TYPE &value) const
Definition: Property.h:229
Gaudi::Property::operator!=
bool operator!=(const T &other) const
inequality comparison
Definition: Property.h:494
Gaudi::Details::Property::BoundedVerifier::clearBounds
void clearBounds()
Clear both bounds (lower and upper) at the same time.
Definition: Property.h:273
InputData.h
PropertyWithHandlers::updateCallBack
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:826
Gaudi::Details::Property::ReadHandler::setReadHandler
void setReadHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:312
Gaudi::Property::verifier
const VerifierType & verifier() const
Accessor to verifier.
Definition: Property.h:520
PropertyWithHandlers::m_handlers
Handler m_handlers
Definition: Property.h:807
StringArrayPropertyRef
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition: Property.h:801
Gaudi::Property::assign
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition: Property.h:659
Gaudi::Details::Property::DefaultStringConverterImpl
Definition: Property.h:166
GaudiHandleProperty::assign
bool assign(const PropertyBase &source) override
Definition: Property.h:858
LongProperty
Gaudi::Property< long > LongProperty
Definition: Property.h:736
Gaudi::Details::Property::NoHandler::setUpdateHandler
void setUpdateHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:302
CharArrayPropertyRef
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition: Property.h:786
std::remove_reference
Gaudi::Property::Property
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, std::string doc="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
Definition: Property.h:404
Gaudi::Details::Property::BoundedVerifier::clearLower
void clearLower()
Clear lower bound value.
Definition: Property.h:256
GaudiHandleBase
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:89
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
Gaudi::Details::Property::BoundedVerifier::hasUpper
bool hasUpper() const
Return if it has a lower bound.
Definition: Property.h:239
GaudiHandleProperty::value
const GaudiHandleBase & value() const
Definition: Property.h:866
Gaudi::Details::Property::UpdateHandler
Definition: Property.h:315
ToStream.h
implementation of various functions for streaming.
Gaudi::Property::Property
Property(T &&v)
Construct an anonymous property from a value.
Definition: Property.h:439
UnsignedShortPropertyRef
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition: Property.h:752
FloatArrayProperty
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition: Property.h:778
Gaudi::Property::operator++
ValueType operator++(int)
Definition: Property.h:600
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:20
Gaudi::Details::Property::SwapCall
helper to disable a while triggering it, to avoid infinite recursion
Definition: Property.h:287
Gaudi::Details::Property::BoundedVerifier::m_upperBound
TYPE m_upperBound
Definition: Property.h:283
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
GaudiHandleProperty::operator=
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition: Property.h:849
ShortArrayPropertyRef
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition: Property.h:789
GaudiHandleArrayProperty
Definition: Property.h:882
std::ostream
STL class.
Gaudi::Property::Property
Property(OWNER *owner, std::string name, T &&value, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:395
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
Gaudi::Details::Property::NullVerifier
Definition: Property.h:223
Gaudi::Details::Property::DefaultStringConverter
Definition: Property.h:201
Gaudi::Property::declareReadHandler
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:450
Gaudi::Details::Property::NoHandler::useUpdateHandler
void useUpdateHandler(const PropertyBase &) const
Definition: Property.h:301
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
UnsignedCharProperty
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition: Property.h:731
Gaudi::Property::m_verifier
VerifierType m_verifier
Definition: Property.h:365
ShortPropertyRef
Gaudi::Property< short & > ShortPropertyRef
Definition: Property.h:751
Gaudi::Details::Property::BoundedVerifier::setUpper
void setUpper(const TYPE &value)
Set upper bound value.
Definition: Property.h:251
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: Property.h:38
Gaudi::Details::Property::NoHandler::setReadHandler
void setReadHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:297
Gaudi::Property< vector< std::string > >::HandlersType
Details::Property::UpdateHandler HandlersType
Definition: Property.h:359
UnsignedCharPropertyRef
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition: Property.h:750
Gaudi::Property::operator--
ValueType operator--(int)
Definition: Property.h:609
std::invalid_argument
STL class.
BooleanArrayProperty
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition: Property.h:766
UnsignedIntegerArrayPropertyRef
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition: Property.h:792
Gaudi::Property::operator==
bool operator==(const T &other) const
equality comparison
Definition: Property.h:488
Gaudi::Property::updateCallBack
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:465
Gaudi::Property::fromString
StatusCode fromString(const std::string &source) override
string -> value
Definition: Property.h:676
Gaudi::Utils::getProperty
GAUDI_API Gaudi::Details::PropertyBase * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
Definition: Property.cpp:204
BooleanPropertyRef
Gaudi::Property< bool & > BooleanPropertyRef
Definition: Property.h:747
Gaudi::Details::Property::UpdateHandler::useUpdateHandler
void useUpdateHandler(PropertyBase &p)
Definition: Property.h:317
Gaudi::Details::Property::ReadUpdateHandler
Definition: Property.h:329
PropertyWithHandlers::useReadHandler
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:829