The Gaudi Framework  v28r3 (cc1cf868)
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(); }
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 )
156  {
158  return toString( v );
159  }
160  inline TYPE fromString( const std::string& s )
161  {
162  TYPE tmp;
163  using Gaudi::Parsers::parse;
164  if ( !parse( tmp, s ).isSuccess() ) {
165  throw std::invalid_argument( "cannot parse '" + s + "' to " + System::typeinfoName( typeid( TYPE ) ) );
166  }
167  return tmp;
168  }
169  };
170  template <>
172  {
173  return v;
174  }
175  struct NullVerifier {
176  template <class TYPE>
177  void operator()( const TYPE& ) const
178  {
179  }
180  };
181  template <class TYPE>
183  void operator()( const TYPE& value ) const
184  {
186  // throw the exception if the limit is defined and value is outside
187  if ( ( m_hasLowerBound && ( value < m_lowerBound ) ) || ( m_hasUpperBound && ( m_upperBound < value ) ) )
188  throw std::out_of_range( "value " + toString( value ) + " outside range" );
189  }
190 
192  bool hasLower() const { return m_hasLowerBound; }
194  bool hasUpper() const { return m_hasUpperBound; }
196  const TYPE& lower() const { return m_lowerBound; }
198  const TYPE& upper() const { return m_upperBound; }
199 
201  void setLower( const TYPE& value )
202  {
203  m_hasLowerBound = true;
204  m_lowerBound = value;
205  }
207  void setUpper( const TYPE& value )
208  {
209  m_hasUpperBound = true;
210  m_upperBound = value;
211  }
213  void clearLower()
214  {
215  m_hasLowerBound = false;
216  m_lowerBound = TYPE();
217  }
219  void clearUpper()
220  {
221  m_hasUpperBound = false;
222  m_upperBound = TYPE();
223  }
224 
226  void setBounds( const TYPE& lower, const TYPE& upper )
227  {
228  setLower( lower );
229  setUpper( upper );
230  }
231 
233  void clearBounds()
234  {
235  clearLower();
236  clearUpper();
237  }
238 
239  private:
241  bool m_hasLowerBound{false};
242  bool m_hasUpperBound{false};
243  TYPE m_lowerBound{};
244  TYPE m_upperBound{};
245  };
246 
248  struct SwapCall {
250  callback_t tmp, &orig;
251  SwapCall( callback_t& input ) : orig( input ) { tmp.swap( orig ); }
252  ~SwapCall() { orig.swap( tmp ); }
253  void operator()( PropertyBase& p ) const { tmp( p ); }
254  };
255 
256  struct NoHandler {
257  void useReadHandler( const PropertyBase& ) const {}
259  {
260  throw std::logic_error( "setReadHandler not implemented for this class" );
261  }
263  void useUpdateHandler( const PropertyBase& ) const {}
265  {
266  throw std::logic_error( "setUpdateHandler not implemented for this class" );
267  }
269  };
272  void useReadHandler( const PropertyBase& p ) const
273  {
274  if ( m_readCallBack ) {
275  SwapCall{m_readCallBack}( const_cast<PropertyBase&>( p ) );
276  }
277  }
278  void setReadHandler( std::function<void( PropertyBase& )> fun ) { m_readCallBack = std::move( fun ); }
279  std::function<void( PropertyBase& )> getReadHandler() const { return m_readCallBack; }
280  };
284  {
285  if ( m_updateCallBack ) {
286  try {
287  SwapCall{m_updateCallBack}( p );
288  } catch ( const std::exception& x ) {
289  throw std::invalid_argument( "failure in update handler of '" + p.name() + "': " + x.what() );
290  }
291  }
292  }
293  void setUpdateHandler( std::function<void( PropertyBase& )> fun ) { m_updateCallBack = std::move( fun ); }
294  std::function<void( PropertyBase& )> getUpdateHandler() const { return m_updateCallBack; }
295  };
297  using ReadHandler::useReadHandler;
298  using ReadHandler::setReadHandler;
299  using ReadHandler::getReadHandler;
300  using UpdateHandler::useUpdateHandler;
301  using UpdateHandler::setUpdateHandler;
302  using UpdateHandler::getUpdateHandler;
303  };
304  }
305 
306  } // namespace Details
307 
308  // ============================================================================
316  // ============================================================================
317  template <class TYPE, class VERIFIER = Details::Property::NullVerifier,
318  class HANDLERS = Details::Property::UpdateHandler>
320  {
321  public:
322  // ==========================================================================
324  using StorageType = TYPE;
326  using VerifierType = VERIFIER;
327  using HandlersType = HANDLERS;
328 
329  private:
336  template <class T>
338  template <class T>
341  public:
342  // ==========================================================================
344  template <class T = StorageType>
345  inline Property( std::string name, T&& value, std::string doc = "" )
346  : Details::PropertyBase( typeid( ValueType ), std::move( name ), std::move( doc ) )
347  , m_value( std::forward<T>( value ) )
348  {
349  m_verifier( m_value );
350  }
353  template <class OWNER, class T = ValueType,
356  inline Property( OWNER* owner, std::string name )
357  : Property( std::move( name ), ValueType{}, "" )
358  {
359  owner->declareProperty( *this );
360  setOwnerType<OWNER>();
361  }
362 
365  template <class OWNER, class T = StorageType,
367  inline Property( OWNER* owner, std::string name, T&& value, std::string doc = "" )
368  : Property( std::move( name ), std::forward<T>( value ), std::move( doc ) )
369  {
370  owner->declareProperty( *this );
371  setOwnerType<OWNER>();
372  }
373 
378  Property( T&& v ) : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value( std::forward<T>( v ) )
379  {
380  }
381 
384  template <typename T = StorageType, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
385  Property() : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value()
386  {
387  }
388 
391 
394  {
395  m_handlers.setReadHandler( std::move( fun ) );
396  return *this;
397  }
400  {
401  m_handlers.setUpdateHandler( std::move( fun ) );
402  return *this;
403  }
404 
407  {
408  return m_handlers.getReadHandler();
409  }
412  {
413  return m_handlers.getUpdateHandler();
414  }
415 
417  bool useUpdateHandler() override
418  {
419  m_handlers.useUpdateHandler( *this );
420  return true;
421  }
422 
424  operator const ValueType&() const
425  {
426  m_handlers.useReadHandler( *this );
427  return m_value;
428  }
429  // /// Automatic conversion to value (reference).
430  // operator ValueType& () {
431  // useReadHandler();
432  // return m_value;
433  // }
434 
436  template <class T>
437  inline bool operator==( const T& other ) const
438  {
439  return m_value == other;
440  }
441 
443  template <class T>
444  inline bool operator!=( const T& other ) const
445  {
446  return m_value != other;
447  }
448 
450  template <class T>
451  inline bool operator<( const T& other ) const
452  {
453  return m_value < other;
454  }
455 
457  template <class T>
458  decltype( std::declval<ValueType>() + std::declval<T>() ) operator+( const T& other ) const
459  {
460  return m_value + other;
461  }
462 
464  template <class T = ValueType>
465  Property& operator=( T&& v )
466  {
467  m_verifier( v );
468  m_value = std::forward<T>( v );
469  m_handlers.useUpdateHandler( *this );
470  return *this;
471  }
472 
474  const VerifierType& verifier() const { return m_verifier; }
476  VerifierType& verifier() { return m_verifier; }
477 
480  const ValueType& value() const { return *this; }
481  ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
482  bool setValue( const ValueType& v )
483  {
484  *this = v;
485  return true;
486  }
487  bool set( const ValueType& v )
488  {
489  *this = v;
490  return true;
491  }
492  Details::PropertyBase* clone() const override { return new Property( *this ); }
494 
498  template <class T = const ValueType>
499  inline decltype( std::declval<T>().size() ) size() const
500  {
501  return value().size();
502  }
503  template <class T = const ValueType>
504  inline decltype( std::declval<T>().length() ) length() const
505  {
506  return value().length();
507  }
508  template <class T = const ValueType>
509  inline decltype( std::declval<T>().empty() ) empty() const
510  {
511  return value().empty();
512  }
513  template <class T = ValueType>
514  inline decltype( std::declval<T>().clear() ) clear()
515  {
516  value().clear();
517  }
518  template <class T = const ValueType>
519  inline decltype( std::declval<T>().begin() ) begin() const
520  {
521  return value().begin();
522  }
523  template <class T = const ValueType>
524  inline decltype( std::declval<T>().end() ) end() const
525  {
526  return value().end();
527  }
528  template <class T = ValueType>
529  inline decltype( std::declval<T>().begin() ) begin()
530  {
531  return value().begin();
532  }
533  template <class T = ValueType>
534  inline decltype( std::declval<T>().end() ) end()
535  {
536  return value().end();
537  }
538  template <class ARG, class T = const ValueType>
539  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg ) const
540  {
541  return value()[arg];
542  }
543  template <class ARG, class T = ValueType>
544  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
545  {
546  return value()[arg];
547  }
548  template <class T = const ValueType>
549  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key ) const
550  {
551  return value().find( key );
552  }
553  template <class T = ValueType>
554  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key )
555  {
556  return value().find( key );
557  }
558  template <class ARG, class T = ValueType>
559  inline decltype( std::declval<T>().erase( ARG{} ) ) erase( ARG arg )
560  {
561  return value().erase( arg );
562  }
563  template <class = ValueType>
565  {
566  ++value();
567  return *this;
568  }
569  template <class = ValueType>
570  inline ValueType operator++( int )
571  {
572  return m_value++;
573  }
574  template <class = ValueType>
576  {
577  --value();
578  return *this;
579  }
580  template <class = ValueType>
581  inline ValueType operator--( int )
582  {
583  return m_value--;
584  }
585  template <class T = ValueType>
586  inline Property& operator+=( const T& other )
587  {
588  m_value += other;
589  return *this;
590  }
591  template <class T = ValueType>
592  inline Property& operator-=( const T& other )
593  {
594  m_value -= other;
595  return *this;
596  }
598  template <class T = const ValueType>
599  inline decltype( std::declval<T>().key() ) key() const
600  {
601  return value().key();
602  }
603  template <class T = const ValueType>
604  inline decltype( std::declval<T>().objKey() ) objKey() const
605  {
606  return value().objKey();
607  }
608  template <class T = const ValueType>
609  inline decltype( std::declval<T>().fullKey() ) fullKey() const
610  {
611  return value().fullKey();
612  }
613  template <class T = ValueType>
614  inline decltype( std::declval<T>().initialize() ) initialize()
615  {
616  return value().initialize();
617  }
618  template <class T = ValueType>
619  inline decltype( std::declval<T>().makeHandles() ) makeHandles() const
620  {
621  return value().makeHandles();
622  }
623  template <class ARG, class T = ValueType>
624  inline decltype( std::declval<T>().makeHandles( std::declval<ARG>() ) ) makeHandles(const ARG& arg) const
625  {
626  return value().makeHandles(arg);
627  }
629  // ==========================================================================
630  public:
632  bool assign( const Details::PropertyBase& source ) override
633  {
634  // Check if the property of is of "the same" type, except for strings
635  const Property* p =
636  ( std::is_same<ValueType, std::string>::value ) ? nullptr : dynamic_cast<const Property*>( &source );
637  if ( p ) {
638  *this = p->value();
639  } else {
640  this->fromString( source.toString() ).ignore();
641  }
642  return true;
643  }
645  bool load( Details::PropertyBase& dest ) const override
646  {
647  // delegate to the 'opposite' method
648  return dest.assign( *this );
649  }
651  StatusCode fromString( const std::string& source ) override
652  {
653  using Converter = Details::Property::StringConverter<ValueType>;
654  *this = Converter().fromString( source );
655  return StatusCode::SUCCESS;
656  }
658  std::string toString() const override
659  {
660  using Converter = Details::Property::StringConverter<ValueType>;
661  return Converter().toString( *this );
662  }
664  void toStream( std::ostream& out ) const override
665  {
666  m_handlers.useReadHandler( *this );
667  using Utils::toStream;
668  toStream( m_value, out );
669  }
670  };
671 
673  template <class T, class TP, class V, class H>
674  bool operator==( const T& v, const Property<TP, V, H>& p )
675  {
676  return p == v;
677  }
678 
680  template <class T, class TP, class V, class H>
681  bool operator!=( const T& v, const Property<TP, V, H>& p )
682  {
683  return p != v;
684  }
685 
687  template <class T, class TP, class V, class H>
688  decltype( std::declval<TP>() + std::declval<T>() ) operator+( const T& v, const Property<TP, V, H>& p )
689  {
690  return v + p.value();
691  }
692 
693  template <class TYPE, class HANDLERS = Details::Property::UpdateHandler>
695 
696  template <class TYPE>
699 
700 } // namespace Gaudi
701 
702 template <class TYPE>
704 
705 template <class TYPE>
707 
708 // Typedef Properties for built-in types
724 
726 
727 // Typedef PropertyRefs for built-in types
743 
745 
746 // Typedef "Arrays" of Properties for built-in types
762 
764 
765 // Typedef "Arrays" of PropertyRefs for built-in types
781 
783 
786 template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
788 {
789  Handler m_handlers;
790 
791 public:
793 
795  PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override
796  {
797  m_handlers.setReadHandler( std::move( fun ) );
798  return *this;
799  }
801  PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override
802  {
803  m_handlers.setUpdateHandler( std::move( fun ) );
804  return *this;
805  }
806 
808  const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
810  const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
811 
813  void useReadHandler() const { m_handlers.useReadHandler( *this ); }
814 
816  bool useUpdateHandler() override
817  {
818  m_handlers.useUpdateHandler( *this );
819  return true;
820  }
821 };
822 
823 // forward-declaration is sufficient here
824 class GaudiHandleBase;
825 
826 // implementation in header file only where the GaudiHandleBase class
827 // definition is not needed. The rest goes into the .cpp file.
828 // The goal is to decouple the header files, to avoid that the whole
829 // world depends on GaudiHandle.h
831 {
832 public:
834 
836  {
837  setValue( value );
838  return *this;
839  }
840 
841  GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
842 
843  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
844 
845  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
846 
847  std::string toString() const override;
848 
849  void toStream( std::ostream& out ) const override;
850 
851  StatusCode fromString( const std::string& s ) override;
852 
853  const GaudiHandleBase& value() const
854  {
855  useReadHandler();
856  return *m_pValue;
857  }
858 
859  bool setValue( const GaudiHandleBase& value );
860 
861 private:
865 };
866 
867 // forward-declaration is sufficient here
869 
871 {
872 public:
874 
876  {
877  setValue( value );
878  return *this;
879  }
880 
881  GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
882 
883  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
884 
885  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
886 
887  std::string toString() const override;
888 
889  void toStream( std::ostream& out ) const override;
890 
891  StatusCode fromString( const std::string& s ) override;
892 
894  {
895  useReadHandler();
896  return *m_pValue;
897  }
898 
899  bool setValue( const GaudiHandleArrayBase& value );
900 
901 private:
905 };
906 
907 namespace Gaudi
908 {
909  namespace Utils
910  {
911  // ========================================================================
929  GAUDI_API bool hasProperty( const IProperty* p, const std::string& name );
930  // ========================================================================
948  GAUDI_API bool hasProperty( const IInterface* p, const std::string& name );
949  // ========================================================================
968  // ========================================================================
987  // ========================================================================
1011  // ========================================================================
1036  // ========================================================================
1060  template <class TYPE>
1061  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
1062  // ========================================================================
1085  template <class TYPE>
1086  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value )
1087  {
1088  return setProperty( component, name, value, std::string() );
1089  }
1090  // ========================================================================
1104  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
1105  const std::string& doc = "" );
1106  // ========================================================================
1120  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
1121  const std::string& doc = "" );
1122  // ========================================================================
1136  template <unsigned N>
1137  StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
1138  const std::string& doc = "" )
1139  {
1140  return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
1141  }
1142  // ========================================================================
1173  template <class TYPE>
1174  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc )
1175  {
1176  using Gaudi::Utils::toString;
1177  return component && hasProperty( component, name )
1178  ? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
1180  }
1181  // ========================================================================
1203  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1204  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1205  // ========================================================================
1227  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1228  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1229  // ========================================================================
1252  template <class TYPE>
1253  StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1254  const std::string& doc = "" )
1255  {
1256  return setProperty( component, name, &value, doc );
1257  }
1258  // ========================================================================
1279  template <class TYPE>
1280  StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1281  const std::string& doc = "" )
1282  {
1283  if ( !component ) {
1284  return StatusCode::FAILURE;
1285  }
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  {
1337  if ( 0 == component ) {
1338  return StatusCode::FAILURE;
1339  }
1340  return setProperty( component, name, std::string{value, value + N}, doc );
1341  }
1342  // ========================================================================
1364  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1365  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1366  // ========================================================================
1388  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1389  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1390  // ========================================================================
1413  template <class TYPE>
1414  StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1415  const std::string& doc = "" )
1416  {
1417  return setProperty( component, name, &value, doc );
1418  }
1419  // ========================================================================
1420  } // end of namespace Gaudi::Utils
1421 } // end of namespace Gaudi
1422 // ============================================================================
1423 // The END
1424 // ============================================================================
1425 #endif // GAUDIKERNEL_PROPERTY_H
1426 // ============================================================================
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition: Property.h:778
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:1174
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition: Property.h:730
Details::Property::NullVerifier VerifierType
Definition: Property.h:326
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition: Property.h:768
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:356
std::function< void(PropertyBase &)> m_readCallBack
Definition: Property.h:271
std::string toString(const TYPE &v)
Definition: Property.h:155
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Definition: Property.h:735
T empty(T...args)
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:681
GaudiHandleProperty * clone() const override
clones the current property
Definition: Property.h:841
bool setValue(const ValueType &v)
Definition: Property.h:482
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:308
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:262
void useUpdateHandler(const PropertyBase &) const
Definition: Property.h:263
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition: Property.h:752
Gaudi::Property< TYPE > SimpleProperty
Definition: Property.h:703
Gaudi::Property< long long & > LongLongPropertyRef
Definition: Property.h:738
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:75
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition: Property.h:753
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:674
bool useUpdateHandler() override
manual trigger for callback for update
Definition: Property.h:417
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property< long long > LongLongProperty
Definition: Property.h:719
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:808
Implementation of property with value of concrete type.
Definition: Property.h:319
Gaudi::Property< long & > LongPropertyRef
Definition: Property.h:736
std::function< void(PropertyBase &)> m_updateCallBack
Definition: Property.h:282
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:779
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:843
const std::string name() const
property name
Definition: Property.h:40
Property & operator=(T &&v)
Assignment from value.
Definition: Property.h:465
Gaudi::Property< float > FloatProperty
Definition: Property.h:721
Gaudi::Property< int > IntegerProperty
Definition: Property.h:715
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition: Property.h:777
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:219
const TYPE & upper() const
Return the upper bound value.
Definition: Property.h:198
GaudiHandleArrayProperty * clone() const override
clones the current property
Definition: Property.h:881
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:360
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition: Property.h:720
Gaudi::Property< float & > FloatPropertyRef
Definition: Property.h:740
vector< std::string > StorageType
Hosted type.
Definition: Property.h:324
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:658
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition: Property.h:763
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition: Property.h:771
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:750
void setLower(const TYPE &value)
Set lower bound value.
Definition: Property.h:201
HandlersType m_handlers
Definition: Property.h:333
Gaudi::Property< unsigned short > UnsignedShortProperty
Definition: Property.h:714
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:411
T end(T...args)
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition: Property.h:718
Gaudi::Property< std::string & > StringPropertyRef
Definition: Property.h:744
StorageType m_value
Storage.
Definition: Property.h:331
Gaudi::Property< char & > CharPropertyRef
Definition: Property.h:729
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition: Property.h:766
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition: Property.h:761
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition: Property.h:757
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition: Property.h:760
bool operator<(const T &other) const
"less" comparison
Definition: Property.h:451
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:751
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:775
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition: Property.h:754
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:399
Property()
Construct an anonymous property with default constructed value.
Definition: Property.h:385
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:787
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
Property & operator+=(const T &other)
Definition: Property.h:586
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition: Property.h:755
typename std::remove_reference< StorageType >::type ValueType
Definition: Property.h:325
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition: Property.h:774
void operator()(PropertyBase &p) const
Definition: Property.h:253
void operator()(const TYPE &value) const
Definition: Property.h:183
Gaudi::Property< signed char > SignedCharProperty
Definition: Property.h:711
std::ostream & toStream(const Type &, std::ostream &)
Gaudi::Property< char > CharProperty
Definition: Property.h:710
int N
Definition: IOTest.py:90
Property & operator-=(const T &other)
Definition: Property.h:592
const VerifierType & verifier() const
Accessor to verifier.
Definition: Property.h:474
Gaudi::Property< int & > IntegerPropertyRef
Definition: Property.h:734
GaudiHandleBase * m_pValue
Pointer to the real property.
Definition: Property.h:864
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition: Property.h:737
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:564
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:226
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Definition: Property.h:780
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:345
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:716
TYPE fromString(const std::string &s)
Definition: Property.h:160
const TYPE & lower() const
Return the lower bound value.
Definition: Property.h:196
T erase(T...args)
Gaudi::Property< std::vector< char > > CharArrayProperty
Definition: Property.h:748
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
const GaudiHandleBase & value() const
Definition: Property.h:853
Gaudi::Property< bool > BooleanProperty
Definition: Property.h:709
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:801
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition: Property.h:758
VerifierType & verifier()
Accessor to verifier.
Definition: Property.h:476
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:795
const GaudiHandleArrayBase & value() const
Definition: Property.h:893
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:192
Gaudi::Property< double > DoubleProperty
Definition: Property.h:722
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:772
T move(T...args)
bool assign(const PropertyBase &source) override
Definition: Property.h:885
Property & operator--()
Definition: Property.h:575
void operator()(const TYPE &) const
Definition: Property.h:177
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition: Property.h:776
Gaudi::Property< double & > DoublePropertyRef
Definition: Property.h:741
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:268
bool operator==(const T &other) const
equality comparison
Definition: Property.h:437
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition: Property.h:769
void useReadHandler(const PropertyBase &p) const
Definition: Property.h:272
bool hasUpper() const
Return if it has a lower bound.
Definition: Property.h:194
T find(T...args)
bool load(Details::PropertyBase &dest) const override
set value to another property
Definition: Property.h:645
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:294
Gaudi::Property< long double & > LongDoublePropertyRef
Definition: Property.h:742
ValueType & value()
Definition: Property.h:481
STL class.
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:813
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition: Property.h:749
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:816
Gaudi::Property< std::string > StringProperty
Definition: Property.h:725
T begin(T...args)
STL class.
void setUpdateHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:293
Gaudi::Property< long double > LongDoubleProperty
Definition: Property.h:723
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition: Property.h:875
SwapCall(callback_t &input)
Definition: Property.h:251
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition: Property.h:904
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
Gaudi::Property< short > ShortProperty
Definition: Property.h:713
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:756
Details::PropertyBase * clone() const override
clones the current property
Definition: Property.h:492
Gaudi::Property< TYPE & > SimplePropertyRef
Definition: Property.h:706
string s
Definition: gaudirun.py:245
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition: Property.h:739
void clearBounds()
Clear both bounds (lower and upper) at the same time.
Definition: Property.h:233
void setReadHandler(std::function< void(PropertyBase &)> fun)
Definition: Property.h:278
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:1414
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:279
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition: Property.h:782
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition: Property.h:632
bool assign(const PropertyBase &source) override
Definition: Property.h:845
bool operator!=(const T &other) const
inequality comparison
Definition: Property.h:444
Gaudi::Property< long > LongProperty
Definition: Property.h:717
void setUpdateHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:264
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition: Property.h:767
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:480
void clearLower()
Clear lower bound value.
Definition: Property.h:213
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:378
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition: Property.h:733
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition: Property.h:759
ValueType operator++(int)
Definition: Property.h:570
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:248
boost::string_ref m_documentation
property doc string
Definition: Property.h:139
bool load(PropertyBase &destination) const override
Definition: Property.h:883
#define GAUDI_API
Definition: Kernel.h:107
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition: Property.h:835
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition: Property.h:770
STL class.
Property(OWNER *owner, std::string name, T &&value, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:367
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:810
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:393
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition: Property.h:712
VerifierType m_verifier
Definition: Property.h:332
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:406
Gaudi::Property< short & > ShortPropertyRef
Definition: Property.h:732
std::string toString(const Type &)
void setUpper(const TYPE &value)
Set upper bound value.
Definition: Property.h:207
void setReadHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:258
Details::Property::UpdateHandler HandlersType
Definition: Property.h:327
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Definition: Property.h:731
ValueType operator--(int)
Definition: Property.h:581
decltype(std::declval< TP >()+std::declval< T >()) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition: Property.h:688
void useReadHandler(const PropertyBase &) const
Definition: Property.h:257
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition: Property.h:747
const std::type_info * type_info() const
property type-info
Definition: Property.h:44
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition: Property.h:773
StatusCode fromString(const std::string &source) override
string -> value
Definition: Property.h:651
void toStream(std::ostream &out) const override
value -> stream
Definition: Property.h:664
Gaudi::Property< bool & > BooleanPropertyRef
Definition: Property.h:728
void useUpdateHandler(PropertyBase &p)
Definition: Property.h:283