Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  using Gaudi::Parsers::parse;
160  if ( !parse( tmp, s ).isSuccess() ) {
161  throw std::invalid_argument( "cannot parse '" + s + "' to " + System::typeinfoName( typeid( TYPE ) ) );
162  }
163  return tmp;
164  }
165  };
166  template <>
168  {
169  return v;
170  }
171  struct NullVerifier {
172  template <class TYPE>
173  void operator()( const TYPE& ) const
174  {
175  }
176  };
177  template <class TYPE>
179  void operator()( const TYPE& value ) const
180  {
181  // throw the exception if the limit is defined and value is outside
182  if ( ( m_hasLowerBound && ( value < m_lowerBound ) ) || ( m_hasUpperBound && ( m_upperBound < value ) ) )
183  throw std::out_of_range( "value " + Gaudi::Utils::toString( value ) + " outside range" );
184  }
185 
187  bool hasLower() const { return m_hasLowerBound; }
189  bool hasUpper() const { return m_hasUpperBound; }
191  const TYPE& lower() const { return m_lowerBound; }
193  const TYPE& upper() const { return m_upperBound; }
194 
196  void setLower( const TYPE& value )
197  {
198  m_hasLowerBound = true;
199  m_lowerBound = value;
200  }
202  void setUpper( const TYPE& value )
203  {
204  m_hasUpperBound = true;
205  m_upperBound = value;
206  }
208  void clearLower()
209  {
210  m_hasLowerBound = false;
211  m_lowerBound = TYPE();
212  }
214  void clearUpper()
215  {
216  m_hasUpperBound = false;
217  m_upperBound = TYPE();
218  }
219 
221  void setBounds( const TYPE& lower, const TYPE& upper )
222  {
223  setLower( lower );
224  setUpper( upper );
225  }
226 
228  void clearBounds()
229  {
230  clearLower();
231  clearUpper();
232  }
233 
234  private:
236  bool m_hasLowerBound{false};
237  bool m_hasUpperBound{false};
238  TYPE m_lowerBound{};
239  TYPE m_upperBound{};
240  };
241 
243  struct SwapCall {
245  callback_t tmp, &orig;
246  SwapCall( callback_t& input ) : orig( input ) { tmp.swap( orig ); }
247  ~SwapCall() { orig.swap( tmp ); }
248  void operator()( PropertyBase& p ) const { tmp( p ); }
249  };
250 
251  struct NoHandler {
252  void useReadHandler( const PropertyBase& ) const {}
254  {
255  throw std::logic_error( "setReadHandler not implemented for this class" );
256  }
258  void useUpdateHandler( const PropertyBase& ) const {}
260  {
261  throw std::logic_error( "setUpdateHandler not implemented for this class" );
262  }
264  };
267  void useReadHandler( const PropertyBase& p ) const
268  {
269  if ( m_readCallBack ) {
270  SwapCall{m_readCallBack}( const_cast<PropertyBase&>( p ) );
271  }
272  }
273  void setReadHandler( std::function<void( PropertyBase& )> fun ) { m_readCallBack = std::move( fun ); }
274  std::function<void( PropertyBase& )> getReadHandler() const { return m_readCallBack; }
275  };
279  {
280  if ( m_updateCallBack ) {
281  try {
282  SwapCall{m_updateCallBack}( p );
283  } catch ( const std::exception& x ) {
284  throw std::invalid_argument( "failure in update handler of '" + p.name() + "': " + x.what() );
285  }
286  }
287  }
288  void setUpdateHandler( std::function<void( PropertyBase& )> fun ) { m_updateCallBack = std::move( fun ); }
289  std::function<void( PropertyBase& )> getUpdateHandler() const { return m_updateCallBack; }
290  };
292  using ReadHandler::useReadHandler;
293  using ReadHandler::setReadHandler;
294  using ReadHandler::getReadHandler;
295  using UpdateHandler::useUpdateHandler;
296  using UpdateHandler::setUpdateHandler;
297  using UpdateHandler::getUpdateHandler;
298  };
299  }
300 
301  } // namespace Details
302 
303  // ============================================================================
311  // ============================================================================
312  template <class TYPE, class VERIFIER = Details::Property::NullVerifier,
313  class HANDLERS = Details::Property::UpdateHandler>
315  {
316  public:
317  // ==========================================================================
319  using StorageType = TYPE;
321  using VerifierType = VERIFIER;
322  using HandlersType = HANDLERS;
323 
324  private:
331  template <class T>
333  template <class T>
336  public:
337  // ==========================================================================
339  template <class T = ValueType>
340  inline Property( std::string name, T&& value, std::string doc = "" )
341  : Details::PropertyBase( typeid( ValueType ), std::move( name ), std::move( doc ) )
342  , m_value( std::forward<T>( value ) )
343  {
344  m_verifier( m_value );
345  }
348  template <class OWNER, class T = ValueType,
351  inline Property( OWNER* owner, std::string name )
352  : Property( std::move( name ), ValueType{}, "" )
353  {
354  owner->declareProperty( *this );
355  setOwnerType<OWNER>();
356  }
357 
360  template <class OWNER, class T = ValueType,
362  inline Property( OWNER* owner, std::string name, T&& value, std::string doc = "" )
363  : Property( std::move( name ), std::forward<T>( value ), std::move( doc ) )
364  {
365  owner->declareProperty( *this );
366  setOwnerType<OWNER>();
367  }
368 
373  Property( T&& v ) : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value( std::forward<T>( v ) )
374  {
375  }
376 
379  template <typename T = StorageType, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
380  Property() : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value()
381  {
382  }
383 
386 
389  {
390  m_handlers.setReadHandler( std::move( fun ) );
391  return *this;
392  }
395  {
396  m_handlers.setUpdateHandler( std::move( fun ) );
397  return *this;
398  }
399 
402  {
403  return m_handlers.getReadHandler();
404  }
407  {
408  return m_handlers.getUpdateHandler();
409  }
410 
412  bool useUpdateHandler() override
413  {
414  m_handlers.useUpdateHandler( *this );
415  return true;
416  }
417 
419  operator const ValueType&() const
420  {
421  m_handlers.useReadHandler( *this );
422  return m_value;
423  }
424  // /// Automatic conversion to value (reference).
425  // operator ValueType& () {
426  // useReadHandler();
427  // return m_value;
428  // }
429 
431  template <class T>
432  inline bool operator==( const T& other ) const
433  {
434  return m_value == other;
435  }
436 
438  template <class T>
439  inline bool operator!=( const T& other ) const
440  {
441  return m_value != other;
442  }
443 
445  template <class T>
446  inline bool operator<( const T& other ) const
447  {
448  return m_value < other;
449  }
450 
452  template <class T>
453  decltype( std::declval<ValueType>() + std::declval<T>() ) operator+( const T& other ) const
454  {
455  return m_value + other;
456  }
457 
459  template <class T = ValueType>
460  Property& operator=( T&& v )
461  {
462  m_verifier( v );
463  m_value = std::forward<T>( v );
464  m_handlers.useUpdateHandler( *this );
465  return *this;
466  }
467 
469  const VerifierType& verifier() const { return m_verifier; }
471  VerifierType& verifier() { return m_verifier; }
472 
475  const ValueType& value() const { return *this; }
476  ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
477  bool setValue( const ValueType& v )
478  {
479  *this = v;
480  return true;
481  }
482  bool set( const ValueType& v )
483  {
484  *this = v;
485  return true;
486  }
487  Details::PropertyBase* clone() const override { return new Property( *this ); }
489 
493  template <class T = const ValueType>
494  inline decltype( std::declval<T>().size() ) size() const
495  {
496  return value().size();
497  }
498  template <class T = const ValueType>
499  inline decltype( std::declval<T>().length() ) length() const
500  {
501  return value().length();
502  }
503  template <class T = const ValueType>
504  inline decltype( std::declval<T>().empty() ) empty() const
505  {
506  return value().empty();
507  }
508  template <class T = ValueType>
509  inline decltype( std::declval<T>().clear() ) clear()
510  {
511  value().clear();
512  }
513  template <class T = const ValueType>
514  inline decltype( std::declval<T>().begin() ) begin() const
515  {
516  return value().begin();
517  }
518  template <class T = const ValueType>
519  inline decltype( std::declval<T>().end() ) end() const
520  {
521  return value().end();
522  }
523  template <class T = ValueType>
524  inline decltype( std::declval<T>().begin() ) begin()
525  {
526  return value().begin();
527  }
528  template <class T = ValueType>
529  inline decltype( std::declval<T>().end() ) end()
530  {
531  return value().end();
532  }
533  template <class ARG, class T = const ValueType>
534  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg ) const
535  {
536  return value()[arg];
537  }
538  template <class ARG, class T = ValueType>
539  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
540  {
541  return value()[arg];
542  }
543  template <class T = const ValueType>
544  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key ) const
545  {
546  return value().find( key );
547  }
548  template <class T = ValueType>
549  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key )
550  {
551  return value().find( key );
552  }
553  template <class ARG, class T = ValueType>
554  inline decltype( std::declval<T>().erase( ARG{} ) ) erase( ARG arg )
555  {
556  return value().erase( arg );
557  }
558  template <class = ValueType>
560  {
561  ++value();
562  return *this;
563  }
564  template <class = ValueType>
565  inline ValueType operator++( int )
566  {
567  return m_value++;
568  }
569  template <class = ValueType>
571  {
572  --value();
573  return *this;
574  }
575  template <class = ValueType>
576  inline ValueType operator--( int )
577  {
578  return m_value--;
579  }
580  template <class T = ValueType>
581  inline Property& operator+=( const T& other )
582  {
583  m_value += other;
584  return *this;
585  }
586  template <class T = ValueType>
587  inline Property& operator-=( const T& other )
588  {
589  m_value -= other;
590  return *this;
591  }
593  // ==========================================================================
594  public:
596  bool assign( const Details::PropertyBase& source ) override
597  {
598  // Check if the property of is of "the same" type, except for strings
599  const Property* p =
600  ( std::is_same<ValueType, std::string>::value ) ? nullptr : dynamic_cast<const Property*>( &source );
601  if ( p ) {
602  *this = p->value();
603  } else {
604  this->fromString( source.toString() ).ignore();
605  }
606  return true;
607  }
609  bool load( Details::PropertyBase& dest ) const override
610  {
611  // delegate to the 'opposite' method
612  return dest.assign( *this );
613  }
615  StatusCode fromString( const std::string& source ) override
616  {
617  using Converter = Details::Property::StringConverter<ValueType>;
618  *this = Converter().fromString( source );
619  return StatusCode::SUCCESS;
620  }
622  std::string toString() const override
623  {
624  using Converter = Details::Property::StringConverter<ValueType>;
625  return Converter().toString( *this );
626  }
628  void toStream( std::ostream& out ) const override
629  {
630  m_handlers.useReadHandler( *this );
631  using Utils::toStream;
632  toStream( m_value, out );
633  }
634  };
635 
637  template <class T, class TP, class V, class H>
638  bool operator==( const T& v, const Property<TP, V, H>& p )
639  {
640  return p == v;
641  }
642 
644  template <class T, class TP, class V, class H>
645  bool operator!=( const T& v, const Property<TP, V, H>& p )
646  {
647  return p != v;
648  }
649 
651  template <class T, class TP, class V, class H>
652  decltype( std::declval<TP>() + std::declval<T>() ) operator+( const T& v, const Property<TP, V, H>& p )
653  {
654  return v + p.value();
655  }
656 
657  template <class TYPE, class HANDLERS = Details::Property::UpdateHandler>
659 
660  template <class TYPE>
663 
664 } // namespace Gaudi
665 
666 template <class TYPE>
668 
669 template <class TYPE>
671 
672 // Typedef Properties for built-in types
688 
690 
691 // Typedef PropertyRefs for built-in types
707 
709 
710 // Typedef "Arrays" of Properties for built-in types
726 
728 
729 // Typedef "Arrays" of PropertyRefs for built-in types
745 
747 
750 template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
752 {
753  Handler m_handlers;
754 
755 public:
757 
759  PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override
760  {
761  m_handlers.setReadHandler( std::move( fun ) );
762  return *this;
763  }
765  PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override
766  {
767  m_handlers.setUpdateHandler( std::move( fun ) );
768  return *this;
769  }
770 
772  const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
774  const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
775 
777  void useReadHandler() const { m_handlers.useReadHandler( *this ); }
778 
780  bool useUpdateHandler() override
781  {
782  m_handlers.useUpdateHandler( *this );
783  return true;
784  }
785 };
786 
787 // forward-declaration is sufficient here
788 class GaudiHandleBase;
789 
790 // implementation in header file only where the GaudiHandleBase class
791 // definition is not needed. The rest goes into the .cpp file.
792 // The goal is to decouple the header files, to avoid that the whole
793 // world depends on GaudiHandle.h
795 {
796 public:
798 
800  {
801  setValue( value );
802  return *this;
803  }
804 
805  GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
806 
807  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
808 
809  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
810 
811  std::string toString() const override;
812 
813  void toStream( std::ostream& out ) const override;
814 
815  StatusCode fromString( const std::string& s ) override;
816 
817  const GaudiHandleBase& value() const
818  {
819  useReadHandler();
820  return *m_pValue;
821  }
822 
823  bool setValue( const GaudiHandleBase& value );
824 
825 private:
829 };
830 
831 // forward-declaration is sufficient here
833 
835 {
836 public:
838 
840  {
841  setValue( value );
842  return *this;
843  }
844 
845  GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
846 
847  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
848 
849  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
850 
851  std::string toString() const override;
852 
853  void toStream( std::ostream& out ) const override;
854 
855  StatusCode fromString( const std::string& s ) override;
856 
858  {
859  useReadHandler();
860  return *m_pValue;
861  }
862 
863  bool setValue( const GaudiHandleArrayBase& value );
864 
865 private:
869 };
870 
871 namespace Gaudi
872 {
873  namespace Utils
874  {
875  // ========================================================================
893  GAUDI_API bool hasProperty( const IProperty* p, const std::string& name );
894  // ========================================================================
912  GAUDI_API bool hasProperty( const IInterface* p, const std::string& name );
913  // ========================================================================
932  // ========================================================================
951  // ========================================================================
975  // ========================================================================
1000  // ========================================================================
1024  template <class TYPE>
1025  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
1026  // ========================================================================
1049  template <class TYPE>
1050  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value )
1051  {
1052  return setProperty( component, name, value, std::string() );
1053  }
1054  // ========================================================================
1068  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
1069  const std::string& doc = "" );
1070  // ========================================================================
1084  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
1085  const std::string& doc = "" );
1086  // ========================================================================
1100  template <unsigned N>
1101  StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
1102  const std::string& doc = "" )
1103  {
1104  return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
1105  }
1106  // ========================================================================
1137  template <class TYPE>
1138  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc )
1139  {
1140  return component && hasProperty( component, name )
1141  ? Gaudi::Utils::setProperty( component, name, Gaudi::Utils::toString( value ), doc )
1143  }
1144  // ========================================================================
1166  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1167  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1168  // ========================================================================
1190  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1191  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1192  // ========================================================================
1215  template <class TYPE>
1216  StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1217  const std::string& doc = "" )
1218  {
1219  return setProperty( component, name, &value, doc );
1220  }
1221  // ========================================================================
1242  template <class TYPE>
1243  StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1244  const std::string& doc = "" )
1245  {
1246  if ( !component ) {
1247  return StatusCode::FAILURE;
1248  }
1249  auto property = SmartIF<IProperty>{component};
1250  return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
1251  }
1252  // ========================================================================
1265  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1266  const std::string& doc = "" );
1267  // ========================================================================
1280  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1281  const std::string& doc = "" );
1282  // ========================================================================
1296  template <unsigned N>
1297  StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1298  const std::string& doc = "" )
1299  {
1300  if ( 0 == component ) {
1301  return StatusCode::FAILURE;
1302  }
1303  return setProperty( component, name, std::string{value, value + N}, doc );
1304  }
1305  // ========================================================================
1327  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1328  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1329  // ========================================================================
1351  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1352  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1353  // ========================================================================
1376  template <class TYPE>
1377  StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1378  const std::string& doc = "" )
1379  {
1380  return setProperty( component, name, &value, doc );
1381  }
1382  // ========================================================================
1383  } // end of namespace Gaudi::Utils
1384 } // end of namespace Gaudi
1385 // ============================================================================
1386 // The END
1387 // ============================================================================
1388 #endif // GAUDIKERNEL_PROPERTY_H
1389 // ============================================================================
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition: Property.h:742
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:1138
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition: Property.h:694
Details::Property::NullVerifier VerifierType
Definition: Property.h:321
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition: Property.h:732
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:351
std::function< void(PropertyBase &)> m_readCallBack
Definition: Property.h:266
std::string toString(const TYPE &v)
Definition: Property.h:155
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition: Property.h:699
T empty(T...args)
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:645
GaudiHandleProperty * clone() const override
clones the current property
Definition: Property.h:805
bool setValue(const ValueType &v)
Definition: Property.h:477
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:257
void useUpdateHandler(const PropertyBase &) const
Definition: Property.h:258
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition: Property.h:716
Gaudi::Property< TYPE > SimpleProperty
Definition: Property.h:667
Gaudi::Property< long long & > LongLongPropertyRef
Definition: Property.h:702
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:75
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition: Property.h:717
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:638
bool useUpdateHandler() override
manual trigger for callback for update
Definition: Property.h:412
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property< long long > LongLongProperty
Definition: Property.h:683
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:772
Implementation of property with value of concrete type.
Definition: Property.h:314
Gaudi::Property< long & > LongPropertyRef
Definition: Property.h:700
std::function< void(PropertyBase &)> m_updateCallBack
Definition: Property.h:277
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:743
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:807
const std::string name() const
property name
Definition: Property.h:40
Property & operator=(T &&v)
Assignment from value.
Definition: Property.h:460
Gaudi::Property< float > FloatProperty
Definition: Property.h:685
Gaudi::Property< int > IntegerProperty
Definition: Property.h:679
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition: Property.h:741
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:214
const TYPE & upper() const
Return the upper bound value.
Definition: Property.h:193
GaudiHandleArrayProperty * clone() const override
clones the current property
Definition: Property.h:845
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:684
Gaudi::Property< float & > FloatPropertyRef
Definition: Property.h:704
vector< std::string > StorageType
Hosted type.
Definition: Property.h:319
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:622
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition: Property.h:727
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition: Property.h:735
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:714
void setLower(const TYPE &value)
Set lower bound value.
Definition: Property.h:196
HandlersType m_handlers
Definition: Property.h:328
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition: Property.h:678
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:406
T end(T...args)
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition: Property.h:682
Gaudi::Property< std::string & > StringPropertyRef
Definition: Property.h:708
StorageType m_value
Storage.
Definition: Property.h:326
Gaudi::Property< char & > CharPropertyRef
Definition: Property.h:693
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition: Property.h:730
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition: Property.h:725
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition: Property.h:721
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition: Property.h:724
bool operator<(const T &other) const
"less" comparison
Definition: Property.h:446
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:715
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:739
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition: Property.h:718
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:394
Property()
Construct an anonymous property with default constructed value.
Definition: Property.h:380
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:751
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
Property & operator+=(const T &other)
Definition: Property.h:581
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition: Property.h:719
typename std::remove_reference< StorageType >::type ValueType
Definition: Property.h:320
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition: Property.h:738
void operator()(PropertyBase &p) const
Definition: Property.h:248
void operator()(const TYPE &value) const
Definition: Property.h:179
Gaudi::Property< signed char > SignedCharProperty
Definition: Property.h:675
Gaudi::Property< char > CharProperty
Definition: Property.h:674
int N
Definition: IOTest.py:90
Property & operator-=(const T &other)
Definition: Property.h:587
const VerifierType & verifier() const
Accessor to verifier.
Definition: Property.h:469
Gaudi::Property< int & > IntegerPropertyRef
Definition: Property.h:698
GaudiHandleBase * m_pValue
Pointer to the real property.
Definition: Property.h:828
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition: Property.h:701
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:559
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:221
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition: Property.h:744
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:340
Definition of the basic interface.
Definition: IInterface.h:234
const std::type_info * m_typeinfo
property type
Definition: Property.h:141
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition: Property.h:680
TYPE fromString(const std::string &s)
Definition: Property.h:156
const TYPE & lower() const
Return the lower bound value.
Definition: Property.h:191
T erase(T...args)
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition: Property.h:712
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
const GaudiHandleBase & value() const
Definition: Property.h:817
Gaudi::Property< bool > BooleanProperty
Definition: Property.h:673
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:765
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition: Property.h:722
VerifierType & verifier()
Accessor to verifier.
Definition: Property.h:471
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:759
const GaudiHandleArrayBase & value() const
Definition: Property.h:857
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
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:187
Gaudi::Property< double > DoubleProperty
Definition: Property.h:686
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:736
T move(T...args)
bool assign(const PropertyBase &source) override
Definition: Property.h:849
Property & operator--()
Definition: Property.h:570
void operator()(const TYPE &) const
Definition: Property.h:173
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition: Property.h:740
Gaudi::Property< double & > DoublePropertyRef
Definition: Property.h:705
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:263
bool operator==(const T &other) const
equality comparison
Definition: Property.h:432
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition: Property.h:733
void useReadHandler(const PropertyBase &p) const
Definition: Property.h:267
bool hasUpper() const
Return if it has a lower bound.
Definition: Property.h:189
T find(T...args)
bool load(Details::PropertyBase &dest) const override
set value to another property
Definition: Property.h:609
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:289
Gaudi::Property< long double & > LongDoublePropertyRef
Definition: Property.h:706
ValueType & value()
Definition: Property.h:476
STL class.
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:777
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition: Property.h:713
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:780
Gaudi::Property< std::string > StringProperty
Definition: Property.h:689
T begin(T...args)
STL class.
void setUpdateHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:288
Gaudi::Property< long double > LongDoubleProperty
Definition: Property.h:687
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition: Property.h:839
SwapCall(callback_t &input)
Definition: Property.h:246
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition: Property.h:868
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
Gaudi::Property< short > ShortProperty
Definition: Property.h:677
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:720
Details::PropertyBase * clone() const override
clones the current property
Definition: Property.h:487
Gaudi::Property< TYPE & > SimplePropertyRef
Definition: Property.h:670
string s
Definition: gaudirun.py:245
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition: Property.h:703
void clearBounds()
Clear both bounds (lower and upper) at the same time.
Definition: Property.h:228
void setReadHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:273
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
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:1377
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:274
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition: Property.h:746
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition: Property.h:596
bool assign(const PropertyBase &source) override
Definition: Property.h:809
bool operator!=(const T &other) const
inequality comparison
Definition: Property.h:439
Gaudi::Property< long > LongProperty
Definition: Property.h:681
void setUpdateHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:259
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition: Property.h:731
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:475
void clearLower()
Clear lower bound value.
Definition: Property.h:208
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:373
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition: Property.h:697
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition: Property.h:723
ValueType operator++(int)
Definition: Property.h:565
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:243
boost::string_ref m_documentation
property doc string
Definition: Property.h:139
bool load(PropertyBase &destination) const override
Definition: Property.h:847
#define GAUDI_API
Definition: Kernel.h:107
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition: Property.h:799
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition: Property.h:734
STL class.
Property(OWNER *owner, std::string name, T &&value, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:362
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:774
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:388
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition: Property.h:676
VerifierType m_verifier
Definition: Property.h:327
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:401
Gaudi::Property< short & > ShortPropertyRef
Definition: Property.h:696
void setUpper(const TYPE &value)
Set upper bound value.
Definition: Property.h:202
void setReadHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:253
Details::Property::UpdateHandler HandlersType
Definition: Property.h:322
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition: Property.h:695
ValueType operator--(int)
Definition: Property.h:576
decltype(std::declval< TP >()+std::declval< T >()) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition: Property.h:652
void useReadHandler(const PropertyBase &) const
Definition: Property.h:252
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition: Property.h:711
const std::type_info * type_info() const
property type-info
Definition: Property.h:44
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition: Property.h:737
StatusCode fromString(const std::string &source) override
string -> value
Definition: Property.h:615
void toStream(std::ostream &out) const override
value -> stream
Definition: Property.h:628
Gaudi::Property< bool & > BooleanPropertyRef
Definition: Property.h:692
void useUpdateHandler(PropertyBase &p)
Definition: Property.h:278