18#include <boost/algorithm/string/compare.hpp>
22#include <unordered_set>
28 bool operator()(
const std::unique_ptr<std::string>& a,
const std::unique_ptr<std::string>& b )
const {
33 std::size_t operator()(
const std::unique_ptr<std::string>& s )
const {
return std::hash<std::string>()( *s ); }
36 std::unordered_set<std::unique_ptr<std::string>, PtrHash, PtrCmp> all_strings;
42 return **( all_strings.insert( std::make_unique<std::string>( std::move( str ) ) ).first );
116 if ( s.size() > 1 && ( s.front() ==
'\'' || s.front() ==
'\"' ) && s.front() == s.back() ) {
117 m_pValue->setTypeAndName( s.substr( 1, s.size() - 2 ) );
152 std::vector<std::string> tmp;
161 template <
typename C1,
typename C2,
typename BinaryPredicate>
162 bool equal_(
const C1& c1,
const C2& c2, BinaryPredicate&& p ) {
163 return std::equal( begin( c1 ), end( c1 ), begin( c2 ), end( c2 ), std::forward<BinaryPredicate>( p ) );
167 template <
typename String>
168 auto is_iByName( String&& name ) {
170 return p && equal_( name, p->name(), boost::algorithm::is_iequal{} );
193 if ( !p ) {
return nullptr; }
197 auto ifound = std::find_if( props.begin(), props.end(), is_iByName( name ) );
198 return ifound != props.end() ? *ifound :
nullptr;
219 if ( !p ) {
return nullptr; }
222 if ( !_i ) {
return nullptr; }
224 return property ?
getProperty( property, name ) :
nullptr;
275 if ( !p ) {
return nullptr; }
276 auto ifound = std::find_if( p->begin(), p->end(), is_iByName( name ) );
277 return p->end() != ifound ? *ifound :
nullptr;
293 const std::string& doc ) {
309 const std::string& doc ) {
313 if ( !doc.empty() ) {
342 const std::string& doc ) {
371 const std::string& doc ) {
372 return setProperty( component, name, &property, doc );
387 const std::string& doc ) {
405 const std::string& doc ) {
406 return setProperty( component, name, std::string{ value }, doc );
430 const std::string& doc ) {
458 const std::string& doc ) {
459 return setProperty( component, name, &property, doc );
462Gaudi::Details::WeakPropertyRef::operator std::string()
const {
471#ifndef GAUDI_PROPERTY_PARSING_ERROR_DEFAULT_POLICY
472# define GAUDI_PROPERTY_PARSING_ERROR_DEFAULT_POLICY Exception
474 ParsingErrorPolicy g_parsingErrorPolicy = ParsingErrorPolicy::GAUDI_PROPERTY_PARSING_ERROR_DEFAULT_POLICY;
478 auto tmp = g_parsingErrorPolicy;
479 g_parsingErrorPolicy = p;
485 struct InitParsingErrorPolicy {
486 InitParsingErrorPolicy() {
490 if (
System::getEnv(
"GAUDI_PROPERTY_PARSING_ERROR_DEFAULT_POLICY", policy ) ) {
491 switch ( policy[0] ) {
493 setParsingErrorPolicy( ParsingErrorPolicy::Ignore );
496 setParsingErrorPolicy( ParsingErrorPolicy::Warning );
499 setParsingErrorPolicy( ParsingErrorPolicy::Exception );
502 setParsingErrorPolicy( ParsingErrorPolicy::Abort );
509 } initParsingErrorPolicy;
const char *PyHelper getProperty(IInterface *p, char *name)
bool PyHelper setProperty(IInterface *p, char *name, char *value)
implementation of various functions for streaming.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
void setDocumentation(std::string value)
set the documentation string
virtual std::string toString() const =0
value -> string
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
const std::string name() const
property name
PropertyBase * m_property
Base class of array's of various gaudihandles.
bool setValue(const GaudiHandleArrayBase &value)
GaudiHandleArrayProperty(std::string name, GaudiHandleArrayBase &ref)
void toStream(std::ostream &out) const override
value -> stream
std::string toString() const override
value -> string
const GaudiHandleArrayBase & value() const
StatusCode fromString(const std::string &s) override
string -> value
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
GaudiHandleBase * m_pValue
Pointer to the real property.
const GaudiHandleBase & value() const
StatusCode fromString(const std::string &s) override
string -> value
std::string toString() const override
value -> string
GaudiHandleProperty(std::string name, GaudiHandleBase &ref)
void toStream(std::ostream &out) const override
value -> stream
bool setValue(const GaudiHandleBase &value)
Definition of the basic interface.
The IProperty is the basic interface for all components which have properties that can be set or get.
virtual StatusCode setPropertyRepr(const std::string &n, const std::string &r)=0
Set the property by name and value representation.
virtual bool hasProperty(std::string_view name) const =0
Return true if we have a property with the given name.
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
static std::string_view to_view(std::string str)
helper to map a string to a reliable std::string_view
Helper class to simplify the migration old properties deriving directly from PropertyBase.
bool useUpdateHandler() override
use the call-back function at update, if available
void useReadHandler() const
use the call-back function at reading, if available
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
ParsingErrorPolicy setParsingErrorPolicy(ParsingErrorPolicy p)
ParsingErrorPolicy parsingErrorPolicy()
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
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
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
GAUDI_API Gaudi::Details::PropertyBase * getProperty(const IProperty *p, std::string_view name)
simple function which gets the property with given name from the component
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
GAUDI_API bool hasProperty(const IProperty *p, std::string_view name)
simple function which check the existence of the property with the given name.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)