Property.h
Go to the documentation of this file.
1 // $Id: Property.h,v 1.26 2008/10/27 16:41:34 marcocle Exp $
2 // ============================================================================
3 // CVS tag $Name: $
4 // ============================================================================
5 #ifndef GAUDIKERNEL_PROPERTY_H
6 #define GAUDIKERNEL_PROPERTY_H
7 // ============================================================================
8 // STD & STL
9 // ============================================================================
10 #include <string>
11 #include <stdexcept>
12 #include <typeinfo>
13 // ============================================================================
14 // Application C++ Class Headers
15 // ============================================================================
16 #include "GaudiKernel/Kernel.h"
17 #include "GaudiKernel/PropertyVerifier.h"
18 #include "GaudiKernel/Parsers.h"
19 #include "GaudiKernel/ToStream.h"
20 #include "GaudiKernel/SmartIF.h"
21 // ============================================================================
22 
23 // ============================================================================
24 class Property ;
26 class IProperty ;
27 class IInterface ;
28 // ============================================================================
29 
30 // ============================================================================
32 // ============================================================================
33 GAUDI_API std::ostream& operator<<(std::ostream& stream, const Property& prop);
34 // ============================================================================
43 class GAUDI_API Property
44 {
45 public:
47  const std::string& name () const { return m_name ; }
49  const std::string& documentation() const { return m_documentation; }
51  const std::type_info* type_info () const { return m_typeinfo ; }
53  std::string type () const { return m_typeinfo->name() ; }
55  virtual bool load ( Property& dest ) const = 0 ;
57  virtual bool assign ( const Property& source ) = 0 ;
58 public:
60  virtual std::string toString () const = 0 ;
62  virtual void toStream(std::ostream& out) const = 0;
64  virtual StatusCode fromString ( const std::string& value ) = 0 ;
65 public:
67  const PropertyCallbackFunctor* readCallBack () const ;
69  const PropertyCallbackFunctor* updateCallBack () const ;
71  virtual void declareReadHandler ( PropertyCallbackFunctor* pf ) ;
73  virtual void declareUpdateHandler ( PropertyCallbackFunctor* pf ) ;
74  template< class HT >
75  void declareReadHandler
76  ( void ( HT::* MF ) ( Property& ) , HT* instance ) ;
77  template< class HT >
78  void declareUpdateHandler
79  ( void ( HT::* MF ) ( Property& ) , HT* instance ) ;
81  virtual void useReadHandler () const ;
83  virtual bool useUpdateHandler () ;
84 public:
86  virtual ~Property() ;
88  virtual Property* clone () const = 0 ;
90  void setName ( const std::string& value ) { m_name = value ; }
92  void setDocumentation( const std::string& documentation ) {
93  m_documentation = documentation; }
95  virtual std::ostream& fillStream ( std::ostream& ) const ;
96 protected:
98  Property
99  ( const std::type_info& type ,
100  const std::string& name = "" ) ;
102  Property
103  ( const std::string& name ,
104  const std::type_info& type ) ;
106  Property ( const Property& right ) ;
108  Property& operator=( const Property& right ) ;
109 private:
110  // the default constructor is disabled
111  Property() ;
112 private:
113  // property name
114  std::string m_name ;
115  // property doc string
116  std::string m_documentation;
117  // property type
118  const std::type_info* m_typeinfo ;
119 protected:
120  // call back functor for reading
121  mutable PropertyCallbackFunctor* m_readCallBack ;
122  // call back functor for update
123  PropertyCallbackFunctor* m_updateCallBack ;
124 };
125 // ============================================================================
126 #include "GaudiKernel/PropertyCallbackFunctor.h"
127 // ============================================================================
128 template< class HT >
130 ( void ( HT::* MF ) ( Property& ) , HT* obj )
132 // ============================================================================
133 template< class HT >
135 ( void ( HT::* MF ) ( Property& ) , HT* obj )
137 // ============================================================================
145 // ============================================================================
146 template <class TYPE>
147 class PropertyWithValue : public Property
148 {
149 public:
150  // ==========================================================================
154  typedef typename Traits::PVal PVal ;
155  // ==========================================================================
156 protected:
157  // ==========================================================================
159  inline PropertyWithValue
160  ( const std::string& name ,
161  PVal value ,
162  const bool owner ) ;
164  inline PropertyWithValue ( const PropertyWithValue& rhs ) ;
166  template <class OTHER>
167  inline PropertyWithValue ( const PropertyWithValue<OTHER>& right ) ;
169  virtual inline ~PropertyWithValue() ;
171  PropertyWithValue& operator=( const TYPE& value ) ;
172  // assignment operator (don't let the compiler generate a buggy one)
174  // assignment operator
175  template <class OTHER>
177  // ==========================================================================
178 public:
179  // ==========================================================================
181  operator const TYPE& () const { return value() ;}
183  inline const TYPE& value() const ;
184  // ==========================================================================
185 public:
186  // ==========================================================================
188  virtual bool setValue ( const TYPE& value ) = 0 ;
190  virtual bool assign ( const Property& source ) ;
192  virtual bool load ( Property& dest ) const ;
194  virtual StatusCode fromString ( const std::string& s ) ;
196  virtual std::string toString () const ;
198  virtual void toStream (std::ostream& out) const ;
199  // ==========================================================================
200 protected:
201  // ==========================================================================
203  inline void i_set ( const TYPE& value ) {
204  Traits::assign(*m_value, value);
205  }
207  inline PVal i_get () const {
208  return m_value;
209  }
210  // ==========================================================================
211 private:
212  // ==========================================================================
214  PVal m_value ; // the actual property value
216  bool m_own ; // owner of the storage
217  // ==========================================================================
218 };
219 
220 // ============================================================================
222 // ============================================================================
223 template <class TYPE>
224 inline
226 ( const std::string& name ,
227  PVal value ,
228  const bool own )
229  : Property ( typeid( TYPE ) , name )
230  , m_value ( value )
231  , m_own ( own )
232 {}
233 // ============================================================================
234 // copy constructor
235 // ============================================================================
236 template <class TYPE>
238 ( const PropertyWithValue& right )
239  : Property( right )
240  , m_value ( right.m_value )
241  , m_own ( right.m_own )
242 {
243  m_value = Traits::copy ( right.value() , m_own ) ;
244 }
245 // ============================================================================
246 // "copy" constructor form any other type
247 // ============================================================================
248 template <class TYPE>
249 template <class OTHER>
251 ( const PropertyWithValue<OTHER>& right )
252  : Property( right )
253  , m_value ( right.m_value )
254  , m_own ( right.m_own )
255 {
256  m_value = Traits::copy ( right.value() , m_own ) ;
257 }
258 // ============================================================================
260 // ============================================================================
261 template <class TYPE>
263 {
264  Traits::dele ( m_value , m_own ) ;
265  m_value = 0 ;
266 }
267 // ============================================================================
269 // ============================================================================
270 template <class TYPE>
273 {
274  if ( !setValue ( value ) )
275  { throw std::out_of_range( "Value not verified" ) ; }
276  return *this ;
277 }
278 // ============================================================================
280 // ============================================================================
281 template <class TYPE>
282 inline bool
284 {
285  // 1) Is the property of "the same" type?
286  const PropertyWithValue<TYPE>* p =
287  dynamic_cast<const PropertyWithValue<TYPE>*> ( &source ) ;
288  if ( 0 != p ) { return setValue ( p->value() ) ; } // RETURN
289  // 2) Else use the string representation
290  return this->fromString( source.toString() ).isSuccess() ;
291 }
292 // ============================================================================
294 // ============================================================================
295 template <class TYPE>
296 inline bool
298 {
299  // delegate to the 'opposite' method ;
300  return dest.assign( *this ) ;
301 }
302 // ============================================================================
304 // ============================================================================
305 template <class TYPE>
306 inline std::string
308 {
309  useReadHandler();
310  return Gaudi::Utils::toString( *m_value ) ;
311 }
312 // ============================================================================
314 // ============================================================================
315 template <class TYPE>
316 inline void
317 PropertyWithValue<TYPE>::toStream (std::ostream& out) const
318 {
319  useReadHandler();
320  Gaudi::Utils::toStream( *m_value, out ) ;
321 }
322 // ============================================================================
324 // ============================================================================
325 template <class TYPE>
326 inline StatusCode
327 PropertyWithValue<TYPE>::fromString ( const std::string& source )
328 {
329  TYPE tmp ;
330  StatusCode sc = Gaudi::Parsers::parse ( tmp , source ) ;
331  if ( sc.isFailure() ) { return sc ; }
332  return setValue ( tmp ) ? StatusCode::SUCCESS : StatusCode::FAILURE ;
333 }
334 // ============================================================================
336 // ============================================================================
337 template <>
338 inline std::string
340 {
341  useReadHandler();
342  return this->value() ;
343 }
344 // ============================================================================
345 template <>
346 inline bool PropertyWithValue<std::string>::assign ( const Property& source )
347 { return this->fromString( source.toString() ).isSuccess() ; }
348 // ============================================================================
349 
350 // ============================================================================
352 // ============================================================================
353 template <class TYPE>
354 inline const TYPE&
356 { useReadHandler() ; return *m_value ; }
357 // ============================================================================
358 // assignment operator
359 // ============================================================================
360 template <class TYPE>
362 ( const PropertyWithValue& right )
363 {
364  // assign the base class
365  Property::operator=( right ) ;
366  // assign the value
368  return *this ;
369 }
370 // ============================================================================
371 // templated assignment operator
372 // ============================================================================
373 template <class TYPE>
374 template <class OTHER>
375 PropertyWithValue<TYPE>& PropertyWithValue<TYPE>::operator=
376 ( const PropertyWithValue<OTHER>& right )
377 {
378  // assign the base class
379  Property::operator=( right ) ;
380  // assign the value
382  return *this ;
383 }
384 // ============================================================================
385 
386 // ============================================================================
394 // ============================================================================
395 template<class TYPE,class VERIFIER>
397  : public PropertyWithValue<TYPE>
398 {
399 protected:
400  // ==========================================================================
403  ( const std::string& name ,
405  const bool owner ,
406  const VERIFIER& verifier )
407  : PropertyWithValue<TYPE> ( name , value , owner )
408  , m_verifier ( verifier )
409  {}
411  virtual ~PropertyWithVerifier() {}
412  // ==========================================================================
413 public:
414  // ==========================================================================
415  inline VERIFIER& verifier() { return m_verifier ; }
416  inline const VERIFIER& verifier() const { return m_verifier ; }
418  bool set( const TYPE& value ) ;
420  virtual bool setValue( const TYPE& value ) { return set( value ) ; }
422  template <class OTHER,class OTHERVERIFIER>
423  PropertyWithVerifier& operator=
426  template <class OTHER>
427  PropertyWithVerifier& operator=( const PropertyWithValue<OTHER>& right ) ;
429  PropertyWithVerifier& operator=( const TYPE& right ) ;
430  // ==========================================================================
431 private:
432  // ==========================================================================
437  // ==========================================================================
438 private:
439  // ==========================================================================
441  VERIFIER m_verifier ; // the verifier itself
442  // ==========================================================================
443 } ;
444 // ============================================================================
446 // ============================================================================
447 template <class TYPE,class VERIFIER>
448 inline bool
449 PropertyWithVerifier<TYPE,VERIFIER>::set( const TYPE& value )
450 {
452  if ( !m_verifier.isValid( &value ) ) { return false ; }
454  this->i_set( value ) ;
456  return this->useUpdateHandler() ;
457 }
458 // ============================================================================
460 // ============================================================================
461 template <class TYPE,class VERIFIER>
464 {
466  return *this ;
467 }
468 // ============================================================================
470 // ============================================================================
471 template <class TYPE,class VERIFIER>
472 template <class OTHER>
475 {
477  return *this ;
478 }
479 // ============================================================================
481 // ============================================================================
482 template <class TYPE,class VERIFIER>
483 template <class OTHER,class OTHERVERIFIER>
487 {
489  return *this ;
490 }
491 // ============================================================================
492 
493 // ============================================================================
503 // ============================================================================
504 template <class TYPE,class VERIFIER = BoundedVerifier<TYPE> >
505 class SimpleProperty
506  : public PropertyWithVerifier<TYPE,VERIFIER>
507 {
508 protected:
509  // ==========================================================================
511  // ==========================================================================
512 public:
513  // ==========================================================================
516  ( VERIFIER verifier = VERIFIER() ) ;
519  ( const TYPE& value ,
520  VERIFIER verifier = VERIFIER() ) ;
523  ( const std::string& name ,
524  const TYPE& value ,
525  VERIFIER verifier = VERIFIER() ) ;
527  template <class OTHER>
528  SimpleProperty ( const PropertyWithValue<OTHER>& right ) ;
530  SimpleProperty ( const SimpleProperty& right ) ;
532  virtual ~SimpleProperty() ;
534  virtual SimpleProperty* clone() const ;
536  SimpleProperty& operator=( const TYPE& value ) ;
538  template <class OTHER>
539  SimpleProperty& operator=( const PropertyWithValue<OTHER>& right ) ;
540  // ==========================================================================
541 };
542 // ============================================================================
544 // ============================================================================
545 template <class TYPE,class VERIFIER>
547 ( VERIFIER verifier )
548  : PropertyWithVerifier<TYPE,VERIFIER>
549 ( "" , Traits::new_() , true , verifier )
550 {}
551 // ============================================================================
553 // ============================================================================
554 template <class TYPE,class VERIFIER>
556 ( const TYPE& value ,
557  VERIFIER verifier )
558  : PropertyWithVerifier<TYPE,VERIFIER>
559 ( "" , Traits::new_(value) , true , verifier )
560 {}
561 // ============================================================================
563 // ============================================================================
564 template <class TYPE,class VERIFIER>
566 ( const std::string& name ,
567  const TYPE& value ,
568  VERIFIER verifier )
569  : PropertyWithVerifier<TYPE,VERIFIER>
570 ( name , Traits::new_(value) , true , verifier )
571 {}
572 // ============================================================================
574 // ============================================================================
575 template <class TYPE,class VERIFIER>
576 template <class OTHER>
578 ( const PropertyWithValue<OTHER>& right )
579  : PropertyWithVerifier<TYPE,VERIFIER>
580 ( right.name() , Traits::new_( right.value() ) , true , VERIFIER() )
581 {}
582 // ============================================================================
584 // ============================================================================
585 template <class TYPE,class VERIFIER>
587 ( const SimpleProperty& right )
588  : PropertyWithVerifier<TYPE,VERIFIER>
589 ( right.name() , Traits::new_( right.value() ) , true , right.verifier() )
590 {}
591 // ============================================================================
593 // ============================================================================
594 template <class TYPE,class VERIFIER>
596 // ============================================================================
598 // ============================================================================
599 template <class TYPE,class VERIFIER>
600 inline
603 { return new SimpleProperty(*this) ; }
604 // ============================================================================
606 // ============================================================================
607 template <class TYPE,class VERIFIER>
608 inline
610 SimpleProperty<TYPE,VERIFIER>::operator=( const TYPE& value )
611 {
613  return *this ;
614 }
615 // ============================================================================
617 // ============================================================================
618 template <class TYPE,class VERIFIER>
619 template <class OTHER>
620 inline
623 ( const PropertyWithValue<OTHER>& right )
624 {
626  return *this ;
627 }
628 // ============================================================================
629 
630 // ============================================================================
639 // ============================================================================
640 template< class TYPE, class VERIFIER = NullVerifier<TYPE> >
641 class SimplePropertyRef :
642  public PropertyWithVerifier<TYPE,VERIFIER>
643 {
644 public:
647  ( const std::string& name ,
648  TYPE& value ,
649  VERIFIER verifier = VERIFIER() ) ;
651  SimplePropertyRef ( const SimplePropertyRef& right ) ;
653  virtual ~SimplePropertyRef() ;
655  virtual SimplePropertyRef* clone() const ;
657  SimplePropertyRef& operator=( const TYPE& value ) ;
659  template <class OTHER>
660  SimplePropertyRef& operator=( const PropertyWithValue<OTHER>& right ) ;
661 private:
662  // the default constructor is disabled
664 };
665 // ============================================================================
667 // ============================================================================
668 template <class TYPE,class VERIFIER>
670 ( const std::string& name ,
671  TYPE& value ,
672  VERIFIER verifier )
673  : PropertyWithVerifier<TYPE,VERIFIER> ( name , &value , false , verifier )
674 {}
675 // ============================================================================
677 // ============================================================================
678 template <class TYPE,class VERIFIER>
680 ( const SimplePropertyRef& right )
681  : PropertyWithVerifier<TYPE,VERIFIER>
682 ( right.name() , right.i_get() , false , right.verifier() )
683 {}
684 // ============================================================================
686 // ============================================================================
687 template <class TYPE,class VERIFIER>
689 // ============================================================================
691 // ============================================================================
692 template <class TYPE,class VERIFIER>
693 inline
696 { return new SimplePropertyRef(*this) ; }
697 // ============================================================================
699 // ============================================================================
700 template <class TYPE,class VERIFIER>
701 inline
704 {
706  return *this ;
707 }
708 // ============================================================================
710 // ============================================================================
711 template <class TYPE,class VERIFIER>
712 template <class OTHER>
713 inline
716 ( const PropertyWithValue<OTHER>& right )
717 {
719  return *this ;
720 }
721 // ============================================================================
722 
723 
724 
725 
726 // Typedef Properties for built-in types
742 
744 
745 
746 // Typedef PropertyRefs for built-in types
762 
764 
765 
766 // Typedef "Arrays" of Properties for built-in types
782 
784 
785 
786 // Typedef "Arrays" of PropertyRefs for built-in types
802 
804 
805 // pre-declaration is sufficient here
806 class GaudiHandleBase;
807 
808 class GAUDI_API GaudiHandleProperty : public Property {
809 public:
810  GaudiHandleProperty( const std::string& name, GaudiHandleBase& ref );
811 
812  GaudiHandleProperty& operator=( const GaudiHandleBase& value );
813 
814  virtual GaudiHandleProperty* clone() const;
815 
816  virtual bool load( Property& destination ) const;
817 
818  virtual bool assign( const Property& source );
819 
820  virtual std::string toString() const;
821 
822  virtual void toStream(std::ostream& out) const;
823 
824  virtual StatusCode fromString(const std::string& s);
825 
826  const GaudiHandleBase& value() const;
827 
828  bool setValue( const GaudiHandleBase& value );
829 
830 private:
833  GaudiHandleBase* m_pValue;
834 };
835 
836 // implementation in header file only where the GaudiHandleBase class
837 // definition is not needed. The rest goes into the .cpp file.
838 // The goal is to decouple the header files, to avoid that the whole
839 // world depends on GaudiHandle.h
841  setValue( value );
842  return *this;
843 }
844 
846  return new GaudiHandleProperty( *this );
847 }
848 
849 inline bool GaudiHandleProperty::load( Property& destination ) const {
850  return destination.assign( *this );
851 }
852 
853 inline bool GaudiHandleProperty::assign( const Property& source ) {
854  return fromString( source.toString() ).isSuccess();
855 }
856 
857 inline const GaudiHandleBase& GaudiHandleProperty::value() const {
858  useReadHandler();
859  return *m_pValue;
860 }
861 
862 
863 // pre-declaration is sufficient here
865 
867 public:
868 
869  GaudiHandleArrayProperty( const std::string& name, GaudiHandleArrayBase& ref );
870 
871  GaudiHandleArrayProperty& operator=( const GaudiHandleArrayBase& value );
872 
873  virtual GaudiHandleArrayProperty* clone() const;
874 
875  virtual bool load( Property& destination ) const;
876 
877  virtual bool assign( const Property& source );
878 
879  virtual std::string toString() const;
880 
881  virtual void toStream(std::ostream& out) const;
882 
883  virtual StatusCode fromString(const std::string& s);
884 
885  const GaudiHandleArrayBase& value() const;
886 
887  bool setValue( const GaudiHandleArrayBase& value );
888 
889 private:
892  GaudiHandleArrayBase* m_pValue;
893 
894 };
895 
896 // implementation in header file only where the GaudiHandleBase class
897 // definition is not needed. The rest goes into the .cpp file.
898 // The goal is to decouple the header files, to avoid that the whole
899 // world depends on GaudiHandle.h
901  setValue( value );
902  return *this;
903 }
904 
906  return new GaudiHandleArrayProperty( *this );
907 }
908 
909 inline bool GaudiHandleArrayProperty::load( Property& destination ) const {
910  return destination.assign( *this );
911 }
912 
913 inline bool GaudiHandleArrayProperty::assign( const Property& source ) {
914  return fromString( source.toString() ) != 0;
915 }
916 
918  useReadHandler();
919  return *m_pValue;
920 }
921 
922 
923 namespace Gaudi
924 {
925  namespace Utils
926  {
927  // ========================================================================
945  GAUDI_API bool hasProperty ( const IProperty* p , const std::string& name ) ;
946  // ========================================================================
964  GAUDI_API bool hasProperty ( const IInterface* p , const std::string& name ) ;
965  // ========================================================================
984  ( const IProperty* p , const std::string& name ) ;
985  // ========================================================================
1004  ( const IInterface* p , const std::string& name ) ;
1005  // ========================================================================
1028  GAUDI_API bool hasProperty
1029  ( const std::vector<const Property*>* p ,
1030  const std::string& name ) ;
1031  // ========================================================================
1055  ( const std::vector<const Property*>* p ,
1056  const std::string& name ) ;
1057  // ========================================================================
1081  template <class TYPE>
1083  ( IProperty* component ,
1084  const std::string& name ,
1085  const TYPE& value ,
1086  const std::string& doc ) ;
1087  // ========================================================================
1110  template <class TYPE>
1112  ( IProperty* component ,
1113  const std::string& name ,
1114  const TYPE& value )
1115  { return setProperty ( component , name , value , std::string() ) ; }
1116  // ========================================================================
1131  ( IProperty* component ,
1132  const std::string& name ,
1133  const std::string& value ,
1134  const std::string& doc = "" ) ;
1135  // ========================================================================
1150  ( IProperty* component ,
1151  const std::string& name ,
1152  const char* value ,
1153  const std::string& doc = "" ) ;
1154  // ========================================================================
1168  template <unsigned N>
1170  ( IProperty* component ,
1171  const std::string& name ,
1172  const char (&value)[N] ,
1173  const std::string& doc = "" )
1174  {
1175  if ( 0 == component ) { return StatusCode::FAILURE ; }
1176  const std::string val = std::string ( value , value + N ) ;
1177  return setProperty ( component , name , val , doc ) ;
1178  }
1179  // ========================================================================
1210  template <class TYPE>
1212  ( IProperty* component ,
1213  const std::string& name ,
1214  const TYPE& value ,
1215  const std::string& doc )
1216  {
1217  if ( 0 == component ) { return StatusCode::FAILURE ; } // RETURN
1218  if ( !hasProperty ( component , name ) ) { return StatusCode::FAILURE ; }
1219  const std::string val = Gaudi::Utils::toString ( value ) ;
1220  return Gaudi::Utils::setProperty ( component , name , val , doc ) ;
1221  }
1222  // ========================================================================
1245  ( IProperty* component ,
1246  const std::string& name ,
1247  const Property* property ,
1248  const std::string& doc = "" ) ;
1249  // ========================================================================
1272  ( IProperty* component ,
1273  const std::string& name ,
1274  const Property& property ,
1275  const std::string& doc = "" ) ;
1276  // ========================================================================
1299  template <class TYPE>
1301  ( IProperty* component ,
1302  const std::string& name ,
1303  const SimpleProperty<TYPE>& value ,
1304  const std::string& doc = "" )
1305  {
1306  const Property* property = &value ;
1307  return setProperty ( component , name , property , doc ) ;
1308  }
1309  // ========================================================================
1330  template <class TYPE>
1332  ( IInterface* component ,
1333  const std::string& name ,
1334  const TYPE& value ,
1335  const std::string& doc = "" )
1336  {
1337  if ( 0 == component ) { return StatusCode::FAILURE ; }
1338  SmartIF<IProperty> property ( component ) ;
1339  if ( !property ) { return StatusCode::FAILURE ; }
1340  return setProperty ( property , name , value , doc ) ;
1341  }
1342  // ========================================================================
1356  ( IInterface* component ,
1357  const std::string& name ,
1358  const std::string& value ,
1359  const std::string& doc = "" ) ;
1360  // ========================================================================
1374  ( IInterface* component ,
1375  const std::string& name ,
1376  const char* value ,
1377  const std::string& doc = "" ) ;
1378  // ========================================================================
1392  template <unsigned N>
1394  ( IInterface* component ,
1395  const std::string& name ,
1396  const char (&value)[N] ,
1397  const std::string& doc = "" )
1398  {
1399  if ( 0 == component ) { return StatusCode::FAILURE ; }
1400  const std::string val = std::string ( value , value + N ) ;
1401  return setProperty ( component , name , val , doc ) ;
1402  }
1403  // ========================================================================
1426  ( IInterface* component ,
1427  const std::string& name ,
1428  const Property* property ,
1429  const std::string& doc = "" ) ;
1430  // ========================================================================
1453  ( IInterface* component ,
1454  const std::string& name ,
1455  const Property& property ,
1456  const std::string& doc = "" ) ;
1457  // ========================================================================
1480  template <class TYPE>
1481  StatusCode
1482  setProperty
1483  ( IInterface* component ,
1484  const std::string& name ,
1485  const SimpleProperty<TYPE>& value ,
1486  const std::string& doc = "" )
1487  {
1488  const Property* property = &value ;
1489  return setProperty ( component , name , property , doc ) ;
1490  }
1491  // ========================================================================
1492  } // end of namespace Gaudi::Utils
1493 } // end of namespace Gaudi
1494 
1495 
1496 // ============================================================================
1497 // The END
1498 // ============================================================================
1499 #endif // GAUDIKERNEL_PROPERTY_H
1500 // ============================================================================
SimplePropertyRef< unsigned long > UnsignedLongPropertyRef
Definition: Property.h:756
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Definition: Property.h:840
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:1212
const GaudiHandleArrayBase & value() const
Definition: Property.h:917
PropertyWithValue(const std::string &name, PVal value, const bool owner)
the constructor with property name and value
Definition: Property.h:226
SimpleProperty< std::vector< unsigned char > > UnsignedCharArrayProperty
Definition: Property.h:770
helper structure to define the types for properties
PVal i_get() const
get the value
Definition: Property.h:207
virtual ~SimplePropertyRef()
virtual Destructor
Definition: Property.h:688
virtual bool assign(const Property &source)=0
import the property value form the source
PropertyWithValue & operator=(const TYPE &value)
assignment operator
Definition: Property.h:272
SimplePropertyRef< long double > LongDoublePropertyRef
Definition: Property.h:761
SimplePropertyRef< std::vector< double > > DoubleArrayPropertyRef
Definition: Property.h:800
virtual std::string toString() const =0
value -> string
SimpleProperty & operator=(const TYPE &value)
assignment form the value
Definition: Property.h:610
#define GAUDI_API
Definition: Kernel.h:108
SimpleProperty< unsigned char > UnsignedCharProperty
Definition: Property.h:730
SimplePropertyRef templated class.
Definition: HistoProperty.h:16
const std::string & name() const
property name
Definition: Property.h:47
virtual bool setValue(const TYPE &value)=0
NB: abstract : to be implemented when verifier is available.
SimplePropertyRef< int > IntegerPropertyRef
Definition: Property.h:753
Helper intermediate class which represent partly implemented property with value of concrete type and...
Definition: Property.h:396
virtual ~PropertyWithValue()
virtual destructor
Definition: Property.h:262
SimpleProperty< std::vector< bool > > BooleanArrayProperty
Definition: Property.h:767
SimplePropertyRef< unsigned short > UnsignedShortPropertyRef
Definition: Property.h:752
virtual bool assign(const Property &source)
import the property value form the source
Definition: Property.h:913
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:403
SimplePropertyRef< std::vector< unsigned long > > UnsignedLongArrayPropertyRef
Definition: Property.h:796
SimpleProperty< std::vector< long long > > LongLongArrayProperty
Definition: Property.h:777
SimpleProperty< short > ShortProperty
Definition: Property.h:731
SimplePropertyRef & operator=(const TYPE &value)
assignment form the value
Definition: Property.h:703
SimpleProperty< float > FloatProperty
Definition: Property.h:739
SimplePropertyRef< std::vector< std::string > > StringArrayPropertyRef
Definition: Property.h:803
virtual void declareReadHandler(PropertyCallbackFunctor *pf)
set new callback for reading
Definition: Property.cpp:132
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
SimplePropertyRef< unsigned char > UnsignedCharPropertyRef
Definition: Property.h:750
SimpleProperty< double > DoubleProperty
Definition: Property.h:740
SimplePropertyRef< std::vector< unsigned short > > UnsignedShortArrayPropertyRef
Definition: Property.h:792
bool set(const TYPE &value)
update the value of the property/check the verifier
Definition: Property.h:449
SimpleProperty< char > CharProperty
Definition: Property.h:728
return false
Definition: Bootstrap.cpp:338
SimplePropertyRef< unsigned long long > UnsignedLongLongPropertyRef
Definition: Property.h:758
const char *PyHelper() getProperty(IInterface *p, char *name)
Definition: Bootstrap.cpp:297
PropertyWithVerifier & operator=(const PropertyWithVerifier< OTHER, OTHERVERIFIER > &right)
templated assignment
SimpleProperty< std::vector< unsigned long > > UnsignedLongArrayProperty
Definition: Property.h:776
virtual GaudiHandleProperty * clone() const
clone: "virtual constructor"
Definition: Property.h:845
Gaudi::Utils::PropertyTypeTraits< TYPE > Traits
the type-traits for properties
Definition: Property.h:152
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
Property & operator=(const Property &right)
assignment operator
Definition: Property.cpp:90
SimplePropertyRef< std::vector< long > > LongArrayPropertyRef
Definition: Property.h:795
SimpleProperty< std::vector< short > > ShortArrayProperty
Definition: Property.h:771
virtual bool load(Property &destination) const
export the property value to the destination
Definition: Property.h:909
virtual bool assign(const Property &source)
import the property value form the source
Definition: Property.h:853
virtual SimpleProperty * clone() const
implementation of Property::clone
Definition: Property.h:602
SimpleProperty< std::vector< unsigned short > > UnsignedShortArrayProperty
Definition: Property.h:772
SimplePropertyRef< std::vector< short > > ShortArrayPropertyRef
Definition: Property.h:791
SimpleProperty concrete class which implements the full Property interface.
Definition: HistoProperty.h:15
PVal m_value
the actual property value
Definition: Property.h:214
SimpleProperty< signed char > SignedCharProperty
Definition: Property.h:729
SimplePropertyRef< std::string > StringPropertyRef
Definition: Property.h:763
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
Definition: Property.cpp:141
SimpleProperty< bool > BooleanProperty
Definition: Property.h:727
SimpleProperty< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Definition: Property.h:778
SimplePropertyRef< std::vector< bool > > BooleanArrayPropertyRef
Definition: Property.h:787
int N
Definition: IOTest.py:90
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:341
SimpleProperty< unsigned int > UnsignedIntegerProperty
Definition: Property.h:734
Helper intermediate class which represent partly implemented property with value of concrete type...
Definition: Property.h:147
SimplePropertyRef< std::vector< unsigned int > > UnsignedIntegerArrayPropertyRef
Definition: Property.h:794
SimplePropertyRef< std::vector< int > > IntegerArrayPropertyRef
Definition: Property.h:793
SimpleProperty< long > LongProperty
Definition: Property.h:735
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode fromString(const std::string &s)
string -> value
Definition: Property.h:327
SimpleProperty< unsigned long > UnsignedLongProperty
Definition: Property.h:736
virtual std::string toString() const
value -> string
Definition: Property.h:307
Definition of the basic interface.
Definition: IInterface.h:160
SimplePropertyRef< signed char > SignedCharPropertyRef
Definition: Property.h:749
SimplePropertyRef< char > CharPropertyRef
Definition: Property.h:748
string dest
Definition: gaudirun.py:162
void i_set(const TYPE &value)
set the value
Definition: Property.h:203
SimplePropertyRef< std::vector< float > > FloatArrayPropertyRef
Definition: Property.h:799
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:290
SimpleProperty< std::string > StringProperty
Definition: Property.h:743
SimpleProperty< int > IntegerProperty
Definition: Property.h:733
SimplePropertyRef< std::vector< signed char > > SignedCharArrayPropertyRef
Definition: Property.h:789
SimplePropertyRef< std::vector< unsigned char > > UnsignedCharArrayPropertyRef
Definition: Property.h:790
const TYPE & value() const
explicit conversion
Definition: Property.h:355
SimplePropertyRef< long long > LongLongPropertyRef
Definition: Property.h:757
SimplePropertyRef< unsigned int > UnsignedIntegerPropertyRef
Definition: Property.h:754
virtual bool assign(const Property &source)
get the value from another property
Definition: Property.h:283
SimpleProperty(VERIFIER verifier=VERIFIER())
"Almost default" constructor from verifier
Definition: Property.h:547
Base class of array's of various gaudihandles.
Definition: GaudiHandle.h:303
SimpleProperty< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Definition: Property.h:774
SimpleProperty< long double > LongDoubleProperty
Definition: Property.h:741
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
virtual SimplePropertyRef * clone() const
implementation of Property::clone
Definition: Property.h:695
bool m_own
owner of the storage
Definition: Property.h:216
SimplePropertyRef< double > DoublePropertyRef
Definition: Property.h:760
SimplePropertyRef< std::vector< unsigned long long > > UnsignedLongLongArrayPropertyRef
Definition: Property.h:798
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Property &prop)
The output operator for friendly printout.
Definition: Property.cpp:38
SimpleProperty< std::vector< signed char > > SignedCharArrayProperty
Definition: Property.h:769
SimpleProperty< std::vector< char > > CharArrayProperty
Definition: Property.h:768
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Definition: Property.h:900
SimplePropertyRef< bool > BooleanPropertyRef
Definition: Property.h:747
SimplePropertyRef< std::vector< char > > CharArrayPropertyRef
Definition: Property.h:788
virtual void toStream(std::ostream &out) const
value -> stream
Definition: Property.h:317
const GaudiHandleBase & value() const
Definition: Property.h:857
SimpleProperty< std::vector< long > > LongArrayProperty
Definition: Property.h:775
string s
Definition: gaudirun.py:244
SimplePropertyRef< std::vector< long double > > LongDoubleArrayPropertyRef
Definition: Property.h:801
SimpleProperty< std::vector< std::string > > StringArrayProperty
Definition: Property.h:783
SimpleProperty< std::vector< double > > DoubleArrayProperty
Definition: Property.h:780
virtual bool load(Property &dest) const
set value for another property
Definition: Property.h:297
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
Definition: GaudiHandle.h:80
virtual ~SimpleProperty()
virtual Destructor
Definition: Property.h:595
SimplePropertyRef< std::vector< long long > > LongLongArrayPropertyRef
Definition: Property.h:797
GAUDI_API bool hasProperty(const std::vector< const Property * > *p, const std::string &name)
check the property by name from the list of the properties
Definition: Property.cpp:421
SimpleProperty< std::vector< float > > FloatArrayProperty
Definition: Property.h:779
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:22
SimpleProperty< unsigned long long > UnsignedLongLongProperty
Definition: Property.h:738
SimpleProperty< unsigned short > UnsignedShortProperty
Definition: Property.h:732
Traits::PVal PVal
the actual storage type
Definition: Property.h:154
virtual GaudiHandleArrayProperty * clone() const
clone: "virtual constructor"
Definition: Property.h:905
SimplePropertyRef< short > ShortPropertyRef
Definition: Property.h:751
SimpleProperty< std::vector< int > > IntegerArrayProperty
Definition: Property.h:773
SimpleProperty< long long > LongLongProperty
Definition: Property.h:737
Helper functions to set/get the application return code.
Definition: __init__.py:1
SimpleProperty< std::vector< long double > > LongDoubleArrayProperty
Definition: Property.h:781
SimplePropertyRef< float > FloatPropertyRef
Definition: Property.h:759
string type
Definition: gaudirun.py:151
virtual bool load(Property &destination) const
export the property value to the destination
Definition: Property.h:849
SimplePropertyRef< long > LongPropertyRef
Definition: Property.h:755