5 #ifndef GAUDIKERNEL_PROPERTY_H
6 #define GAUDIKERNEL_PROPERTY_H
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"
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() ; }
57 virtual bool assign (
const Property& source ) = 0 ;
60 virtual std::string
toString ()
const = 0 ;
62 virtual void toStream(std::ostream& out)
const = 0;
75 void declareReadHandler
76 (
void ( HT::* MF ) (
Property& ) , HT* instance ) ;
78 void declareUpdateHandler
79 (
void ( HT::* MF ) (
Property& ) , HT* instance ) ;
81 virtual void useReadHandler ()
const ;
83 virtual bool useUpdateHandler () ;
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 ;
99 (
const std::type_info&
type ,
100 const std::string& name =
"" ) ;
103 (
const std::string& name ,
104 const std::type_info&
type ) ;
116 std::string m_documentation;
118 const std::type_info* m_typeinfo ;
126 #include "GaudiKernel/PropertyCallbackFunctor.h"
130 (
void ( HT::* MF ) (
Property& ) , HT* obj )
135 (
void ( HT::* MF ) (
Property& ) , HT* obj )
146 template <
class TYPE>
154 typedef typename Traits::PVal
PVal ;
160 (
const std::string&
name ,
166 template <
class OTHER>
175 template <
class OTHER>
181 operator const TYPE& ()
const {
return value() ;}
183 inline const TYPE&
value()
const ;
196 virtual std::string
toString ()
const ;
198 virtual void toStream (std::ostream& out)
const ;
204 Traits::assign(*
m_value, value);
207 inline PVal
i_get ()
const {
223 template <
class TYPE>
226 (
const std::string& name ,
229 :
Property ( typeid( TYPE ) , name )
236 template <
class TYPE>
240 , m_value ( right.m_value )
241 , m_own ( right.m_own )
243 m_value = Traits::copy ( right.
value() , m_own ) ;
248 template <
class TYPE>
249 template <
class OTHER>
253 , m_value ( right.m_value )
254 , m_own ( right.m_own )
256 m_value = Traits::copy ( right.
value() , m_own ) ;
261 template <
class TYPE>
264 Traits::dele ( m_value , m_own ) ;
270 template <
class TYPE>
274 if ( !setValue ( value ) )
275 {
throw std::out_of_range(
"Value not verified" ) ; }
281 template <
class TYPE>
288 if ( 0 != p ) {
return setValue ( p->
value() ) ; }
290 return this->fromString( source.
toString() ).isSuccess() ;
295 template <
class TYPE>
300 return dest.
assign( *
this ) ;
305 template <
class TYPE>
315 template <
class TYPE>
325 template <
class TYPE>
342 return this->
value() ;
347 {
return this->fromString( source.
toString() ).isSuccess() ; }
353 template <
class TYPE>
356 { useReadHandler() ;
return *m_value ; }
360 template <
class TYPE>
373 template <
class TYPE>
374 template <
class OTHER>
395 template<
class TYPE,
class VERIFIER>
403 (
const std::string& name ,
406 const VERIFIER& verifier )
408 , m_verifier ( verifier )
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>
426 template <
class OTHER>
441 VERIFIER m_verifier ;
447 template <
class TYPE,
class VERIFIER>
452 if ( !m_verifier.isValid( &value ) ) {
return false ; }
454 this->i_set( value ) ;
456 return this->useUpdateHandler() ;
461 template <
class TYPE,
class VERIFIER>
471 template <
class TYPE,
class VERIFIER>
472 template <
class OTHER>
482 template <
class TYPE,
class VERIFIER>
483 template <
class OTHER,
class OTHERVERIFIER>
504 template <
class TYPE,
class VERIFIER = BoundedVerifier<TYPE> >
516 ( VERIFIER verifier = VERIFIER() ) ;
519 (
const TYPE& value ,
520 VERIFIER verifier = VERIFIER() ) ;
523 (
const std::string& name ,
525 VERIFIER verifier = VERIFIER() ) ;
527 template <
class OTHER>
538 template <
class OTHER>
545 template <
class TYPE,
class VERIFIER>
547 ( VERIFIER verifier )
549 (
"" , Traits::new_() , true , verifier )
554 template <
class TYPE,
class VERIFIER>
556 (
const TYPE& value ,
559 (
"" , Traits::new_(value) , true , verifier )
564 template <
class TYPE,
class VERIFIER>
566 (
const std::string& name ,
570 ( name , Traits::new_(value) , true , verifier )
575 template <
class TYPE,
class VERIFIER>
576 template <
class OTHER>
580 ( right.name() , Traits::new_( right.value() ) , true , VERIFIER() )
585 template <
class TYPE,
class VERIFIER>
589 ( right.name() , Traits::new_( right.value() ) , true , right.verifier() )
594 template <
class TYPE,
class VERIFIER>
599 template <
class TYPE,
class VERIFIER>
607 template <
class TYPE,
class VERIFIER>
618 template <
class TYPE,
class VERIFIER>
619 template <
class OTHER>
640 template<
class TYPE,
class VERIFIER = NullVerifier<TYPE> >
647 (
const std::string& name ,
649 VERIFIER verifier = VERIFIER() ) ;
659 template <
class OTHER>
668 template <
class TYPE,
class VERIFIER>
670 (
const std::string& name ,
678 template <
class TYPE,
class VERIFIER>
682 ( right.name() , right.i_get() ,
false , right.verifier() )
687 template <
class TYPE,
class VERIFIER>
692 template <
class TYPE,
class VERIFIER>
700 template <
class TYPE,
class VERIFIER>
711 template <
class TYPE,
class VERIFIER>
712 template <
class OTHER>
816 virtual bool load(
Property& destination )
const;
818 virtual bool assign(
const Property& source );
820 virtual std::string
toString()
const;
822 virtual void toStream(std::ostream& out)
const;
824 virtual StatusCode fromString(
const std::string&
s);
850 return destination.
assign( *
this );
854 return fromString( source.
toString() ).isSuccess();
875 virtual bool load(
Property& destination )
const;
877 virtual bool assign(
const Property& source );
879 virtual std::string
toString()
const;
881 virtual void toStream(std::ostream& out)
const;
883 virtual StatusCode fromString(
const std::string&
s);
910 return destination.
assign( *
this );
914 return fromString( source.
toString() ) != 0;
984 (
const IProperty* p ,
const std::string& name ) ;
1004 (
const IInterface* p ,
const std::string& name ) ;
1029 (
const std::vector<const Property*>* p ,
1030 const std::string& name ) ;
1055 (
const std::vector<const Property*>* p ,
1056 const std::string& name ) ;
1081 template <
class TYPE>
1084 const std::string& name ,
1086 const std::string& doc ) ;
1110 template <
class TYPE>
1113 const std::string& name ,
1115 {
return setProperty ( component , name , value , std::string() ) ; }
1132 const std::string& name ,
1133 const std::string& value ,
1134 const std::string& doc =
"" ) ;
1151 const std::string& name ,
1153 const std::string& doc =
"" ) ;
1168 template <
unsigned N>
1171 const std::string& name ,
1172 const char (&value)[
N] ,
1173 const std::string& doc =
"" )
1176 const std::string val = std::string ( value , value + N ) ;
1177 return setProperty ( component , name , val , doc ) ;
1210 template <
class TYPE>
1213 const std::string& name ,
1215 const std::string& doc )
1246 const std::string& name ,
1248 const std::string& doc =
"" ) ;
1273 const std::string& name ,
1275 const std::string& doc =
"" ) ;
1299 template <
class TYPE>
1302 const std::string& name ,
1304 const std::string& doc =
"" )
1307 return setProperty ( component , name , property , doc ) ;
1330 template <
class TYPE>
1333 const std::string& name ,
1335 const std::string& doc =
"" )
1340 return setProperty ( property , name , value , doc ) ;
1357 const std::string& name ,
1358 const std::string& value ,
1359 const std::string& doc =
"" ) ;
1375 const std::string& name ,
1377 const std::string& doc =
"" ) ;
1392 template <
unsigned N>
1395 const std::string& name ,
1396 const char (&value)[N] ,
1397 const std::string& doc =
"" )
1400 const std::string val = std::string ( value , value + N ) ;
1401 return setProperty ( component , name , val , doc ) ;
1427 const std::string& name ,
1429 const std::string& doc =
"" ) ;
1454 const std::string& name ,
1456 const std::string& doc =
"" ) ;
1480 template <
class TYPE>
1484 const std::string& name ,
1486 const std::string& doc =
"" )
1489 return setProperty ( component , name , property , doc ) ;
1499 #endif // GAUDIKERNEL_PROPERTY_H
SimplePropertyRef< unsigned long > UnsignedLongPropertyRef
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
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
const GaudiHandleArrayBase & value() const
PropertyWithValue(const std::string &name, PVal value, const bool owner)
the constructor with property name and value
SimpleProperty< std::vector< unsigned char > > UnsignedCharArrayProperty
helper structure to define the types for properties
PVal i_get() const
get the value
virtual ~SimplePropertyRef()
virtual Destructor
virtual bool assign(const Property &source)=0
import the property value form the source
PropertyWithValue & operator=(const TYPE &value)
assignment operator
SimplePropertyRef< long double > LongDoublePropertyRef
SimplePropertyRef< std::vector< double > > DoubleArrayPropertyRef
virtual std::string toString() const =0
value -> string
SimpleProperty & operator=(const TYPE &value)
assignment form the value
SimpleProperty< unsigned char > UnsignedCharProperty
SimplePropertyRef templated class.
const std::string & name() const
property name
virtual bool setValue(const TYPE &value)=0
NB: abstract : to be implemented when verifier is available.
SimplePropertyRef< int > IntegerPropertyRef
Helper intermediate class which represent partly implemented property with value of concrete type and...
virtual ~PropertyWithValue()
virtual destructor
SimpleProperty< std::vector< bool > > BooleanArrayProperty
SimplePropertyRef< unsigned short > UnsignedShortPropertyRef
virtual bool assign(const Property &source)
import the property value form the source
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
SimplePropertyRef< std::vector< unsigned long > > UnsignedLongArrayPropertyRef
SimpleProperty< std::vector< long long > > LongLongArrayProperty
SimpleProperty< short > ShortProperty
SimplePropertyRef & operator=(const TYPE &value)
assignment form the value
SimpleProperty< float > FloatProperty
SimplePropertyRef< std::vector< std::string > > StringArrayPropertyRef
virtual void declareReadHandler(PropertyCallbackFunctor *pf)
set new callback for reading
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
SimpleProperty< double > DoubleProperty
SimplePropertyRef< std::vector< unsigned short > > UnsignedShortArrayPropertyRef
bool set(const TYPE &value)
update the value of the property/check the verifier
SimpleProperty< char > CharProperty
SimplePropertyRef< unsigned long long > UnsignedLongLongPropertyRef
const char *PyHelper() getProperty(IInterface *p, char *name)
PropertyWithVerifier & operator=(const PropertyWithVerifier< OTHER, OTHERVERIFIER > &right)
templated assignment
SimpleProperty< std::vector< unsigned long > > UnsignedLongArrayProperty
virtual GaudiHandleProperty * clone() const
clone: "virtual constructor"
Gaudi::Utils::PropertyTypeTraits< TYPE > Traits
the type-traits for properties
bool isFailure() const
Test for a status code of FAILURE.
Property & operator=(const Property &right)
assignment operator
SimplePropertyRef< std::vector< long > > LongArrayPropertyRef
SimpleProperty< std::vector< short > > ShortArrayProperty
virtual bool load(Property &destination) const
export the property value to the destination
virtual bool assign(const Property &source)
import the property value form the source
virtual SimpleProperty * clone() const
implementation of Property::clone
SimpleProperty< std::vector< unsigned short > > UnsignedShortArrayProperty
SimplePropertyRef< std::vector< short > > ShortArrayPropertyRef
SimpleProperty concrete class which implements the full Property interface.
PVal m_value
the actual property value
SimpleProperty< signed char > SignedCharProperty
SimplePropertyRef< std::string > StringPropertyRef
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
SimpleProperty< bool > BooleanProperty
SimpleProperty< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
SimplePropertyRef< std::vector< bool > > BooleanArrayPropertyRef
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
SimpleProperty< unsigned int > UnsignedIntegerProperty
Helper intermediate class which represent partly implemented property with value of concrete type...
SimplePropertyRef< std::vector< unsigned int > > UnsignedIntegerArrayPropertyRef
SimplePropertyRef< std::vector< int > > IntegerArrayPropertyRef
SimpleProperty< long > LongProperty
This class is used for returning status codes from appropriate routines.
virtual StatusCode fromString(const std::string &s)
string -> value
SimpleProperty< unsigned long > UnsignedLongProperty
virtual std::string toString() const
value -> string
Definition of the basic interface.
SimplePropertyRef< signed char > SignedCharPropertyRef
SimplePropertyRef< char > CharPropertyRef
void i_set(const TYPE &value)
set the value
SimplePropertyRef< std::vector< float > > FloatArrayPropertyRef
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
SimpleProperty< std::string > StringProperty
SimpleProperty< int > IntegerProperty
SimplePropertyRef< std::vector< signed char > > SignedCharArrayPropertyRef
SimplePropertyRef< std::vector< unsigned char > > UnsignedCharArrayPropertyRef
const TYPE & value() const
explicit conversion
SimplePropertyRef< long long > LongLongPropertyRef
SimplePropertyRef< unsigned int > UnsignedIntegerPropertyRef
virtual bool assign(const Property &source)
get the value from another property
SimpleProperty(VERIFIER verifier=VERIFIER())
"Almost default" constructor from verifier
Base class of array's of various gaudihandles.
SimpleProperty< std::vector< unsigned int > > UnsignedIntegerArrayProperty
SimpleProperty< long double > LongDoubleProperty
Property base class allowing Property* collections to be "homogeneous".
virtual SimplePropertyRef * clone() const
implementation of Property::clone
bool m_own
owner of the storage
SimplePropertyRef< double > DoublePropertyRef
SimplePropertyRef< std::vector< unsigned long long > > UnsignedLongLongArrayPropertyRef
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Property &prop)
The output operator for friendly printout.
SimpleProperty< std::vector< signed char > > SignedCharArrayProperty
SimpleProperty< std::vector< char > > CharArrayProperty
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
SimplePropertyRef< bool > BooleanPropertyRef
SimplePropertyRef< std::vector< char > > CharArrayPropertyRef
virtual void toStream(std::ostream &out) const
value -> stream
const GaudiHandleBase & value() const
SimpleProperty< std::vector< long > > LongArrayProperty
SimplePropertyRef< std::vector< long double > > LongDoubleArrayPropertyRef
SimpleProperty< std::vector< std::string > > StringArrayProperty
SimpleProperty< std::vector< double > > DoubleArrayProperty
virtual bool load(Property &dest) const
set value for another property
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
virtual ~SimpleProperty()
virtual Destructor
SimplePropertyRef< std::vector< long long > > LongLongArrayPropertyRef
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
SimpleProperty< std::vector< float > > FloatArrayProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
SimpleProperty< unsigned long long > UnsignedLongLongProperty
SimpleProperty< unsigned short > UnsignedShortProperty
Traits::PVal PVal
the actual storage type
virtual GaudiHandleArrayProperty * clone() const
clone: "virtual constructor"
SimplePropertyRef< short > ShortPropertyRef
SimpleProperty< std::vector< int > > IntegerArrayProperty
SimpleProperty< long long > LongLongProperty
Helper functions to set/get the application return code.
SimpleProperty< std::vector< long double > > LongDoubleArrayProperty
SimplePropertyRef< float > FloatPropertyRef
virtual bool load(Property &destination) const
export the property value to the destination
SimplePropertyRef< long > LongPropertyRef