00001
00002
00003
00004
00005 #ifndef GAUDIKERNEL_PROPERTY_H
00006 #define GAUDIKERNEL_PROPERTY_H
00007
00008
00009
00010 #include <string>
00011 #include <stdexcept>
00012 #include <typeinfo>
00013
00014
00015
00016 #include "GaudiKernel/Kernel.h"
00017 #include "GaudiKernel/PropertyVerifier.h"
00018 #include "GaudiKernel/Parsers.h"
00019 #include "GaudiKernel/ToStream.h"
00020 #include "GaudiKernel/SmartIF.h"
00021
00022
00023
00024 class Property ;
00025 class PropertyCallbackFunctor ;
00026 class IProperty ;
00027 class IInterface ;
00028
00029
00030
00032
00033 GAUDI_API std::ostream& operator<<(std::ostream& stream, const Property& prop);
00034
00043 class GAUDI_API Property
00044 {
00045 public:
00047 const std::string& name () const { return m_name ; } ;
00049 const std::string& documentation() const { return m_documentation; };
00051 const std::type_info* type_info () const { return m_typeinfo ; } ;
00053 std::string type () const { return m_typeinfo->name() ; } ;
00055 virtual bool load ( Property& dest ) const = 0 ;
00057 virtual bool assign ( const Property& source ) = 0 ;
00058 public:
00060 virtual std::string toString () const = 0 ;
00062 virtual StatusCode fromString ( const std::string& value ) = 0 ;
00063 public:
00065 const PropertyCallbackFunctor* readCallBack () const ;
00067 const PropertyCallbackFunctor* updateCallBack () const ;
00069 virtual void declareReadHandler ( PropertyCallbackFunctor* pf ) ;
00071 virtual void declareUpdateHandler ( PropertyCallbackFunctor* pf ) ;
00072 template< class HT >
00073 void declareReadHandler
00074 ( void ( HT::* MF ) ( Property& ) , HT* instance ) ;
00075 template< class HT >
00076 void declareUpdateHandler
00077 ( void ( HT::* MF ) ( Property& ) , HT* instance ) ;
00079 virtual void useReadHandler () const ;
00081 virtual bool useUpdateHandler () ;
00082 public:
00084 virtual ~Property() ;
00086 virtual Property* clone () const = 0 ;
00088 void setName ( const std::string& value ) { m_name = value ; }
00090 void setDocumentation( const std::string& documentation ) {
00091 m_documentation = documentation; };
00093 virtual std::ostream& fillStream ( std::ostream& ) const ;
00094 protected:
00096 Property
00097 ( const std::type_info& type ,
00098 const std::string& name = "" ) ;
00100 Property
00101 ( const std::string& name ,
00102 const std::type_info& type ) ;
00104 Property ( const Property& right ) ;
00106 Property& operator=( const Property& right ) ;
00107 private:
00108
00109 Property() ;
00110 private:
00111
00112 std::string m_name ;
00113
00114 std::string m_documentation;
00115
00116 const std::type_info* m_typeinfo ;
00117 protected:
00118
00119 mutable PropertyCallbackFunctor* m_readCallBack ;
00120
00121 PropertyCallbackFunctor* m_updateCallBack ;
00122 };
00123
00124 #include "GaudiKernel/PropertyCallbackFunctor.h"
00125
00126 template< class HT >
00127 inline void Property::declareReadHandler
00128 ( void ( HT::* MF ) ( Property& ) , HT* obj )
00129 { declareReadHandler ( new PropertyCallbackMemberFunctor< HT >( MF , obj ) ) ; }
00130
00131 template< class HT >
00132 inline void Property::declareUpdateHandler
00133 ( void ( HT::* MF ) ( Property& ) , HT* obj )
00134 { declareUpdateHandler ( new PropertyCallbackMemberFunctor< HT >( MF , obj ) ) ; }
00135
00143
00144 template <class TYPE>
00145 class PropertyWithValue
00146 : public Property
00147 {
00148 protected:
00150 PropertyWithValue
00151 ( const std::string& name ,
00152 TYPE* value ,
00153 const bool owner ) ;
00155 PropertyWithValue ( const PropertyWithValue& rhs ) ;
00157 template <class OTHER>
00158 PropertyWithValue ( const PropertyWithValue<OTHER>& right ) ;
00160 virtual ~PropertyWithValue() ;
00162 PropertyWithValue& operator=( const TYPE& value ) ;
00163
00164 PropertyWithValue& operator=( const PropertyWithValue& rhs ) ;
00165
00166 template <class OTHER>
00167 PropertyWithValue& operator=( const PropertyWithValue<OTHER>& right ) ;
00168 public:
00169 operator const TYPE& () const { return value() ;}
00170 const TYPE& value() const ;
00171 public:
00172
00173 virtual bool setValue ( const TYPE& value ) = 0 ;
00175 virtual bool assign ( const Property& source ) ;
00177 virtual bool load ( Property& dest ) const ;
00179 virtual StatusCode fromString ( const std::string& s ) ;
00181 virtual std::string toString () const ;
00182 protected:
00183 void i_set ( const TYPE& value ) ;
00184 TYPE* i_get () const ;
00185 private:
00186 TYPE* m_value ;
00187 bool m_own ;
00188 };
00189
00191
00192 template <class TYPE>
00193 inline PropertyWithValue<TYPE>::PropertyWithValue
00194 ( const std::string& name ,
00195 TYPE* value ,
00196 const bool own )
00197 : Property ( typeid( TYPE ) , name )
00198 , m_value ( value )
00199 , m_own ( own )
00200 {}
00201
00202
00203
00204 template <class TYPE>
00205 inline PropertyWithValue<TYPE>::PropertyWithValue
00206 ( const PropertyWithValue& right )
00207 : Property( right )
00208 , m_value ( right.m_value )
00209 , m_own ( right.m_own )
00210 { if ( m_own ) { m_value = new TYPE(right.value()) ; } }
00211
00212
00213
00214 template <class TYPE>
00215 template <class OTHER>
00216 inline PropertyWithValue<TYPE>::PropertyWithValue
00217 ( const PropertyWithValue<OTHER>& right )
00218 : Property( right )
00219 , m_value ( right.m_value )
00220 , m_own ( right.m_own )
00221 { if ( m_own ) { m_value = new TYPE(right.value()) ; } }
00222
00224
00225 template <class TYPE>
00226 inline PropertyWithValue<TYPE>::~PropertyWithValue()
00227 { if ( m_own ) { delete m_value ; } ; m_value = 0 ; }
00228
00230
00231 template <class TYPE>
00232 inline PropertyWithValue<TYPE>&
00233 PropertyWithValue<TYPE>::operator=( const TYPE& value )
00234 {
00235 if ( !setValue ( value ) )
00236 { throw std::out_of_range( "Value not verified" ) ; }
00237 return *this ;
00238 }
00239
00241
00242 template <class TYPE>
00243 inline bool
00244 PropertyWithValue<TYPE>::assign ( const Property& source )
00245 {
00246
00247 const PropertyWithValue<TYPE>* p =
00248 dynamic_cast<const PropertyWithValue<TYPE>*> ( &source ) ;
00249 if ( 0 != p ) { return setValue ( p->value() ) ; }
00250
00251 return this->fromString( source.toString() ).isSuccess() ;
00252 }
00253
00255
00256 template <class TYPE>
00257 inline bool
00258 PropertyWithValue<TYPE>::load( Property& dest ) const
00259 {
00260
00261 return dest.assign( *this ) ;
00262 }
00263
00265
00266 template <class TYPE>
00267 inline std::string
00268 PropertyWithValue<TYPE>::toString () const
00269 {
00270 useReadHandler();
00271 return Gaudi::Utils::toString( *m_value ) ;
00272 }
00273
00275
00276 template <class TYPE>
00277 inline StatusCode
00278 PropertyWithValue<TYPE>::fromString ( const std::string& source )
00279 {
00280 TYPE tmp ;
00281 StatusCode sc = Gaudi::Parsers::parse ( tmp , source ) ;
00282 if ( sc.isFailure() ) { return sc ; }
00283 return setValue ( tmp ) ? StatusCode::SUCCESS : StatusCode::FAILURE ;
00284 }
00285
00287
00288 template <>
00289 inline std::string
00290 PropertyWithValue<std::string>::toString () const
00291 { return this->value() ; }
00292
00293 template <>
00294 inline bool PropertyWithValue<std::string>::assign ( const Property& source )
00295 { return this->fromString( source.toString() ).isSuccess() ; }
00296
00297
00298
00300
00301 template <class TYPE>
00302 inline const TYPE&
00303 PropertyWithValue<TYPE>::value() const
00304 { useReadHandler() ; return *m_value ; }
00305
00306
00307
00308 template <class TYPE>
00309 inline void PropertyWithValue<TYPE>::i_set
00310 ( const TYPE& value ) { *m_value = value ; }
00311
00312
00313
00314 template <class TYPE>
00315 inline TYPE* PropertyWithValue<TYPE>::i_get() const { return m_value ; }
00316
00317
00318
00319 template <class TYPE>
00320 PropertyWithValue<TYPE>& PropertyWithValue<TYPE>::operator=
00321 ( const PropertyWithValue& right )
00322 {
00323
00324 Property::operator=( right ) ;
00325
00326 PropertyWithValue<TYPE>::operator=( right.value() ) ;
00327 return *this ;
00328 }
00329
00330
00331
00332 template <class TYPE>
00333 template <class OTHER>
00334 PropertyWithValue<TYPE>& PropertyWithValue<TYPE>::operator=
00335 ( const PropertyWithValue<OTHER>& right )
00336 {
00337
00338 Property::operator=( right ) ;
00339
00340 PropertyWithValue<TYPE>::operator=( right.value() ) ;
00341 return *this ;
00342 }
00343
00344
00345
00353
00354 template<class TYPE,class VERIFIER>
00355 class PropertyWithVerifier
00356 : public PropertyWithValue<TYPE>
00357 {
00358 protected:
00360 PropertyWithVerifier
00361 ( const std::string& name ,
00362 TYPE* value ,
00363 const bool owner ,
00364 const VERIFIER& verifier )
00365 : PropertyWithValue<TYPE> ( name , value , owner )
00366 , m_verifier ( verifier )
00367 {}
00369 virtual ~PropertyWithVerifier() {};
00370 public:
00371 inline VERIFIER& verifier() { return m_verifier ; }
00372 inline const VERIFIER& verifier() const { return m_verifier ; }
00374 bool set( const TYPE& value ) ;
00376 virtual bool setValue( const TYPE& value ) { return set( value ) ; }
00378 template <class OTHER,class OTHERVERIFIER>
00379 PropertyWithVerifier& operator=
00380 ( const PropertyWithVerifier<OTHER,OTHERVERIFIER>& right ) ;
00382 template <class OTHER>
00383 PropertyWithVerifier& operator=( const PropertyWithValue<OTHER>& right ) ;
00385 PropertyWithVerifier& operator=( const TYPE& right ) ;
00386 private:
00388 PropertyWithVerifier() ;
00390 PropertyWithVerifier( const PropertyWithVerifier& right );
00391 private:
00392 VERIFIER m_verifier ;
00393 } ;
00394
00396
00397 template <class TYPE,class VERIFIER>
00398 inline bool
00399 PropertyWithVerifier<TYPE,VERIFIER>::set( const TYPE& value )
00400 {
00402 if ( !m_verifier.isValid( &value ) ) { return false ; }
00404 i_set( value ) ;
00406 return this->useUpdateHandler() ;
00407 }
00408
00410
00411 template <class TYPE,class VERIFIER>
00412 inline PropertyWithVerifier<TYPE,VERIFIER>&
00413 PropertyWithVerifier<TYPE,VERIFIER>::operator=( const TYPE& right )
00414 {
00415 PropertyWithValue<TYPE>::operator=( right ) ;
00416 return *this ;
00417 }
00418
00420
00421 template <class TYPE,class VERIFIER>
00422 template <class OTHER>
00423 inline PropertyWithVerifier<TYPE,VERIFIER>&
00424 PropertyWithVerifier<TYPE,VERIFIER>::operator=( const PropertyWithValue<OTHER>& right )
00425 {
00426 PropertyWithValue<TYPE>::operator=(right) ;
00427 return *this ;
00428 }
00429
00431
00432 template <class TYPE,class VERIFIER>
00433 template <class OTHER,class OTHERVERIFIER>
00434 inline PropertyWithVerifier<TYPE,VERIFIER>&
00435 PropertyWithVerifier<TYPE,VERIFIER>::operator=
00436 ( const PropertyWithVerifier<OTHER,OTHERVERIFIER>& right )
00437 {
00438 PropertyWithValue<TYPE>::operator=(right) ;
00439 return *this ;
00440 }
00441
00442
00443
00453
00454 template <class TYPE,class VERIFIER = BoundedVerifier<TYPE> >
00455 class SimpleProperty
00456 : public PropertyWithVerifier<TYPE,VERIFIER>
00457 {
00458 public:
00460 SimpleProperty
00461 ( VERIFIER verifier = VERIFIER() ) ;
00463 SimpleProperty
00464 ( const TYPE& value ,
00465 VERIFIER verifier = VERIFIER() ) ;
00467 SimpleProperty
00468 ( const std::string& name ,
00469 const TYPE& value ,
00470 VERIFIER verifier = VERIFIER() ) ;
00472 template <class OTHER>
00473 SimpleProperty ( const PropertyWithValue<OTHER>& right ) ;
00475 SimpleProperty ( const SimpleProperty& right ) ;
00477 virtual ~SimpleProperty() ;
00479 virtual SimpleProperty* clone() const ;
00481 SimpleProperty& operator=( const TYPE& value ) ;
00483 template <class OTHER>
00484 SimpleProperty& operator=( const PropertyWithValue<OTHER>& right ) ;
00485 };
00486
00488
00489 template <class TYPE,class VERIFIER>
00490 SimpleProperty<TYPE,VERIFIER>::SimpleProperty
00491 ( VERIFIER verifier )
00492 : PropertyWithVerifier<TYPE,VERIFIER>
00493 ( "" , new TYPE() , true , verifier )
00494 {}
00495
00497
00498 template <class TYPE,class VERIFIER>
00499 SimpleProperty<TYPE,VERIFIER>::SimpleProperty
00500 ( const TYPE& value ,
00501 VERIFIER verifier )
00502 : PropertyWithVerifier<TYPE,VERIFIER>
00503 ( "" , new TYPE(value) , true , verifier )
00504 {}
00505
00507
00508 template <class TYPE,class VERIFIER>
00509 SimpleProperty<TYPE,VERIFIER>::SimpleProperty
00510 ( const std::string& name ,
00511 const TYPE& value ,
00512 VERIFIER verifier )
00513 : PropertyWithVerifier<TYPE,VERIFIER>
00514 ( name , new TYPE(value) , true , verifier )
00515 {}
00516
00518
00519 template <class TYPE,class VERIFIER>
00520 template <class OTHER>
00521 SimpleProperty<TYPE,VERIFIER>::SimpleProperty
00522 ( const PropertyWithValue<OTHER>& right )
00523 : PropertyWithVerifier<TYPE,VERIFIER>
00524 ( right.name() , new TYPE( right.value() ) , true , VERIFIER() )
00525 {}
00526
00528
00529 template <class TYPE,class VERIFIER>
00530 SimpleProperty<TYPE,VERIFIER>::SimpleProperty
00531 ( const SimpleProperty& right )
00532 : PropertyWithVerifier<TYPE,VERIFIER>
00533 ( right.name() , new TYPE( right.value() ) , true , right.verifier() )
00534 {}
00535
00537
00538 template <class TYPE,class VERIFIER>
00539 SimpleProperty<TYPE,VERIFIER>::~SimpleProperty(){}
00540
00542
00543 template <class TYPE,class VERIFIER>
00544 inline
00545 SimpleProperty<TYPE,VERIFIER>*
00546 SimpleProperty<TYPE,VERIFIER>::clone() const
00547 { return new SimpleProperty(*this) ; }
00548
00550
00551 template <class TYPE,class VERIFIER>
00552 inline
00553 SimpleProperty<TYPE,VERIFIER>&
00554 SimpleProperty<TYPE,VERIFIER>::operator=( const TYPE& value )
00555 {
00556 PropertyWithVerifier<TYPE,VERIFIER>::operator=( value );
00557 return *this ;
00558 }
00559
00561
00562 template <class TYPE,class VERIFIER>
00563 template <class OTHER>
00564 inline
00565 SimpleProperty<TYPE,VERIFIER>&
00566 SimpleProperty<TYPE,VERIFIER>::operator=
00567 ( const PropertyWithValue<OTHER>& right )
00568 {
00569 PropertyWithVerifier<TYPE,VERIFIER>::operator=( right );
00570 return *this ;
00571 }
00572
00573
00574
00583
00584 template< class TYPE, class VERIFIER = NullVerifier<TYPE> >
00585 class SimplePropertyRef :
00586 public PropertyWithVerifier<TYPE,VERIFIER>
00587 {
00588 public:
00590 SimplePropertyRef
00591 ( const std::string& name ,
00592 TYPE& value ,
00593 VERIFIER verifier = VERIFIER() ) ;
00595 SimplePropertyRef ( const SimplePropertyRef& right ) ;
00597 virtual ~SimplePropertyRef() ;
00599 virtual SimplePropertyRef* clone() const ;
00601 SimplePropertyRef& operator=( const TYPE& value ) ;
00603 template <class OTHER>
00604 SimplePropertyRef& operator=( const PropertyWithValue<OTHER>& right ) ;
00605 private:
00606
00607 SimplePropertyRef() ;
00608 };
00609
00611
00612 template <class TYPE,class VERIFIER>
00613 SimplePropertyRef<TYPE,VERIFIER>::SimplePropertyRef
00614 ( const std::string& name ,
00615 TYPE& value ,
00616 VERIFIER verifier )
00617 : PropertyWithVerifier<TYPE,VERIFIER> ( name , &value , false , verifier )
00618 {}
00619
00621
00622 template <class TYPE,class VERIFIER>
00623 SimplePropertyRef<TYPE,VERIFIER>::SimplePropertyRef
00624 ( const SimplePropertyRef& right )
00625 : PropertyWithVerifier<TYPE,VERIFIER>
00626 ( right.name() , right.i_get() , false , right.verifier() )
00627 {}
00628
00630
00631 template <class TYPE,class VERIFIER>
00632 SimplePropertyRef<TYPE,VERIFIER>::~SimplePropertyRef(){}
00633
00635
00636 template <class TYPE,class VERIFIER>
00637 inline
00638 SimplePropertyRef<TYPE,VERIFIER>*
00639 SimplePropertyRef<TYPE,VERIFIER>::clone() const
00640 { return new SimplePropertyRef(*this) ; }
00641
00643
00644 template <class TYPE,class VERIFIER>
00645 inline
00646 SimplePropertyRef<TYPE,VERIFIER>&
00647 SimplePropertyRef<TYPE,VERIFIER>::operator=( const TYPE& value )
00648 {
00649 PropertyWithVerifier<TYPE,VERIFIER>::operator=( value ) ;
00650 return *this ;
00651 }
00652
00654
00655 template <class TYPE,class VERIFIER>
00656 template <class OTHER>
00657 inline
00658 SimplePropertyRef<TYPE,VERIFIER>&
00659 SimplePropertyRef<TYPE,VERIFIER>::operator=
00660 ( const PropertyWithValue<OTHER>& right )
00661 {
00662 PropertyWithVerifier<TYPE,VERIFIER>::operator=( right );
00663 return *this ;
00664 }
00665
00666
00667
00668
00669
00670
00671 typedef SimpleProperty< bool > BooleanProperty;
00672 typedef SimpleProperty< char > CharProperty;
00673 typedef SimpleProperty< signed char > SignedCharProperty;
00674 typedef SimpleProperty< unsigned char > UnsignedCharProperty;
00675 typedef SimpleProperty< short > ShortProperty;
00676 typedef SimpleProperty< unsigned short > UnsignedShortProperty;
00677 typedef SimpleProperty< int > IntegerProperty;
00678 typedef SimpleProperty< unsigned int > UnsignedIntegerProperty;
00679 typedef SimpleProperty< long > LongProperty;
00680 typedef SimpleProperty< unsigned long > UnsignedLongProperty;
00681 typedef SimpleProperty< long long> LongLongProperty;
00682 typedef SimpleProperty< unsigned long long> UnsignedLongLongProperty;
00683 typedef SimpleProperty< float > FloatProperty;
00684 typedef SimpleProperty< double > DoubleProperty;
00685 typedef SimpleProperty< long double > LongDoubleProperty;
00686
00687 typedef SimpleProperty< std::string > StringProperty;
00688
00689
00690
00691 typedef SimplePropertyRef< bool > BooleanPropertyRef;
00692 typedef SimplePropertyRef< char > CharPropertyRef;
00693 typedef SimplePropertyRef< signed char > SignedCharPropertyRef;
00694 typedef SimplePropertyRef< unsigned char > UnsignedCharPropertyRef;
00695 typedef SimplePropertyRef< short > ShortPropertyRef;
00696 typedef SimplePropertyRef< unsigned short > UnsignedShortPropertyRef;
00697 typedef SimplePropertyRef< int > IntegerPropertyRef;
00698 typedef SimplePropertyRef< unsigned int > UnsignedIntegerPropertyRef;
00699 typedef SimplePropertyRef< long > LongPropertyRef;
00700 typedef SimplePropertyRef< unsigned long > UnsignedLongPropertyRef;
00701 typedef SimplePropertyRef< long long > LongLongPropertyRef;
00702 typedef SimplePropertyRef< unsigned long long > UnsignedLongLongPropertyRef;
00703 typedef SimplePropertyRef< float > FloatPropertyRef;
00704 typedef SimplePropertyRef< double > DoublePropertyRef;
00705 typedef SimplePropertyRef< long double > LongDoublePropertyRef;
00706
00707 typedef SimplePropertyRef< std::string > StringPropertyRef;
00708
00709
00710
00711 typedef SimpleProperty< std::vector< bool > > BooleanArrayProperty;
00712 typedef SimpleProperty< std::vector< char > > CharArrayProperty;
00713 typedef SimpleProperty< std::vector< signed char > > SignedCharArrayProperty;
00714 typedef SimpleProperty< std::vector< unsigned char > > UnsignedCharArrayProperty;
00715 typedef SimpleProperty< std::vector< short > > ShortArrayProperty;
00716 typedef SimpleProperty< std::vector< unsigned short > > UnsignedShortArrayProperty;
00717 typedef SimpleProperty< std::vector< int > > IntegerArrayProperty;
00718 typedef SimpleProperty< std::vector< unsigned int > > UnsignedIntegerArrayProperty;
00719 typedef SimpleProperty< std::vector< long > > LongArrayProperty;
00720 typedef SimpleProperty< std::vector< unsigned long > > UnsignedLongArrayProperty;
00721 typedef SimpleProperty< std::vector< long long > > LongLongArrayProperty;
00722 typedef SimpleProperty< std::vector< unsigned long long > > UnsignedLongLongArrayProperty;
00723 typedef SimpleProperty< std::vector< float > > FloatArrayProperty;
00724 typedef SimpleProperty< std::vector< double > > DoubleArrayProperty;
00725 typedef SimpleProperty< std::vector< long double > > LongDoubleArrayProperty;
00726
00727 typedef SimpleProperty< std::vector< std::string > > StringArrayProperty;
00728
00729
00730
00731 typedef SimplePropertyRef< std::vector< bool > > BooleanArrayPropertyRef;
00732 typedef SimplePropertyRef< std::vector< char > > CharArrayPropertyRef;
00733 typedef SimplePropertyRef< std::vector< signed char > > SignedCharArrayPropertyRef;
00734 typedef SimplePropertyRef< std::vector< unsigned char > > UnsignedCharArrayPropertyRef;
00735 typedef SimplePropertyRef< std::vector< short > > ShortArrayPropertyRef;
00736 typedef SimplePropertyRef< std::vector< unsigned short > > UnsignedShortArrayPropertyRef;
00737 typedef SimplePropertyRef< std::vector< int > > IntegerArrayPropertyRef;
00738 typedef SimplePropertyRef< std::vector< unsigned int > > UnsignedIntegerArrayPropertyRef;
00739 typedef SimplePropertyRef< std::vector< long > > LongArrayPropertyRef;
00740 typedef SimplePropertyRef< std::vector< unsigned long > > UnsignedLongArrayPropertyRef;
00741 typedef SimplePropertyRef< std::vector< long long > > LongLongArrayPropertyRef;
00742 typedef SimplePropertyRef< std::vector< unsigned long long > > UnsignedLongLongArrayPropertyRef;
00743 typedef SimplePropertyRef< std::vector< float > > FloatArrayPropertyRef;
00744 typedef SimplePropertyRef< std::vector< double > > DoubleArrayPropertyRef;
00745 typedef SimplePropertyRef< std::vector< long double > > LongDoubleArrayPropertyRef;
00746
00747 typedef SimplePropertyRef< std::vector< std::string > > StringArrayPropertyRef;
00748
00749
00750 class GaudiHandleBase;
00751
00752 class GAUDI_API GaudiHandleProperty : public Property {
00753 public:
00754 GaudiHandleProperty( const std::string& name, GaudiHandleBase& ref );
00755
00756 GaudiHandleProperty& operator=( const GaudiHandleBase& value );
00757
00758 virtual GaudiHandleProperty* clone() const;
00759
00760 virtual bool load( Property& destination ) const;
00761
00762 virtual bool assign( const Property& source );
00763
00764 virtual std::string toString() const;
00765
00766 virtual StatusCode fromString(const std::string& s);
00767
00768 const GaudiHandleBase& value() const;
00769
00770 bool setValue( const GaudiHandleBase& value );
00771
00772 private:
00775 GaudiHandleBase* m_pValue;
00776 };
00777
00778
00779
00780
00781
00782 inline GaudiHandleProperty& GaudiHandleProperty::operator=( const GaudiHandleBase& value ) {
00783 setValue( value );
00784 return *this;
00785 }
00786
00787 inline GaudiHandleProperty* GaudiHandleProperty::clone() const {
00788 return new GaudiHandleProperty( *this );
00789 }
00790
00791 inline bool GaudiHandleProperty::load( Property& destination ) const {
00792 return destination.assign( *this );
00793 }
00794
00795 inline bool GaudiHandleProperty::assign( const Property& source ) {
00796 return fromString( source.toString() ).isSuccess();
00797 }
00798
00799 inline const GaudiHandleBase& GaudiHandleProperty::value() const {
00800 useReadHandler();
00801 return *m_pValue;
00802 }
00803
00804
00805
00806 class GaudiHandleArrayBase;
00807
00808 class GAUDI_API GaudiHandleArrayProperty : public Property {
00809 public:
00810
00811 GaudiHandleArrayProperty( const std::string& name, GaudiHandleArrayBase& ref );
00812
00813 GaudiHandleArrayProperty& operator=( const GaudiHandleArrayBase& value );
00814
00815 virtual GaudiHandleArrayProperty* clone() const;
00816
00817 virtual bool load( Property& destination ) const;
00818
00819 virtual bool assign( const Property& source );
00820
00821 virtual std::string toString() const;
00822
00823 virtual StatusCode fromString(const std::string& s);
00824
00825 const GaudiHandleArrayBase& value() const;
00826
00827 bool setValue( const GaudiHandleArrayBase& value );
00828
00829 private:
00832 GaudiHandleArrayBase* m_pValue;
00833
00834 };
00835
00836
00837
00838
00839
00840 inline GaudiHandleArrayProperty& GaudiHandleArrayProperty::operator=( const GaudiHandleArrayBase& value ) {
00841 setValue( value );
00842 return *this;
00843 }
00844
00845 inline GaudiHandleArrayProperty* GaudiHandleArrayProperty::clone() const {
00846 return new GaudiHandleArrayProperty( *this );
00847 }
00848
00849 inline bool GaudiHandleArrayProperty::load( Property& destination ) const {
00850 return destination.assign( *this );
00851 }
00852
00853 inline bool GaudiHandleArrayProperty::assign( const Property& source ) {
00854 return fromString( source.toString() ) != 0;
00855 }
00856
00857 inline const GaudiHandleArrayBase& GaudiHandleArrayProperty::value() const {
00858 useReadHandler();
00859 return *m_pValue;
00860 }
00861
00862
00863 namespace Gaudi
00864 {
00865 namespace Utils
00866 {
00867
00885 GAUDI_API bool hasProperty ( const IProperty* p , const std::string& name ) ;
00886
00904 GAUDI_API bool hasProperty ( const IInterface* p , const std::string& name ) ;
00905
00923 GAUDI_API Property* getProperty
00924 ( const IProperty* p , const std::string& name ) ;
00925
00943 GAUDI_API Property* getProperty
00944 ( const IInterface* p , const std::string& name ) ;
00945
00968 GAUDI_API bool hasProperty
00969 ( const std::vector<const Property*>* p ,
00970 const std::string& name ) ;
00971
00994 GAUDI_API const Property* getProperty
00995 ( const std::vector<const Property*>* p ,
00996 const std::string& name ) ;
00997
01021 template <class TYPE>
01022 StatusCode setProperty
01023 ( IProperty* component ,
01024 const std::string& name ,
01025 const TYPE& value ,
01026 const std::string& doc ) ;
01027
01050 template <class TYPE>
01051 StatusCode setProperty
01052 ( IProperty* component ,
01053 const std::string& name ,
01054 const TYPE& value )
01055 { return setProperty ( component , name , value , std::string() ) ; }
01056
01070 GAUDI_API StatusCode setProperty
01071 ( IProperty* component ,
01072 const std::string& name ,
01073 const std::string& value ,
01074 const std::string& doc = "" ) ;
01075
01089 GAUDI_API StatusCode setProperty
01090 ( IProperty* component ,
01091 const std::string& name ,
01092 const char* value ,
01093 const std::string& doc = "" ) ;
01094
01108 template <unsigned N>
01109 StatusCode setProperty
01110 ( IProperty* component ,
01111 const std::string& name ,
01112 const char (&value)[N] ,
01113 const std::string& doc = "" )
01114 {
01115 if ( 0 == component ) { return StatusCode::FAILURE ; }
01116 const std::string val = std::string ( value , value + N ) ;
01117 return setProperty ( component , name , val , doc ) ;
01118 }
01119
01150 template <class TYPE>
01151 StatusCode setProperty
01152 ( IProperty* component ,
01153 const std::string& name ,
01154 const TYPE& value ,
01155 const std::string& doc )
01156 {
01157 if ( 0 == component ) { return StatusCode::FAILURE ; }
01158 if ( !hasProperty ( component , name ) ) { return StatusCode::FAILURE ; }
01159 const std::string val = Gaudi::Utils::toString ( value ) ;
01160 return Gaudi::Utils::setProperty ( component , name , val , doc ) ;
01161 }
01162
01184 GAUDI_API StatusCode setProperty
01185 ( IProperty* component ,
01186 const std::string& name ,
01187 const Property* property ,
01188 const std::string& doc = "" ) ;
01189
01211 GAUDI_API StatusCode setProperty
01212 ( IProperty* component ,
01213 const std::string& name ,
01214 const Property& property ,
01215 const std::string& doc = "" ) ;
01216
01239 template <class TYPE>
01240 StatusCode setProperty
01241 ( IProperty* component ,
01242 const std::string& name ,
01243 const SimpleProperty<TYPE>& value ,
01244 const std::string& doc = "" )
01245 {
01246 const Property* property = &value ;
01247 return setProperty ( component , name , property , doc ) ;
01248 }
01249
01270 template <class TYPE>
01271 StatusCode setProperty
01272 ( IInterface* component ,
01273 const std::string& name ,
01274 const TYPE& value ,
01275 const std::string& doc = "" )
01276 {
01277 if ( 0 == component ) { return StatusCode::FAILURE ; }
01278 SmartIF<IProperty> property ( component ) ;
01279 if ( !property ) { return StatusCode::FAILURE ; }
01280 return setProperty ( property , name , value , doc ) ;
01281 }
01282
01295 GAUDI_API StatusCode setProperty
01296 ( IInterface* component ,
01297 const std::string& name ,
01298 const std::string& value ,
01299 const std::string& doc = "" ) ;
01300
01313 GAUDI_API StatusCode setProperty
01314 ( IInterface* component ,
01315 const std::string& name ,
01316 const char* value ,
01317 const std::string& doc = "" ) ;
01318
01332 template <unsigned N>
01333 StatusCode setProperty
01334 ( IInterface* component ,
01335 const std::string& name ,
01336 const char (&value)[N] ,
01337 const std::string& doc = "" )
01338 {
01339 if ( 0 == component ) { return StatusCode::FAILURE ; }
01340 const std::string val = std::string ( value , value + N ) ;
01341 return setProperty ( component , name , val , doc ) ;
01342 }
01343
01365 GAUDI_API StatusCode setProperty
01366 ( IInterface* component ,
01367 const std::string& name ,
01368 const Property* property ,
01369 const std::string& doc = "" ) ;
01370
01392 GAUDI_API StatusCode setProperty
01393 ( IInterface* component ,
01394 const std::string& name ,
01395 const Property& property ,
01396 const std::string& doc = "" ) ;
01397
01420 template <class TYPE>
01421 StatusCode
01422 setProperty
01423 ( IInterface* component ,
01424 const std::string& name ,
01425 const SimpleProperty<TYPE>& value ,
01426 const std::string& doc = "" )
01427 {
01428 const Property* property = &value ;
01429 return setProperty ( component , name , property , doc ) ;
01430 }
01431
01432 }
01433 }
01434
01435
01436
01437
01438
01439 #endif // GAUDIKERNEL_PROPERTY_H
01440