1 #ifndef GAUDIKERNEL_PROPERTY_H
2 #define GAUDIKERNEL_PROPERTY_H
12 #include "GaudiKernel/Kernel.h"
13 #include "GaudiKernel/PropertyVerifier.h"
14 #include "GaudiKernel/Parsers.h"
15 #include "GaudiKernel/ToStream.h"
16 #include "GaudiKernel/SmartIF.h"
45 const std::string&
name ()
const {
return m_name ; }
49 const std::type_info*
type_info ()
const {
return m_typeinfo ; }
51 std::string
type ()
const {
return m_typeinfo->name() ; }
55 virtual bool assign (
const Property& source ) = 0 ;
58 virtual std::string
toString ()
const = 0 ;
60 virtual void toStream(std::ostream& out)
const = 0;
65 const std::function<void(Property&)>&
readCallBack()
const {
return m_readCallBack; }
67 const std::function<void(Property&)>&
updateCallBack()
const {
return m_updateCallBack; }
70 virtual void declareReadHandler ( std::function<
void(
Property&)>
fun ) ;
72 virtual void declareUpdateHandler ( std::function<
void(
Property&)>
fun ) ;
76 { declareReadHandler( [=](
Property& p) { (instance->*MF)(p); } ) ; }
80 { declareUpdateHandler ( [=](
Property& p) { (instance->*MF)(p); } ); }
83 virtual void useReadHandler ()
const ;
85 virtual bool useUpdateHandler () ;
90 virtual Property* clone ()
const = 0 ;
95 m_documentation = std::move(documentation); }
97 virtual std::ostream& fillStream ( std::ostream& )
const ;
101 (
const std::type_info&
type ,
102 std::string
name =
"" ) ;
106 const std::type_info&
type ) ;
133 template <
class TYPE>
141 typedef typename Traits::PVal
PVal ;
153 template <
class OTHER>
162 template <
class OTHER>
168 operator const TYPE& ()
const {
return value() ;}
170 inline const TYPE&
value()
const ;
183 std::string
toString ()
const override;
185 void toStream (std::ostream& out)
const override;
191 Traits::assign(*
m_value, value);
210 template <
class TYPE>
216 :
Property (
typeid( TYPE ) , std::move(name) )
223 template <
class TYPE>
228 , m_own ( right.
m_own )
230 m_value = Traits::copy ( right.
value() , m_own ) ;
235 template <
class TYPE>
236 template <
class OTHER>
241 , m_own ( right.
m_own )
243 m_value = Traits::copy ( right.
value() , m_own ) ;
248 template <
class TYPE>
251 Traits::dele ( m_value , m_own ) ;
256 template <
class TYPE>
260 if ( !setValue ( value ) )
261 {
throw std::out_of_range(
"Value not verified" ) ; }
267 template <
class TYPE>
274 if ( p ) {
return setValue ( p->
value() ) ; }
276 return this->fromString( source.
toString() ).isSuccess() ;
281 template <
class TYPE>
286 return dest.
assign( *
this ) ;
291 template <
class TYPE>
301 template <
class TYPE>
311 template <
class TYPE>
328 return this->
value() ;
339 template <
class TYPE>
342 { useReadHandler() ;
return *m_value ; }
346 template <
class TYPE>
359 template <
class TYPE>
360 template <
class OTHER>
381 template<
class TYPE,
class VERIFIER>
404 bool set(
const TYPE& value ) ;
406 bool setValue(
const TYPE& value )
override {
return set( value ) ; }
408 template <
class OTHER,
class OTHERVERIFIER>
412 template <
class OTHER>
432 template <
class TYPE,
class VERIFIER>
437 if ( !m_verifier.isValid( &value ) ) {
return false ; }
439 this->i_set( value ) ;
441 return this->useUpdateHandler() ;
446 template <
class TYPE,
class VERIFIER>
456 template <
class TYPE,
class VERIFIER>
457 template <
class OTHER>
467 template <
class TYPE,
class VERIFIER>
468 template <
class OTHER,
class OTHERVERIFIER>
489 template <
class TYPE,
class VERIFIER = BoundedVerifier<TYPE> >
501 ( VERIFIER
verifier = VERIFIER() ) ;
504 (
const TYPE& value ,
512 template <
class OTHER>
523 template <
class OTHER>
530 template <
class TYPE,
class VERIFIER>
532 ( VERIFIER verifier )
534 (
"" , Traits::new_() , true , verifier )
539 template <
class TYPE,
class VERIFIER>
541 (
const TYPE& value ,
544 (
"" , Traits::new_(value) , true , verifier )
549 template <
class TYPE,
class VERIFIER>
555 ( std::move(name) , Traits::new_(value) , true , verifier )
560 template <
class TYPE,
class VERIFIER>
561 template <
class OTHER>
565 ( right.
name() , Traits::new_( right.
value() ) ,
true , VERIFIER() )
570 template <
class TYPE,
class VERIFIER>
579 template <
class TYPE,
class VERIFIER>
587 template <
class TYPE,
class VERIFIER>
598 template <
class TYPE,
class VERIFIER>
599 template <
class OTHER>
620 template<
class TYPE,
class VERIFIER = NullVerifier<TYPE> >
629 VERIFIER verifier = VERIFIER() ) ;
639 template <
class OTHER>
648 template <
class TYPE,
class VERIFIER>
658 template <
class TYPE,
class VERIFIER>
667 template <
class TYPE,
class VERIFIER>
675 template <
class TYPE,
class VERIFIER>
686 template <
class TYPE,
class VERIFIER>
687 template <
class OTHER>
795 std::string
toString()
const override;
797 void toStream(std::ostream& out)
const override;
825 return destination.
assign( *
this );
854 std::string
toString()
const override;
856 void toStream(std::ostream& out)
const override;
885 return destination.
assign( *
this );
959 (
const IProperty* p ,
const std::string& name ) ;
979 (
const IInterface* p ,
const std::string& name ) ;
1004 (
const std::vector<const Property*>* p ,
1005 const std::string& name ) ;
1030 (
const std::vector<const Property*>* p ,
1031 const std::string& name ) ;
1056 template <
class TYPE>
1059 const std::string& name ,
1061 const std::string& doc ) ;
1085 template <
class TYPE>
1088 const std::string& name ,
1090 {
return setProperty ( component , name , value , std::string() ) ; }
1107 const std::string& name ,
1108 const std::string& value ,
1109 const std::string& doc =
"" ) ;
1126 const std::string& name ,
1128 const std::string& doc =
"" ) ;
1143 template <
unsigned N>
1146 const std::string& name ,
1147 const char (&value)[
N] ,
1148 const std::string& doc =
"" )
1150 return component ?
setProperty ( component , name ,
1151 std::string ( value , value + N ), doc )
1185 template <
class TYPE>
1188 const std::string& name ,
1190 const std::string& doc )
1221 const std::string& name ,
1223 const std::string& doc =
"" ) ;
1248 const std::string& name ,
1250 const std::string& doc =
"" ) ;
1274 template <
class TYPE>
1277 const std::string& name ,
1279 const std::string& doc =
"" )
1281 return setProperty ( component , name , &value , doc ) ;
1304 template <
class TYPE>
1307 const std::string& name ,
1309 const std::string& doc =
"" )
1313 return property ?
setProperty ( property , name , value , doc )
1331 const std::string& name ,
1332 const std::string& value ,
1333 const std::string& doc =
"" ) ;
1349 const std::string& name ,
1351 const std::string& doc =
"" ) ;
1366 template <
unsigned N>
1369 const std::string& name ,
1370 const char (&value)[N] ,
1371 const std::string& doc =
"" )
1375 std::string{
value , value + N }, doc ) ;
1401 const std::string& name ,
1403 const std::string& doc =
"" ) ;
1428 const std::string& name ,
1430 const std::string& doc =
"" ) ;
1454 template <
class TYPE>
1458 const std::string& name ,
1460 const std::string& doc =
"" )
1462 return setProperty ( component , name , &value , doc ) ;
1472 #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
std::string m_documentation
SimpleProperty< std::vector< unsigned char > > UnsignedCharArrayProperty
helper structure to define the types for properties
bool load(Property &destination) const override
export the property value to the destination
virtual void useReadHandler() const
use the call-back function at reading
GaudiHandleArrayProperty * clone() const override
clone: "virtual constructor"
PropertyWithValue(std::string name, PVal value, const bool owner)
the constructor with property name and value
PVal i_get() const
get the value
bool setValue(const GaudiHandleArrayBase &value)
virtual bool assign(const Property &source)=0
import the property value form the source
const std::function< void(Property &)> & updateCallBack() const
get a reference to the updateCallBack
~PropertyWithValue() override
virtual destructor
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
PropertyWithVerifier()
the default & copy constructors are deleted
Helper intermediate class which represent partly implemented property with value of concrete type and...
GaudiHandleProperty * clone() const override
clone: "virtual constructor"
bool assign(const Property &source) override
import the property value form the source
SimpleProperty< std::vector< bool > > BooleanArrayProperty
StatusCode fromString(const std::string &s) override
string -> value
SimplePropertyRef< unsigned short > UnsignedShortPropertyRef
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
SimplePropertyRef< std::vector< unsigned long > > UnsignedLongArrayPropertyRef
void setDocumentation(std::string documentation)
set the documentation string
~SimplePropertyRef() override=default
virtual Destructor
void declareUpdateHandler(void(HT::*MF)(Property &), HT *instance)
SimpleProperty< std::vector< long long > > LongLongArrayProperty
SimpleProperty< short > ShortProperty
SimplePropertyRef & operator=(const TYPE &value)
assignment form the value
SimpleProperty< float > FloatProperty
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
SimplePropertyRef< std::vector< std::string > > StringArrayPropertyRef
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
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
const std::function< void(Property &)> & readCallBack() const
get a reference to the readCallBack
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
virtual bool load(Property &dest) const =0
export the property value to the destination
SimplePropertyRef< unsigned long long > UnsignedLongLongPropertyRef
PropertyWithVerifier & operator=(const PropertyWithVerifier< OTHER, OTHERVERIFIER > &right)
templated assignment
const std::string & documentation() const
property documentation
SimpleProperty< std::vector< unsigned long > > UnsignedLongArrayProperty
Gaudi::Utils::PropertyTypeTraits< TYPE > Traits
the type-traits for properties
bool assign(const Property &source) override
import the property value form the source
bool isFailure() const
Test for a status code of FAILURE.
SimplePropertyRef< std::vector< long > > LongArrayPropertyRef
const std::type_info * m_typeinfo
SimpleProperty< std::vector< short > > ShortArrayProperty
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
std::string type() const
property type
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
GaudiHandleProperty(std::string name, GaudiHandleBase &ref)
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.
SimpleProperty< unsigned long > UnsignedLongProperty
std::string toString() const override
value -> string
Definition of the basic interface.
SimplePropertyRef< signed char > SignedCharPropertyRef
GaudiHandleArrayProperty(std::string name, GaudiHandleArrayBase &ref)
std::function< void(Property &)> m_readCallBack
SimplePropertyRef< char > CharPropertyRef
void i_set(const TYPE &value)
set the value
SimplePropertyRef< std::vector< float > > FloatArrayPropertyRef
const VERIFIER & verifier() const
SimpleProperty< std::string > StringProperty
SimpleProperty< int > IntegerProperty
SimplePropertyRef< std::vector< signed char > > SignedCharArrayPropertyRef
~SimpleProperty() override=default
virtual Destructor
SimplePropertyRef< std::vector< unsigned char > > UnsignedCharArrayPropertyRef
Gaudi::Utils::PropertyTypeTraits< TYPE > Traits
const TYPE & value() const
explicit conversion
SimplePropertyRef< long long > LongLongPropertyRef
GAUDI_API Property * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
SimpleProperty * clone() const override
implementation of Property::clone
StatusCode fromString(const std::string &s) override
string -> value
Property & operator=(const Property &)=default
assignment operator
SimplePropertyRef< unsigned int > UnsignedIntegerPropertyRef
GaudiHandleArrayBase * m_pValue
Pointer to the real 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".
bool assign(const Property &source) override
get the value from another property
StatusCode fromString(const std::string &s) override
string -> value
void declareReadHandler(void(HT::*MF)(Property &), HT *instance)
bool m_own
owner of the storage
SimplePropertyRef< double > DoublePropertyRef
SimplePropertyRef< std::vector< unsigned long long > > UnsignedLongLongArrayPropertyRef
VERIFIER m_verifier
the verifier itself
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Property &prop)
The output operator for friendly printout.
void setName(std::string value)
set the new value for the property name
SimpleProperty< std::vector< signed char > > SignedCharArrayProperty
SimpleProperty< std::vector< char > > CharArrayProperty
SimplePropertyRef * clone() const override
implementation of Property::clone
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
SimplePropertyRef< bool > BooleanPropertyRef
std::function< void(Property &)> m_updateCallBack
void toStream(std::ostream &out) const override
value -> stream
double fun(const std::vector< double > &x)
SimplePropertyRef< std::vector< char > > CharArrayPropertyRef
const GaudiHandleBase & value() const
SimpleProperty< std::vector< long > > LongArrayProperty
SimplePropertyRef< std::vector< long double > > LongDoubleArrayPropertyRef
bool load(Property &destination) const override
export the property value to the destination
SimpleProperty< std::vector< std::string > > StringArrayProperty
const std::type_info * type_info() const
property type-info
GaudiHandleBase * m_pValue
Pointer to the real property.
bool load(Property &dest) const override
set value for another property
SimpleProperty< std::vector< double > > DoubleArrayProperty
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
SimplePropertyRef< std::vector< long long > > LongLongArrayPropertyRef
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 Property * clone() const =0
clone: "virtual constructor"
SimplePropertyRef< short > ShortPropertyRef
~PropertyWithVerifier() override=default
virtual destructor
SimpleProperty< std::vector< int > > IntegerArrayProperty
SimpleProperty< long long > LongLongProperty
Helper functions to set/get the application return code.
bool setValue(const GaudiHandleBase &value)
SimpleProperty< std::vector< long double > > LongDoubleArrayProperty
SimplePropertyRef< float > FloatPropertyRef
virtual void toStream(std::ostream &out) const =0
value -> stream
SimplePropertyRef< long > LongPropertyRef
virtual StatusCode fromString(const std::string &value)=0
string -> value