Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v29r3 (fa547fc2)
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(); }
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 ) : Property( std::move( name ), ValueType{}, "" )
357  {
358  owner->declareProperty( *this );
359  setOwnerType<OWNER>();
360  }
361 
364  template <class OWNER, class T = StorageType,
366  inline Property( OWNER* owner, std::string name, T&& value, std::string doc = "" )
367  : Property( std::move( name ), std::forward<T>( value ), std::move( doc ) )
368  {
369  owner->declareProperty( *this );
370  setOwnerType<OWNER>();
371  }
372 
377  Property( T&& v ) : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value( std::forward<T>( v ) )
378  {
379  }
380 
383  template <typename T = StorageType, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
384  Property() : Details::PropertyBase( typeid( ValueType ), "", "" ), m_value()
385  {
386  }
387 
390 
393  {
394  m_handlers.setReadHandler( std::move( fun ) );
395  return *this;
396  }
399  {
400  m_handlers.setUpdateHandler( std::move( fun ) );
401  return *this;
402  }
403 
406  {
407  return m_handlers.getReadHandler();
408  }
411  {
412  return m_handlers.getUpdateHandler();
413  }
414 
416  bool useUpdateHandler() override
417  {
418  m_handlers.useUpdateHandler( *this );
419  return true;
420  }
421 
423  operator const ValueType&() const
424  {
425  m_handlers.useReadHandler( *this );
426  return m_value;
427  }
428  // /// Automatic conversion to value (reference).
429  // operator ValueType& () {
430  // useReadHandler();
431  // return m_value;
432  // }
433 
435  template <class T>
436  inline bool operator==( const T& other ) const
437  {
438  return m_value == other;
439  }
440 
442  template <class T>
443  inline bool operator!=( const T& other ) const
444  {
445  return m_value != other;
446  }
447 
449  template <class T>
450  inline bool operator<( const T& other ) const
451  {
452  return m_value < other;
453  }
454 
456  template <class T>
457  decltype( std::declval<ValueType>() + std::declval<T>() ) operator+( const T& other ) const
458  {
459  return m_value + other;
460  }
461 
463  template <class T = ValueType>
464  Property& operator=( T&& v )
465  {
466  m_verifier( v );
467  m_value = std::forward<T>( v );
468  m_handlers.useUpdateHandler( *this );
469  return *this;
470  }
471 
473  const VerifierType& verifier() const { return m_verifier; }
475  VerifierType& verifier() { return m_verifier; }
476 
479  const ValueType& value() const { return *this; }
480  ValueType& value() { return const_cast<ValueType&>( (const ValueType&)*this ); }
481  bool setValue( const ValueType& v )
482  {
483  *this = v;
484  return true;
485  }
486  bool set( const ValueType& v )
487  {
488  *this = v;
489  return true;
490  }
491  Details::PropertyBase* clone() const override { return new Property( *this ); }
493 
497  template <class T = const ValueType>
498  inline decltype( std::declval<T>().size() ) size() const
499  {
500  return value().size();
501  }
502  template <class T = const ValueType>
503  inline decltype( std::declval<T>().length() ) length() const
504  {
505  return value().length();
506  }
507  template <class T = const ValueType>
508  inline decltype( std::declval<T>().empty() ) empty() const
509  {
510  return value().empty();
511  }
512  template <class T = ValueType>
513  inline decltype( std::declval<T>().clear() ) clear()
514  {
515  value().clear();
516  }
517  template <class T = const ValueType>
518  inline decltype( std::declval<T>().begin() ) begin() const
519  {
520  return value().begin();
521  }
522  template <class T = const ValueType>
523  inline decltype( std::declval<T>().end() ) end() const
524  {
525  return value().end();
526  }
527  template <class T = ValueType>
528  inline decltype( std::declval<T>().begin() ) begin()
529  {
530  return value().begin();
531  }
532  template <class T = ValueType>
533  inline decltype( std::declval<T>().end() ) end()
534  {
535  return value().end();
536  }
537  template <class ARG, class T = const ValueType>
538  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg ) const
539  {
540  return value()[arg];
541  }
542  template <class ARG, class T = ValueType>
543  inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
544  {
545  return value()[arg];
546  }
547  template <class T = const ValueType>
548  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key ) const
549  {
550  return value().find( key );
551  }
552  template <class T = ValueType>
553  inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key )
554  {
555  return value().find( key );
556  }
557  template <class ARG, class T = ValueType>
558  inline decltype( std::declval<T>().erase( ARG{} ) ) erase( ARG arg )
559  {
560  return value().erase( arg );
561  }
562  template <class = ValueType>
564  {
565  ++value();
566  return *this;
567  }
568  template <class = ValueType>
569  inline ValueType operator++( int )
570  {
571  return m_value++;
572  }
573  template <class = ValueType>
575  {
576  --value();
577  return *this;
578  }
579  template <class = ValueType>
580  inline ValueType operator--( int )
581  {
582  return m_value--;
583  }
584  template <class T = ValueType>
585  inline Property& operator+=( const T& other )
586  {
587  m_value += other;
588  return *this;
589  }
590  template <class T = ValueType>
591  inline Property& operator-=( const T& other )
592  {
593  m_value -= other;
594  return *this;
595  }
597  template <class T = const ValueType>
598  inline decltype( std::declval<T>().key() ) key() const
599  {
600  return value().key();
601  }
602  template <class T = const ValueType>
603  inline decltype( std::declval<T>().objKey() ) objKey() const
604  {
605  return value().objKey();
606  }
607  template <class T = const ValueType>
608  inline decltype( std::declval<T>().fullKey() ) fullKey() const
609  {
610  return value().fullKey();
611  }
612  template <class T = ValueType>
613  inline decltype( std::declval<T>().initialize() ) initialize()
614  {
615  return value().initialize();
616  }
617  template <class T = ValueType>
618  inline decltype( std::declval<T>().makeHandles() ) makeHandles() const
619  {
620  return value().makeHandles();
621  }
622  template <class ARG, class T = ValueType>
623  inline decltype( std::declval<T>().makeHandles( std::declval<ARG>() ) ) makeHandles( const ARG& arg ) const
624  {
625  return value().makeHandles( arg );
626  }
628  // ==========================================================================
629  public:
631  bool assign( const Details::PropertyBase& source ) override
632  {
633  // Check if the property of is of "the same" type, except for strings
634  const Property* p =
635  ( std::is_same<ValueType, std::string>::value ) ? nullptr : dynamic_cast<const Property*>( &source );
636  if ( p ) {
637  *this = p->value();
638  } else {
639  this->fromString( source.toString() ).ignore();
640  }
641  return true;
642  }
644  bool load( Details::PropertyBase& dest ) const override
645  {
646  // delegate to the 'opposite' method
647  return dest.assign( *this );
648  }
650  StatusCode fromString( const std::string& source ) override
651  {
652  using Converter = Details::Property::StringConverter<ValueType>;
653  *this = Converter().fromString( source );
654  return StatusCode::SUCCESS;
655  }
657  std::string toString() const override
658  {
659  using Converter = Details::Property::StringConverter<ValueType>;
660  return Converter().toString( *this );
661  }
663  void toStream( std::ostream& out ) const override
664  {
665  m_handlers.useReadHandler( *this );
666  using Utils::toStream;
667  toStream( m_value, out );
668  }
669  };
670 
672  template <class T, class TP, class V, class H>
673  bool operator==( const T& v, const Property<TP, V, H>& p )
674  {
675  return p == v;
676  }
677 
679  template <class T, class TP, class V, class H>
680  bool operator!=( const T& v, const Property<TP, V, H>& p )
681  {
682  return p != v;
683  }
684 
686  template <class T, class TP, class V, class H>
687  decltype( std::declval<TP>() + std::declval<T>() ) operator+( const T& v, const Property<TP, V, H>& p )
688  {
689  return v + p.value();
690  }
691 
692  template <class TYPE, class HANDLERS = Details::Property::UpdateHandler>
694 
695  template <class TYPE>
698 
699 } // namespace Gaudi
700 
701 template <class TYPE>
703 
704 template <class TYPE>
706 
707 // Typedef Properties for built-in types
723 
725 
726 // Typedef PropertyRefs for built-in types
742 
744 
745 // Typedef "Arrays" of Properties for built-in types
761 
763 
764 // Typedef "Arrays" of PropertyRefs for built-in types
780 
782 
785 template <typename Handler = typename Gaudi::Details::Property::UpdateHandler>
787 {
788  Handler m_handlers;
789 
790 public:
792 
794  PropertyBase& declareReadHandler( std::function<void( PropertyBase& )> fun ) override
795  {
796  m_handlers.setReadHandler( std::move( fun ) );
797  return *this;
798  }
800  PropertyBase& declareUpdateHandler( std::function<void( PropertyBase& )> fun ) override
801  {
802  m_handlers.setUpdateHandler( std::move( fun ) );
803  return *this;
804  }
805 
807  const std::function<void( PropertyBase& )> readCallBack() const override { return m_handlers.getReadHandler(); }
809  const std::function<void( PropertyBase& )> updateCallBack() const override { return m_handlers.getUpdateHandler(); }
810 
812  void useReadHandler() const { m_handlers.useReadHandler( *this ); }
813 
815  bool useUpdateHandler() override
816  {
817  m_handlers.useUpdateHandler( *this );
818  return true;
819  }
820 };
821 
822 // forward-declaration is sufficient here
823 class GaudiHandleBase;
824 
825 // implementation in header file only where the GaudiHandleBase class
826 // definition is not needed. The rest goes into the .cpp file.
827 // The goal is to decouple the header files, to avoid that the whole
828 // world depends on GaudiHandle.h
830 {
831 public:
833 
835  {
836  setValue( value );
837  return *this;
838  }
839 
840  GaudiHandleProperty* clone() const override { return new GaudiHandleProperty( *this ); }
841 
842  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
843 
844  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
845 
846  std::string toString() const override;
847 
848  void toStream( std::ostream& out ) const override;
849 
850  StatusCode fromString( const std::string& s ) override;
851 
852  const GaudiHandleBase& value() const
853  {
854  useReadHandler();
855  return *m_pValue;
856  }
857 
858  bool setValue( const GaudiHandleBase& value );
859 
860 private:
864 };
865 
866 // forward-declaration is sufficient here
868 
870 {
871 public:
873 
875  {
876  setValue( value );
877  return *this;
878  }
879 
880  GaudiHandleArrayProperty* clone() const override { return new GaudiHandleArrayProperty( *this ); }
881 
882  bool load( PropertyBase& destination ) const override { return destination.assign( *this ); }
883 
884  bool assign( const PropertyBase& source ) override { return fromString( source.toString() ); }
885 
886  std::string toString() const override;
887 
888  void toStream( std::ostream& out ) const override;
889 
890  StatusCode fromString( const std::string& s ) override;
891 
893  {
894  useReadHandler();
895  return *m_pValue;
896  }
897 
898  bool setValue( const GaudiHandleArrayBase& value );
899 
900 private:
904 };
905 
906 namespace Gaudi
907 {
908  namespace Utils
909  {
910  // ========================================================================
928  GAUDI_API bool hasProperty( const IProperty* p, const std::string& name );
929  // ========================================================================
947  GAUDI_API bool hasProperty( const IInterface* p, const std::string& name );
948  // ========================================================================
967  // ========================================================================
986  // ========================================================================
1010  // ========================================================================
1035  // ========================================================================
1059  template <class TYPE>
1060  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc );
1061  // ========================================================================
1084  template <class TYPE>
1085  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value )
1086  {
1087  return setProperty( component, name, value, std::string() );
1088  }
1089  // ========================================================================
1103  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const std::string& value,
1104  const std::string& doc = "" );
1105  // ========================================================================
1119  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name, const char* value,
1120  const std::string& doc = "" );
1121  // ========================================================================
1135  template <unsigned N>
1136  StatusCode setProperty( IProperty* component, const std::string& name, const char ( &value )[N],
1137  const std::string& doc = "" )
1138  {
1139  return component ? setProperty( component, name, std::string( value, value + N ), doc ) : StatusCode::FAILURE;
1140  }
1141  // ========================================================================
1172  template <class TYPE>
1173  StatusCode setProperty( IProperty* component, const std::string& name, const TYPE& value, const std::string& doc )
1174  {
1175  using Gaudi::Utils::toString;
1176  return component && hasProperty( component, name )
1177  ? Gaudi::Utils::setProperty( component, name, toString( value ), doc )
1179  }
1180  // ========================================================================
1202  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1203  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1204  // ========================================================================
1226  GAUDI_API StatusCode setProperty( IProperty* component, const std::string& name,
1227  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1228  // ========================================================================
1251  template <class TYPE>
1252  StatusCode setProperty( IProperty* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1253  const std::string& doc = "" )
1254  {
1255  return setProperty( component, name, &value, doc );
1256  }
1257  // ========================================================================
1278  template <class TYPE>
1279  StatusCode setProperty( IInterface* component, const std::string& name, const TYPE& value,
1280  const std::string& doc = "" )
1281  {
1282  if ( !component ) {
1283  return StatusCode::FAILURE;
1284  }
1285  auto property = SmartIF<IProperty>{component};
1286  return property ? setProperty( property, name, value, doc ) : StatusCode::FAILURE;
1287  }
1288  // ========================================================================
1301  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const std::string& value,
1302  const std::string& doc = "" );
1303  // ========================================================================
1316  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name, const char* value,
1317  const std::string& doc = "" );
1318  // ========================================================================
1332  template <unsigned N>
1333  StatusCode setProperty( IInterface* component, const std::string& name, const char ( &value )[N],
1334  const std::string& doc = "" )
1335  {
1336  if ( 0 == component ) {
1337  return StatusCode::FAILURE;
1338  }
1339  return setProperty( component, name, std::string{value, value + N}, doc );
1340  }
1341  // ========================================================================
1363  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1364  const Gaudi::Details::PropertyBase* property, const std::string& doc = "" );
1365  // ========================================================================
1387  GAUDI_API StatusCode setProperty( IInterface* component, const std::string& name,
1388  const Gaudi::Details::PropertyBase& property, const std::string& doc = "" );
1389  // ========================================================================
1412  template <class TYPE>
1413  StatusCode setProperty( IInterface* component, const std::string& name, const Gaudi::Property<TYPE>& value,
1414  const std::string& doc = "" )
1415  {
1416  return setProperty( component, name, &value, doc );
1417  }
1418  // ========================================================================
1419  } // end of namespace Gaudi::Utils
1420 } // end of namespace Gaudi
1421 // ============================================================================
1422 // The END
1423 // ============================================================================
1424 #endif // GAUDIKERNEL_PROPERTY_H
1425 // ============================================================================
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Definition: Property.h:777
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:1173
Gaudi::Property< signed char & > SignedCharPropertyRef
Definition: Property.h:729
Details::Property::NullVerifier VerifierType
Definition: Property.h:326
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Definition: Property.h:767
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:734
T empty(T...args)
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:680
GaudiHandleProperty * clone() const override
clones the current property
Definition: Property.h:840
bool setValue(const ValueType &v)
Definition: Property.h:481
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:293
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:751
Gaudi::Property< TYPE > SimpleProperty
Definition: Property.h:702
Gaudi::Property< long long & > LongLongPropertyRef
Definition: Property.h:737
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
Definition: Property.h:75
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Definition: Property.h:752
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:673
bool useUpdateHandler() override
manual trigger for callback for update
Definition: Property.h:416
void setDocumentation(std::string value)
set the documentation string
Definition: Property.h:92
Gaudi::Property< long long > LongLongProperty
Definition: Property.h:718
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Definition: Property.h:807
Implementation of property with value of concrete type.
Definition: Property.h:319
Gaudi::Property< long & > LongPropertyRef
Definition: Property.h:735
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:329
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Definition: Property.h:778
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:842
const std::string name() const
property name
Definition: Property.h:40
Property & operator=(T &&v)
Assignment from value.
Definition: Property.h:464
Gaudi::Property< float > FloatProperty
Definition: Property.h:720
Gaudi::Property< int > IntegerProperty
Definition: Property.h:714
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Definition: Property.h:776
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:880
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:346
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Definition: Property.h:719
Gaudi::Property< float & > FloatPropertyRef
Definition: Property.h:739
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:657
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Definition: Property.h:762
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Definition: Property.h:770
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:749
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:713
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:410
T end(T...args)
Gaudi::Property< unsigned long > UnsignedLongProperty
Definition: Property.h:717
Gaudi::Property< std::string & > StringPropertyRef
Definition: Property.h:743
StorageType m_value
Storage.
Definition: Property.h:331
Gaudi::Property< char & > CharPropertyRef
Definition: Property.h:728
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Definition: Property.h:765
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Definition: Property.h:760
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Definition: Property.h:756
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Definition: Property.h:759
bool operator<(const T &other) const
"less" comparison
Definition: Property.h:450
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:750
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:774
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition: Property.h:753
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:398
Property()
Construct an anonymous property with default constructed value.
Definition: Property.h:384
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:786
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
Property & operator+=(const T &other)
Definition: Property.h:585
Gaudi::Property< std::vector< long > > LongArrayProperty
Definition: Property.h:754
typename std::remove_reference< StorageType >::type ValueType
Definition: Property.h:325
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Definition: Property.h:773
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:710
std::ostream & toStream(const Type &, std::ostream &)
Gaudi::Property< char > CharProperty
Definition: Property.h:709
int N
Definition: IOTest.py:101
Property & operator-=(const T &other)
Definition: Property.h:591
const VerifierType & verifier() const
Accessor to verifier.
Definition: Property.h:473
Gaudi::Property< int & > IntegerPropertyRef
Definition: Property.h:733
GaudiHandleBase * m_pValue
Pointer to the real property.
Definition: Property.h:863
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Definition: Property.h:736
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:563
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:779
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:277
const std::type_info * m_typeinfo
property type
Definition: Property.h:141
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Definition: Property.h:715
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:747
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
const GaudiHandleBase & value() const
Definition: Property.h:852
Gaudi::Property< bool > BooleanProperty
Definition: Property.h:708
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:800
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition: Property.h:757
VerifierType & verifier()
Accessor to verifier.
Definition: Property.h:475
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:794
const GaudiHandleArrayBase & value() const
Definition: Property.h:892
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
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:721
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:771
T move(T...args)
bool assign(const PropertyBase &source) override
Definition: Property.h:884
Property & operator--()
Definition: Property.h:574
void operator()(const TYPE &) const
Definition: Property.h:177
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Definition: Property.h:775
Gaudi::Property< double & > DoublePropertyRef
Definition: Property.h:740
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:268
bool operator==(const T &other) const
equality comparison
Definition: Property.h:436
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Definition: Property.h:768
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:644
T size(T...args)
Base class of array&#39;s of various gaudihandles.
Definition: GaudiHandle.h:348
std::function< void(PropertyBase &)> getUpdateHandler() const
Definition: Property.h:294
Gaudi::Property< long double & > LongDoublePropertyRef
Definition: Property.h:741
ValueType & value()
Definition: Property.h:480
STL class.
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:812
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Definition: Property.h:748
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:815
Gaudi::Property< std::string > StringProperty
Definition: Property.h:724
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:722
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition: Property.h:874
SwapCall(callback_t &input)
Definition: Property.h:251
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Definition: Property.h:903
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
Gaudi::Property< short > ShortProperty
Definition: Property.h:712
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:755
Details::PropertyBase * clone() const override
clones the current property
Definition: Property.h:491
Gaudi::Property< TYPE & > SimplePropertyRef
Definition: Property.h:705
string s
Definition: gaudirun.py:253
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Definition: Property.h:738
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:1413
std::function< void(PropertyBase &)> getReadHandler() const
Definition: Property.h:279
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Definition: Property.h:781
bool assign(const Details::PropertyBase &source) override
get the value from another property
Definition: Property.h:631
bool assign(const PropertyBase &source) override
Definition: Property.h:844
bool operator!=(const T &other) const
inequality comparison
Definition: Property.h:443
Gaudi::Property< long > LongProperty
Definition: Property.h:716
void setUpdateHandler(std::function< void(PropertyBase &)>)
Definition: Property.h:264
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Definition: Property.h:766
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:479
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:83
implementation of various functions for streaming.
Property(T &&v)
Construct an anonymous property from a value.
Definition: Property.h:377
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Definition: Property.h:732
Gaudi::Property< std::vector< float > > FloatArrayProperty
Definition: Property.h:758
ValueType operator++(int)
Definition: Property.h:569
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:882
#define GAUDI_API
Definition: Kernel.h:110
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition: Property.h:834
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Definition: Property.h:769
STL class.
Property(OWNER *owner, std::string name, T &&value, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Definition: Property.h:366
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Definition: Property.h:809
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
Definition: Property.h:392
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Property< unsigned char > UnsignedCharProperty
Definition: Property.h:711
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:405
Gaudi::Property< short & > ShortPropertyRef
Definition: Property.h:731
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:730
ValueType operator--(int)
Definition: Property.h:580
decltype(std::declval< TP >()+std::declval< T >()) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition: Property.h:687
void useReadHandler(const PropertyBase &) const
Definition: Property.h:257
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Definition: Property.h:746
const std::type_info * type_info() const
property type-info
Definition: Property.h:44
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Definition: Property.h:772
StatusCode fromString(const std::string &source) override
string -> value
Definition: Property.h:650
void toStream(std::ostream &out) const override
value -> stream
Definition: Property.h:663
Gaudi::Property< bool & > BooleanPropertyRef
Definition: Property.h:727
void useUpdateHandler(PropertyBase &p)
Definition: Property.h:283