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 )
82 std::function<void(Property&)> theCallBack;
84 theCallBack( const_cast<Property&>(*
this) ) ;
95 std::function<void(Property&)> theCallBack;
98 theCallBack( *
this ) ;
110 {
return stream <<
" '" <<
name() <<
"':" <<
toString() ; }
132 const std::string& name )
158 const std::string& name )
171 m_pValue->setPropertyName(
name() );
223 std::vector< std::string > tmp;
235 template <
typename C,
typename BinaryPredicate>
236 bool equal_(
const C& c1,
const C& c2, BinaryPredicate&& p) {
237 return c1.size() == c2.size() &&
239 std::forward<BinaryPredicate>(p) );
246 is_iByName (
const std::string& name ) : m_name ( name ) {}
248 bool operator () (
const Property* p )
const
250 return p && equal_(m_name,p->
name(),boost::algorithm::is_iequal{});
253 const std::string& m_name ;
277 const std::string& name )
280 if ( !p ) {
return nullptr ; }
284 auto ifound = std::find_if ( props.begin(), props.end(), is_iByName{ name } );
285 return ifound != props.end() ? *ifound :
nullptr;
310 if ( !p ) {
return nullptr ; }
313 if ( !_i ) {
return nullptr ; }
315 return property ?
getProperty ( property , name ) :
nullptr;
342 (
const std::vector<const Property*>* p ,
343 const std::string& name )
373 (
const std::vector<const Property*>* p ,
374 const std::string& name )
377 if ( !p ) {
return nullptr ; }
378 auto ifound = std::find_if ( p->begin() , p->end() , is_iByName{ name } ) ;
379 return p->end() != ifound ? *ifound : nullptr ;
398 const std::string& name ,
400 const std::string& doc )
420 const std::string& name ,
421 const std::string& value ,
422 const std::string& doc )
430 if ( p ) { p -> setDocumentation ( doc ) ; }
460 const std::string& name ,
462 const std::string& doc )
495 const std::string& name ,
497 const std::string& doc )
498 {
return setProperty ( component , name , &property , doc ) ; }
515 const std::string& name ,
516 const std::string& value ,
517 const std::string& doc )
521 return property ?
setProperty ( property , name , value , doc )
540 const std::string& name ,
542 const std::string& doc )
544 return setProperty ( component , name , std::string{ value } , doc ) ;
571 const std::string& name ,
573 const std::string& doc )
578 return setProperty ( prop , name , property , doc ) ;
605 const std::string& name ,
607 const std::string& doc )
608 {
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
const std::string & name() const
property name
auto begin(reverse_wrapper< T > &w)
StatusCode fromString(const std::string &s) override
string -> value
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
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)
auto end(reverse_wrapper< T > &w)
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
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)
virtual void declareReadHandler(std::function< void(Property &)> fun)
set new callback for reading
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)
virtual void declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
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)