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 <boost/utility/string_ref.hpp>
7 #include <stdexcept>
8 #include <string>
9 #include <typeinfo>
10 // ============================================================================
11 // Application C++ Class Headers
12 // ============================================================================
13 #include "GaudiKernel/IProperty.h"
14 #include "GaudiKernel/Kernel.h"
15 #include "GaudiKernel/Parsers.h"
17 #include "GaudiKernel/SmartIF.h"
18 #include "GaudiKernel/ToStream.h"
19 
20 namespace Gaudi
21 {
22  namespace Details
23  {
24  // ============================================================================
33  {
34  private:
35  // the default constructor is disabled
36  PropertyBase() = delete;
37 
38  public:
40  const std::string name() const { return m_name.to_string(); }
42  std::string documentation() const { return m_documentation.to_string() + " [" + ownerTypeName() + "]"; }
44  const std::type_info* type_info() const { return m_typeinfo; }
46  std::string type() const { return m_typeinfo->name(); }
48  virtual bool load( PropertyBase& dest ) const = 0;
50  virtual bool assign( const PropertyBase& source ) = 0;
51 
52  public:
54  virtual std::string toString() const = 0;
56  virtual void toStream( std::ostream& out ) const = 0;
58  virtual StatusCode fromString( const std::string& value ) = 0;
59 
60  public:
62  virtual PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) = 0;
64  virtual PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) = 0;
65 
67  virtual const std::function<void( PropertyBase& )> readCallBack() const = 0;
69  virtual const std::function<void( PropertyBase& )> updateCallBack() const = 0;
70 
72  virtual bool useUpdateHandler() = 0;
73 
74  template <class HT>
75  inline PropertyBase& declareReadHandler( void ( HT::*MF )( PropertyBase& ), HT* instance )
76  {
77  return declareReadHandler( [=]( PropertyBase& p ) { ( instance->*MF )( p ); } );
78  }
79 
80  template <class HT>
81  inline PropertyBase& declareUpdateHandler( void ( HT::*MF )( PropertyBase& ), HT* instance )
82  {
83  return declareUpdateHandler( [=]( PropertyBase& p ) { ( instance->*MF )( p ); } );
84  }
85 
86  public:
88  virtual ~PropertyBase() = default;
90  void setName( std::string value ) { m_name = to_view( std::move( value ) ); }
92  void setDocumentation( std::string value ) { m_documentation = to_view( std::move( value ) ); }
94  virtual std::ostream& fillStream( std::ostream& ) const;
96  virtual PropertyBase* clone() const = 0;
97 
99  void setOwnerType( const std::type_info& ownerType ) { m_ownerType = &ownerType; }
100 
102  template <class OWNER>
104  {
105  setOwnerType( typeid( OWNER ) );
106  }
107 
109  const std::type_info* ownerType() const { return m_ownerType; }
110 
113  {
114  return m_ownerType ? System::typeinfoName( *m_ownerType ) : std::string( "unknown owner type" );
115  }
116 
117  protected:
120  : m_name( to_view( std::move( name ) ) ), m_documentation( to_view( std::move( doc ) ) ), m_typeinfo( &type )
121  {
122  }
125  : m_name( to_view( std::move( name ) ) ), m_documentation( m_name ), m_typeinfo( &type )
126  {
127  }
129  PropertyBase( const PropertyBase& ) = default;
131  PropertyBase& operator=( const PropertyBase& ) = default;
132 
133  private:
135  static boost::string_ref to_view( std::string str );
137  boost::string_ref m_name;
139  boost::string_ref m_documentation;
143  const std::type_info* m_ownerType = nullptr;
144  };
145 
146  inline std::ostream& operator<<( std::ostream& stream, const PropertyBase& prop )
147  {
148  return prop.fillStream( stream );
149  }
150 
151  namespace Property
152  {
153  template <class TYPE>
155  inline std::string toString( const TYPE& v ) { return Gaudi::Utils::toString( v ); }
156  inline TYPE fromString( const std::string& s )
157  {
158  TYPE tmp;
159  if ( !Gaudi::Parsers::parse( tmp, s ).isSuccess() ) {
160  throw std::invalid_argument( "cannot parse '" + s + "' to " + System::typeinfoName( typeid( TYPE ) ) );
161  }
162  return tmp;
163  }
164  };
165  template <>
167  {
168  return v;
169  }
170  struct NullVerifier {
171  template <class TYPE>
172  void operator()( const TYPE& ) const
173  {
174  }
175  };
176  template <class TYPE>
178  void operator()( const TYPE& value ) const
179  {
180  // throw the exception if the limit is defined and value is outside
181  if ( ( m_hasLowerBound && ( value < m_lowerBound ) ) || ( m_hasUpperBound && ( m_upperBound < value ) ) )
182  throw std::out_of_range( "value " + Gaudi::Utils::toString( value ) + " outside range" );
183  }
184 
186  bool hasLower() const { return m_hasLowerBound; }
188  bool hasUpper() const { return m_hasUpperBound; }
190  const TYPE& lower() const { return m_lowerBound; }
192  const TYPE& upper() const { return m_upperBound; }
193 
195  void setLower( const TYPE& value )
196  {
197  m_hasLowerBound = true;
198  m_lowerBound = value;
199  }
201  void setUpper( const TYPE& value )
202  {
203  m_hasUpperBound = true;
204  m_upperBound = value;
205  }
207  void clearLower()
208  {
209  m_hasLowerBound = false;
210  m_lowerBound = TYPE();
211  }
213  void clearUpper()
214  {
215  m_hasUpperBound = false;
216  m_upperBound = TYPE();
217  }
218 
220  void setBounds( const TYPE& lower, const TYPE& upper )
221  {
222  setLower( lower );
223  setUpper( upper );
224  }
225 
227  void clearBounds()
228  {
229  clearLower();
230  clearUpper();
231  }
232 
233  private:
235  bool m_hasLowerBound{false};
236  bool m_hasUpperBound{false};
237  TYPE m_lowerBound{};
238  TYPE m_upperBound{};
239  };
240 
242  struct SwapCall {
244  callback_t tmp, &orig;
245  SwapCall( callback_t& input ) : orig( input ) { tmp.swap( orig ); }
246  ~SwapCall() { orig.swap( tmp ); }
247  void operator()( PropertyBase& p ) const { tmp( p ); }
248  };
249 
250  struct NoHandler {
251  void useReadHandler( const PropertyBase& ) const {}
253  {
254  throw std::logic_error( "setReadHandler not implemented for this class" );
255  }
257  void useUpdateHandler( const PropertyBase& ) const {}
259  {
260  throw std::logic_error( "setUpdateHandler not implemented for this class" );
261  }
263  };
266  void useReadHandler( const PropertyBase& p ) const
267  {
268  if ( m_readCallBack ) {
269  SwapCall{m_readCallBack}( const_cast<PropertyBase&>( p ) );
270  }
271  }
272  void setReadHandler( std::function<void( PropertyBase& )> fun ) { m_readCallBack = std::move( fun ); }
273  std::function<void( PropertyBase& )> getReadHandler() const { return m_readCallBack; }
274  };
278  {
279  if ( m_updateCallBack ) {
280  try {
281  SwapCall{m_updateCallBack}( p );
282  } catch ( const std::exception& x ) {
283  throw std::invalid_argument( "failure in update handler of '" + p.name() + "': " + x.what() );
284  }
285  }
286  }
287  void setUpdateHandler( std::function<void( PropertyBase& )> fun ) { m_updateCallBack = std::move( fun ); }
288  std::function<void( PropertyBase& )> getUpdateHandler() const { return m_updateCallBack; }
289  };
291  using ReadHandler::useReadHandler;
292  using ReadHandler::setReadHandler;
293  using ReadHandler::getReadHandler;
294  using UpdateHandler::useUpdateHandler;
295  using UpdateHandler::setUpdateHandler;
296  using UpdateHandler::getUpdateHandler;
297  };
298  }
299 
300  } // namespace Details
301 
302  // ============================================================================
310  // ============================================================================
311  template <class TYPE, class VERIFIER = Details::Property::NullVerifier,
312  class HANDLERS = Details::Property::UpdateHandler>
314  {
315  public:
316  // ==========================================================================
318  using StorageType = TYPE;
320  using VerifierType = VERIFIER;
321  using HandlersType = HANDLERS;
322 
323  private:
330  template <class T>
332  template <class T>
335  public:
336  // ==========================================================================
338  template <class T = ValueType>
339  inline Property( std::string name, T&& value, std::string doc = "" )
340  : Details::PropertyBase( typeid( ValueType ), std::move( name ), std::move( doc ) )
341  , m_value( std::forward<T>( value ) )
342  {
343  m_verifier( m_value );
344  }
347  template <class OWNER, class T = ValueType,
349  inline Property( OWNER* owner, std::string name, T&& value = ValueType{}, std::string doc = "" )
350  : Property( std::move( name ), std::forward<T>( value ), std::move( doc ) )
351  {
352  owner->declareProperty( *this );
353  setOwnerType<OWNER>();
354  }
355 
360  Property( T&& v ) : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value( std::forward<T>( v ) )
361  {
362  }
363 
366  template <typename T = StorageType, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
367  Property() : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value()
368  {
369  }
370 
373 
376  {
377  m_handlers.setReadHandler( std::move( fun ) );
378  return *this;
379  }
382  {
383  m_handlers.setUpdateHandler( std::move( fun ) );
384  return *this;
385  }
386 
389  {
390  return m_handlers.getReadHandler();
391  }
394  {
395  return m_handlers.getUpdateHandler();
396  }
397 
399  bool useUpdateHandler() override
400  {
401  m_handlers.useUpdateHandler( *this );
402  return true;
403  }
404 
406  operator const ValueType&() const
407  {
408  m_handlers.useReadHandler( *this );
409  return m_value;
410  }
411  // /// Automatic conversion to value (reference).
412  // operator ValueType& () {
413  // useReadHandler();
414  // return m_value;
415  // }
416 
418  template <class T>
419  inline bool operator==( const T& other ) const
420  {
421  return m_value == other;
422  }
423 
425  template <class T>
426  inline bool operator!=( const T& other ) const
427  {
428  return m_value != other;
429  }
430 
432  template <class T>
433  inline bool operator<( const T& other ) const
434  {
435  return m_value < other;
436  }
437 
439  template <class T>
440  decltype( std::declval<ValueType>() + std::declval<T>() ) operator+( const T& other ) const
441  {
442  return m_value + other;
443  }
444 
446  template <class T = ValueType>
447  Property& operator=( T&& v )
448  {
449  m_verifier( v );
450  m_value = std::forward<T>( v );
451  m_handlers.useUpdateHandler( *this );
452  return *this;
453  }
454 
456  const VerifierType& verifier() const { return m_verifier; }
458  VerifierType& verifier() { return m_verifier; }
459 
462  const ValueType& value() const { return *this; }
463  ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
464  bool setValue( const ValueType& v )
465  {
466  *this = v;
467  return true;
468  }
469  bool set( const ValueType& v )
470  {
471  *this = v;
472  return true;
473  }
474  Details::PropertyBase* clone() const override { return new Property( *this ); }
476 
480  template <class T = const ValueType>
481  inline decltype( std::declval<T>().size() ) size() const
482  {
483  return value().size();
484  }
485  template <class T = const ValueType>
486  inline decltype( std::declval<T>().length() ) length() const
487  {
488  return value().length();
489  }
490  template <class T = const ValueType>
491  inline decltype( std::declval<T>().empty() ) empty() const
492  {
493  return value().empty();
494  }
495  template <class T = ValueType>
496  inline decltype( std::declval<T>().clear() ) clear()
497  {
498  value().clear();
499  }
500  template <class T = const ValueType>
501  inline decltype( std::declval<T>().begin() ) begin() const
502  {
503  return value().begin();
504  }
505  template <class T = const ValueType>
506  inline decltype( std::declval<T>().end() ) end() const
507  {
508  return value().end();
509  }
510  template <class T = ValueType>
511  inline decltype( std::declval<T>().begin() ) begin()
512  {
513  return value().begin();
514  }
515  template <class T = ValueType>
516  inline decltype( std::declval<T>().end() ) end()
517  {
518  return value().end();
519  }
520  template <class ARG, class T = const ValueType>
521  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg ) const
522  {
523  return value()[arg];
524  }
525  template <class ARG, class T = ValueType>
526  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
527  {
528  return value()[arg];
529  }
530  template <class T = const ValueType>
531  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key ) const
532  {
533  return value().find( key );
534  }
535  template <class T = ValueType>
536  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key )
537  {
538  return value().find( key );
539  }
540  template <class ARG, class T = ValueType>
541  inline decltype( std::declval<T>().erase( ARG{} ) ) erase( ARG arg )
542  {
543  return value().erase( arg );
544  }
545  template <class = ValueType>
547  {
548  ++value();
549  return *this;
550  }
551  template <class = ValueType>
552  inline ValueType operator++( int )
553  {
554  return m_value++;
555  }
556  template <class = ValueType>
558  {
559  --value();
560  return *this;
561  }
562  template <class = ValueType>
563  inline ValueType operator--( int )
564  {
565  return m_value--;
566  }
567  template <class T = ValueType>
568  inline Property& operator+=( const T& other )
569  {
570  m_value += other;
571  return *this;
572  }
573  template <class T = ValueType>
574  inline Property& operator-=( const T& other )
575  {
576  m_value -= other;
577  return *this;
578  }
580  // ==========================================================================
581  public:
583  bool assign( const Details::PropertyBase& source ) override
584  {
585  // Check if the property of is of "the same" type, except for strings
586  const Property* p =
587  ( std::is_same<ValueType, std::string>::value ) ? nullptr : dynamic_cast<const Property*>( &source );
588  if ( p ) {
589  *this = p->value();
590  } else {
591  this->fromString( source.toString() ).ignore();
592  }
593  return true;
594  }
596  bool load( Details::PropertyBase& dest ) const override
597  {
598  // delegate to the 'opposite' method
599  return dest.assign( *this );
600  }
602  StatusCode fromString( const std::string& source ) override
603  {
604  using Converter = Details::Property::StringConverter<ValueType>;
605  *this = Converter().fromString( source );
606  return StatusCode::SUCCESS;
607  }
609  std::string toString() const override
610  {
611  using Converter = Details::Property::StringConverter<ValueType>;
612  return Converter().toString( *this );
613  }
615  void toStream( std::ostream& out ) const override
616  {
617  m_handlers.useReadHandler( *this );
618  Utils::toStream( m_value, out );
619  }
620  };
621 
623  template <class T, class TP, class V, class H>
624  bool operator==( const T& v, const Property<TP, V, H>& p )
625  {
626  return p == v;
627  }
628 
630  template <class T, class TP, class V, class H>
631  bool operator!=( const T& v, const Property<TP, V, H>& p )
632  {
633  return p != v;
634  }
635 
637  template <class T, class TP, class V, class H>
638  decltype( std::declval<TP>() + std::declval<T>() ) operator+( const T& v, const Property<TP, V, H>& p )
639  {
640  return v + p.value();
641  }
642 
643  template <class TYPE, class HANDLERS = Details::Property::UpdateHandler>
645 
646  template <class TYPE>
649 
650 } // namespace Gaudi
651 
652 template <class TYPE>
654 
655 template <class TYPE>
657 
658 // Typedef Properties for built-in types
674 
676 
677 // Typedef PropertyRefs for built-in types
693 
695 
696 // Typedef "Arrays" of Properties for built-in types
712 
714 
715 // Typedef "Arrays" of PropertyRefs for built-in types
731 
733 
737 {
739 
740 public:
742 
744  PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override
745  {
746  m_handlers.setReadHandler( std::move( fun ) );
747  return *this;
748  }
750  PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override
751  {
752  m_handlers.setUpdateHandler( std::move( fun ) );
753  return *this;
754  }
755 
757  const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
759  const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
760 
762  void useReadHandler() const { m_handlers.useReadHandler( *this ); }
763 
765  bool useUpdateHandler() override
766  {
767  m_handlers.useUpdateHandler( *this );
768  return true;
769  }
770 };
771 
772 // forward-declaration is sufficient here
773 class GaudiHandleBase;
774 
775 // implementation in header file only where the GaudiHandleBase class
776 // definition is not needed. The rest goes into the .cpp file.
777 // The goal is to decouple the header files, to avoid that the whole
778 // world depends on GaudiHandle.h
780 {
781 public:
783 
785  {
786  setValue( value );
787  return *this;
788  }
789 
790  GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
791 
792  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
793 
794  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
795 
796  std::string toString() const override;
797 
798  void toStream( std::ostream& out ) const override;
799 
800  StatusCode fromString( const std::string& s ) override;
801 
802  const GaudiHandleBase& value() const
803  {
804  useReadHandler();
805  return *m_pValue;
806  }
807 
808  bool setValue( const GaudiHandleBase& value );
809 
810 private:
814 };
815 
816 // forward-declaration is sufficient here
818 
820 {
821 public:
823 
825  {
826  setValue( value );
827  return *this;
828  }
829 
830  GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
831 
832  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
833 
834  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
835 
836  std::string toString() const override;
837 
838  void toStream( std::ostream& out ) const override;
839 
840  StatusCode fromString( const std::string& s ) override;
841 
843  {
844  useReadHandler();
845  return *m_pValue;
846  }
847 
848  bool setValue( const GaudiHandleArrayBase& value );
849 
850 private:
854 };
855 
856 namespace Gaudi
857 {
858  namespace Utils
859  {
860  // ========================================================================
878  GAUDI_API bool hasProperty( const IProperty* p, const std::string& name );
879  // ========================================================================
897  GAUDI_API bool hasProperty( const IInterface* p, const std::string& name );
898  // ========================================================================
917  // ========================================================================
936  // ========================================================================
960  // ========================================================================
985  // ========================================================================
1009  template <class TYPE>
1010  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
1011  // ========================================================================
1034  template <class TYPE>
1035  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value )
1036  {
1037  return setProperty( component, name, value, std::string() );
1038  }
1039  // ========================================================================
1053  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
1054  const std::string& doc = "" );
1055  // ========================================================================
1069  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
1070  const std::string& doc = "" );
1071  // ========================================================================
1085  template <unsigned N>
1086  StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
1087  const std::string& doc = "" )
1088  {
1089  return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
1090  }
1091  // ========================================================================
1122  template <class TYPE>
1123  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc )
1124  {
1125  return component && hasProperty( component, name )
1126  ? Gaudi::Utils::setProperty( component, name, Gaudi::Utils::toString( value ), doc )
1128  }
1129  // ========================================================================
1151  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1152  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1153  // ========================================================================
1175  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1176  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1177  // ========================================================================
1200  template <class TYPE>
1201  StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1202  const std::string& doc = "" )
1203  {
1204  return setProperty( component, name, &value, doc );
1205  }
1206  // ========================================================================
1227  template <class TYPE>
1228  StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1229  const std::string& doc = "" )
1230  {
1231  if ( !component ) {
1232  return StatusCode::FAILURE;
1233  }
1234  auto property = SmartIF<IProperty>{component};
1235  return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
1236  }
1237  // ========================================================================
1250  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1251  const std::string& doc = "" );
1252  // ========================================================================
1265  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1266  const std::string& doc = "" );
1267  // ========================================================================
1281  template <unsigned N>
1282  StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1283  const std::string& doc = "" )
1284  {
1285  if ( 0 == component ) {
1286  return StatusCode::FAILURE;
1287  }
1288  return setProperty( component, name, std::string{value, value + N}, doc );
1289  }
1290  // ========================================================================
1312  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1313  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1314  // ========================================================================
1336  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1337  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1338  // ========================================================================
1361  template <class TYPE>
1362  StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1363  const std::string& doc = "" )
1364  {
1365  return setProperty( component, name, &value, doc );
1366  }
1367  // ========================================================================
1368  } // end of namespace Gaudi::Utils
1369 } // end of namespace Gaudi
1370 // ============================================================================
1371 // The END
1372 // ============================================================================
1373 #endif // GAUDIKERNEL_PROPERTY_H
1374 // ============================================================================
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition: Property.h:728
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:1123
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition: Property.h:680
Details::Property::NullVerifier VerifierType
Definition: Property.h:320
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition: Property.h:718
std::function< void(PropertyBase &)> m_readCallBack
Definition: Property.h:265
std::string toString(const TYPE &v)
Definition: Property.h:155
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition: Property.h:685
T empty(T...args)
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:631
GaudiHandleProperty * clone() const override
clones the current property
Definition: Property.h:790
bool setValue(const ValueType &v)
Definition: Property.h:464
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:315
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:256
void useUpdateHandler(const PropertyBase &) const
Definition: Property.h:257
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition: Property.h:702
Gaudi::Property< TYPE > SimpleProperty
Definition: Property.h:653
Gaudi::Property< long long & > LongLongPropertyRef
Definition: Property.h:688
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:75
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition: Property.h:703
std::ostream & operator<<(std::ostream &stream, const PropertyBase &prop)
Definition: Property.h:146
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition: Property.h:624
bool useUpdateHandler() override
manual trigger for callback for update
Definition: Property.h:399
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property< long long > LongLongProperty
Definition: Property.h:669
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:750
Implementation of property with value of concrete type.
Definition: Property.h:313
Gaudi::Property< long & > LongPropertyRef
Definition: Property.h:686
std::function< void(PropertyBase &)> m_updateCallBack
Definition: Property.h:276
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Definition: Property.h:729
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
T swap(T...args)
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
bool load(PropertyBase &destination) const override
Definition: Property.h:792
const std::string name() const
property name
Definition: Property.h:40
Property & operator=(T &&v)
Assignment from value.
Definition: Property.h:447
Gaudi::Property< float > FloatProperty
Definition: Property.h:671
Gaudi::Property< int > IntegerProperty
Definition: Property.h:665
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition: Property.h:727
void setOwnerType()
set the type of the owner class (used for documentation)
Definition: Property.h:103
void clearUpper()
Clear upper bound value.
Definition: Property.h:213
const TYPE & upper() const
Return the upper bound value.
Definition: Property.h:192
GaudiHandleArrayProperty * clone() const override
clones the current property
Definition: Property.h:830
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition: Property.h:670
Gaudi::Property< float & > FloatPropertyRef
Definition: Property.h:690
vector< std::string > StorageType
Hosted type.
Definition: Property.h:318
Gaudi::Details::PropertyBase * property(const std::string &name) const
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
Definition: Property.h:112
STL namespace.
std::string toString() const override
value -> string
Definition: Property.h:609
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition: Property.h:713
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition: Property.h:721
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Definition: Property.h:700
void setLower(const TYPE &value)
Set lower bound value.
Definition: Property.h:195
HandlersType m_handlers
Definition: Property.h:327
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition: Property.h:664
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:393
T end(T...args)
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition: Property.h:668
Gaudi::Property< std::string & > StringPropertyRef
Definition: Property.h:694
Gaudi::Details::Property::ReadUpdateHandler m_handlers
Definition: Property.h:738
StorageType m_value
Storage.
Definition: Property.h:325
Gaudi::Property< char & > CharPropertyRef
Definition: Property.h:679
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition: Property.h:716
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition: Property.h:711
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition: Property.h:707
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition: Property.h:710
bool operator<(const T &other) const
"less" comparison
Definition: Property.h:433
void setOwnerType(const std::type_info &ownerType)
set the type of the owner class (used for documentation)
Definition: Property.h:99
virtual std::string toString() const =0
value -> string
Gaudi::Property< std::vector< short > > ShortArrayProperty
Definition: Property.h:701
Gaudi::Details::PropertyBase Property
backward compatibility hack for old Property base class
Definition: PropertyFwd.h:28
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Definition: Property.h:725
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition: Property.h:704
PropertyBase(const std::type_info &type, std::string name="", std::string doc="")
constructor from the property name and the type
Definition: Property.h:119
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:381
Property()
Construct an anonymous property with default constructed value.
Definition: Property.h:367
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:47
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:736
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
Property & operator+=(const T &other)
Definition: Property.h:568
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition: Property.h:705
typename std::remove_reference< StorageType >::type ValueType
Definition: Property.h:319
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition: Property.h:724
void operator()(PropertyBase &p) const
Definition: Property.h:247
void operator()(const TYPE &value) const
Definition: Property.h:178
Gaudi::Property< signed char > SignedCharProperty
Definition: Property.h:661
Gaudi::Property< char > CharProperty
Definition: Property.h:660
int N
Definition: IOTest.py:90
Property & operator-=(const T &other)
Definition: Property.h:574
const VerifierType & verifier() const
Accessor to verifier.
Definition: Property.h:456
Gaudi::Property< int & > IntegerPropertyRef
Definition: Property.h:684
GaudiHandleBase * m_pValue
Pointer to the real property.
Definition: Property.h:813
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition: Property.h:687
const std::type_info * ownerType() const
get the type of the owner class (used for documentation)
Definition: Property.h:109
boost::string_ref m_name
property name
Definition: Property.h:137
Property & operator++()
Definition: Property.h:546
T what(T...args)
PropertyBase(std::string name, const std::type_info &type)
constructor from the property name and the type
Definition: Property.h:124
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
void setBounds(const TYPE &lower, const TYPE &upper)
Set both bounds (lower and upper) at the same time.
Definition: Property.h:220
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition: Property.h:730
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Property(std::string name, T &&value, std::string doc="")
the constructor with property name, value and documentation.
Definition: Property.h:339
Definition of the basic interface.
Definition: IInterface.h:234
const std::type_info * m_typeinfo
property type
Definition: Property.h:141
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:765
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition: Property.h:666
TYPE fromString(const std::string &s)
Definition: Property.h:156
const TYPE & lower() const
Return the lower bound value.
Definition: Property.h:190
T erase(T...args)
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition: Property.h:698
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
const GaudiHandleBase & value() const
Definition: Property.h:802
Gaudi::Property< bool > BooleanProperty
Definition: Property.h:659
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition: Property.h:708
VerifierType & verifier()
Accessor to verifier.
Definition: Property.h:458
const GaudiHandleArrayBase & value() const
Definition: Property.h:842
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:49
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:52
PropertyBase & declareUpdateHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:81
T clear(T...args)
bool hasLower() const
Return if it has a lower bound.
Definition: Property.h:186
Gaudi::Property< double > DoubleProperty
Definition: Property.h:672
Converter base class.
Definition: Converter.h:24
STL class.
void setName(std::string value)
set the new value for the property name
Definition: Property.h:90
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Definition: Property.h:722
T move(T...args)
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:762
bool assign(const PropertyBase &source) override
Definition: Property.h:834
Property & operator--()
Definition: Property.h:557
void operator()(const TYPE &) const
Definition: Property.h:172
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition: Property.h:726
Gaudi::Property< double & > DoublePropertyRef
Definition: Property.h:691
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:262
bool operator==(const T &other) const
equality comparison
Definition: Property.h:419
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition: Property.h:719
void useReadHandler(const PropertyBase &p) const
Definition: Property.h:266
Property(OWNER *owner, std::string name, T &&value=ValueType{}, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:349
bool hasUpper() const
Return if it has a lower bound.
Definition: Property.h:188
T find(T...args)
bool load(Details::PropertyBase &dest) const override
set value to another property
Definition: Property.h:596
T size(T...args)
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:364
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:288
Gaudi::Property< long double & > LongDoublePropertyRef
Definition: Property.h:692
ValueType & value()
Definition: Property.h:463
STL class.
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:744
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition: Property.h:699
Gaudi::Property< std::string > StringProperty
Definition: Property.h:675
T begin(T...args)
STL class.
void setUpdateHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:287
Gaudi::Property< long double > LongDoubleProperty
Definition: Property.h:673
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition: Property.h:824
SwapCall(callback_t &input)
Definition: Property.h:245
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition: Property.h:853
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
Gaudi::Property< short > ShortProperty
Definition: Property.h:663
std::string type() const
property type
Definition: Property.h:46
std::string documentation() const
property documentation
Definition: Property.h:42
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Definition: Property.h:706
Details::PropertyBase * clone() const override
clones the current property
Definition: Property.h:474
Gaudi::Property< TYPE & > SimplePropertyRef
Definition: Property.h:656
string s
Definition: gaudirun.py:245
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition: Property.h:689
void clearBounds()
Clear both bounds (lower and upper) at the same time.
Definition: Property.h:227
void setReadHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:272
GAUDI_API const Gaudi::Details::PropertyBase * getProperty(const std::vector< const Gaudi::Details::PropertyBase * > *p, const std::string &name)
get the property by name from the list of the properties
Definition: Property.cpp:320
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:759
StatusCode setProperty(IInterface *component, const std::string &name, const Gaudi::Property< TYPE > &value, const std::string &doc="")
simple function to set the property of the given object from another property
Definition: Property.h:1362
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:273
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition: Property.h:732
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition: Property.h:583
bool assign(const PropertyBase &source) override
Definition: Property.h:794
bool operator!=(const T &other) const
inequality comparison
Definition: Property.h:426
Gaudi::Property< long > LongProperty
Definition: Property.h:667
void setUpdateHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:258
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition: Property.h:717
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:462
void clearLower()
Clear lower bound value.
Definition: Property.h:207
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:94
implementation of various functions for streaming.
Property(T &&v)
Construct an anonymous property from a value.
Definition: Property.h:360
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:757
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition: Property.h:683
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition: Property.h:709
ValueType operator++(int)
Definition: Property.h:552
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
helper to disable a while triggering it, to avoid infinite recursion
Definition: Property.h:242
boost::string_ref m_documentation
property doc string
Definition: Property.h:139
bool load(PropertyBase &destination) const override
Definition: Property.h:832
#define GAUDI_API
Definition: Kernel.h:107
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition: Property.h:784
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition: Property.h:720
STL class.
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:375
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition: Property.h:662
VerifierType m_verifier
Definition: Property.h:326
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:388
Gaudi::Property< short & > ShortPropertyRef
Definition: Property.h:682
void setUpper(const TYPE &value)
Set upper bound value.
Definition: Property.h:201
void setReadHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:252
Details::Property::UpdateHandler HandlersType
Definition: Property.h:321
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition: Property.h:681
ValueType operator--(int)
Definition: Property.h:563
decltype(std::declval< TP >()+std::declval< T >()) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition: Property.h:638
void useReadHandler(const PropertyBase &) const
Definition: Property.h:251
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition: Property.h:697
const std::type_info * type_info() const
property type-info
Definition: Property.h:44
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition: Property.h:723
StatusCode fromString(const std::string &source) override
string -> value
Definition: Property.h:602
void toStream(std::ostream &out) const override
value -> stream
Definition: Property.h:615
Gaudi::Property< bool & > BooleanPropertyRef
Definition: Property.h:678
void useUpdateHandler(PropertyBase &p)
Definition: Property.h:277