15 #include "GaudiKernel/IProperty.h"
16 #include "GaudiKernel/SmartIF.h"
17 #include "GaudiKernel/Property.h"
18 #include "GaudiKernel/GaudiHandle.h"
22 #include "boost/algorithm/string/compare.hpp"
42 (
const std::type_info&
type ,
44 : m_name ( std::move(name) )
45 , m_documentation ( m_name )
46 , m_typeinfo ( &type )
56 const std::type_info& type )
57 : m_name ( std::move(name) )
58 , m_documentation ( m_name )
59 , m_typeinfo ( &type )
84 std::function<void(Property&)> theCallBack;
86 theCallBack( const_cast<Property&>(*
this) ) ;
97 std::function<void(Property&)> theCallBack;
100 theCallBack( *
this ) ;
112 {
return stream <<
" '" <<
name() <<
"':" <<
toString() ; }
134 const std::string& name )
160 const std::string& name )
173 m_pValue->setPropertyName(
name() );
225 std::vector< std::string > tmp;
237 template <
typename C,
typename BinaryPredicate>
238 bool equal_(
const C&
c1,
const C&
c2, BinaryPredicate&& p) {
239 return c1.size() == c2.size() &&
241 std::forward<BinaryPredicate>(p) );
248 is_iByName (
const std::string& name ) : m_name ( name ) {}
250 bool operator () (
const Property* p )
const
252 return p && equal_(m_name,p->
name(),boost::algorithm::is_iequal{});
255 const std::string& m_name ;
279 const std::string& name )
282 if ( !p ) {
return nullptr ; }
286 auto ifound = std::find_if ( props.begin(), props.end(), is_iByName{ name } );
287 return ifound != props.end() ? *ifound :
nullptr;
312 if ( !p ) {
return nullptr ; }
315 if ( !_i ) {
return nullptr ; }
317 return property ?
getProperty ( property , name ) :
nullptr;
344 (
const std::vector<const Property*>* p ,
345 const std::string& name )
375 (
const std::vector<const Property*>* p ,
376 const std::string& name )
379 if ( !p ) {
return nullptr ; }
380 auto ifound = std::find_if ( p->begin() , p->end() , is_iByName{ name } ) ;
381 return p->end() != ifound ? *ifound : nullptr ;
400 const std::string& name ,
402 const std::string& doc )
422 const std::string& name ,
423 const std::string& value ,
424 const std::string& doc )
432 if ( p ) { p -> setDocumentation ( doc ) ; }
462 const std::string& name ,
464 const std::string& doc )
497 const std::string& name ,
499 const std::string& doc )
500 {
return setProperty ( component , name , &property , doc ) ; }
517 const std::string& name ,
518 const std::string& value ,
519 const std::string& doc )
523 return property ?
setProperty ( property , name , value , doc )
542 const std::string& name ,
544 const std::string& doc )
546 return setProperty ( component , name , std::string{ value } , doc ) ;
573 const std::string& name ,
575 const std::string& doc )
580 return setProperty ( prop , name , property , doc ) ;
607 const std::string& name ,
609 const std::string& doc )
610 {
return setProperty ( component , name , &property , doc ) ; }
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
virtual void useReadHandler() const
use the call-back function at reading
bool setValue(const GaudiHandleArrayBase &value)
virtual bool assign(const Property &source)=0
import the property value form the source
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
void setTypeAndName(std::string myTypeAndName)
The component "type/name" string.
virtual std::string toString() const =0
value -> string
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
const std::string & name() const
property name
StatusCode fromString(const std::string &s) override
string -> value
auto begin(reverse_wrapper< T > &w)
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
void setDocumentation(std::string documentation)
set the documentation string
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
const char *PyHelper() getProperty(IInterface *p, char *name)
bool isFailure() const
Test for a status code of FAILURE.
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
void toStream(std::ostream &out) const override
value -> stream
virtual Property & declareReadHandler(std::function< void(Property &)> fun)
set new callback for reading
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)
bool setTypesAndNames(const std::vector< std::string > &myTypesAndNamesList)
Set the array of handles from list of "type/name" strings in .
virtual bool useUpdateHandler()
use the call-back function at update
auto end(reverse_wrapper< T > &w)
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
GaudiHandleArrayProperty(std::string name, GaudiHandleArrayBase &ref)
std::function< void(Property &)> m_readCallBack
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
std::string toString() const override
value -> string
GAUDI_API Property * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
StatusCode fromString(const std::string &s) override
string -> value
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Base class of array's of various gaudihandles.
Property base class allowing Property* collections to be "homogeneous".
void toStream(std::ostream &out) const override
value -> stream
void setPropertyName(std::string propName)
set name as used in declareProperty(name,gaudiHandle).
std::function< void(Property &)> m_updateCallBack
double fun(const std::vector< double > &x)
std::ostream & operator<<(std::ostream &stream, const Property &prop)
The output operator for friendly printout.
GaudiHandleBase * m_pValue
Pointer to the real property.
const std::vector< std::string > typesAndNames() const
Return a vector with "type/name" strings of all handles in the array.
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
std::string toString() const override
value -> string
std::string typeAndName() const
The full type and name: "type/name".
The IProperty is the basic interface for all components which have properties that can be set or get...
bool setValue(const GaudiHandleBase &value)