39 using ValueType =
typename std::remove_reference<StorageType>::type;
50 template <
typename T = StorageType>
58 template <std::derived_from<IProperty> OWNER,
typename T = ValueType>
59 requires( std::is_default_constructible_v<T> )
61 owner->declareProperty( *
this );
67 template <std::derived_from<IProperty> OWNER,
typename T = StorageType>
70 owner->declareProperty( *
this );
76 template <std::derived_from<IProperty> OWNER,
typename T = StorageType>
78 std::string doc =
"", std::string
semantics =
"" )
85 template <std::derived_from<IProperty> OWNER,
typename T = StorageType>
87 std::string doc =
"", std::string
semantics =
"" )
90 [owner, handler](
PropertyBase& p ) { ( owner->*handler )( p ); }, std::move( doc ),
94 template <std::derived_from<IProperty> OWNER,
typename T = StorageType>
95 Property( OWNER* owner, std::string
name, T&&
value,
void ( OWNER::*handler )(), std::string doc =
"",
99 [owner, handler](
PropertyBase& ) { ( owner->*handler )(); }, std::move( doc ), std::move(
semantics ) ) {
104 template <std::derived_from<IProperty> OWNER,
typename T = StorageType>
115 template <
typename T>
116 requires( !std::is_same_v<Property, std::remove_reference_t<T>> )
117 [[deprecated(
"anonymous properties are deprecated" )]]
Property( T&& v )
122 template <
typename T = StorageType>
123 requires( !std::is_reference_v<T> )
131 m_handlers.setReadHandler( std::move( fun ) );
136 m_handlers.setUpdateHandler( std::move( fun ) );
166 operator std::string_view() const
174 std::ostream&
fillStream( std::ostream& stream )
const override {
175 stream <<
" '" <<
name() <<
"':";
176 if constexpr ( std::is_same_v<ValueType, std::string> ) {
186 template <
typename T>
189 {
m_value == other } -> std::convertible_to<bool>;
196 template <
typename T>
199 {
m_value != other } -> std::convertible_to<bool>;
206 template <
typename T>
209 {
m_value < other } -> std::convertible_to<bool>;
216 template <
typename T>
218 requires requires {
m_value + other; }
224 template <
typename T>
225 requires( std::assignable_from<TYPE&, T &&> || std::constructible_from<TYPE, T &&> )
228 m_value = std::forward<T>( v );
233 template <
typename T = TYPE>
234 requires requires {
typename T::value_type; } &&
235 std::constructible_from<TYPE, std::initializer_list<typename T::value_type>>
237 return *
this = TYPE{ ilist };
263 requires requires {
value().size(); }
265 return value().size();
268 requires requires {
value().length(); }
270 return value().length();
273 requires requires {
value().empty(); }
275 return value().empty();
278 requires requires {
value().clear(); }
283 requires requires {
value().begin(); }
285 return value().begin();
288 requires requires {
value().end(); }
290 return value().end();
293 requires requires {
value().begin(); }
295 return value().begin();
298 requires requires {
value().end(); }
300 return value().end();
302 template <
typename ARG>
303 decltype( auto )
operator[](
const ARG& arg )
const
304 requires requires {
value()[arg]; }
308 template <
typename ARG>
309 decltype( auto )
operator[](
const ARG& arg )
310 requires requires {
value()[arg]; }
314 template <
typename K>
316 requires requires {
value().find(
key ); }
320 template <
typename K>
322 requires requires {
value().find(
key ); }
326 template <
typename T>
328 requires requires {
value().erase( arg ); }
330 return value().erase( arg );
333 requires requires { ++
m_value; }
339 requires requires {
m_value++; }
344 requires requires { --
value(); }
350 requires requires {
m_value--; }
354 template <
typename T>
356 requires requires {
m_value += other; }
361 template <
typename T>
363 requires requires {
m_value -= other; }
369 decltype( auto )
key()
const
370 requires requires {
value().key(); }
372 return value().key();
375 requires requires {
value().objKey(); }
377 return value().objKey();
380 requires requires {
value().fullKey(); }
382 return value().fullKey();
385 requires requires {
value().initialize(); }
387 return value().initialize();
390 requires requires {
value().makeHandles(); }
392 return value().makeHandles();
394 template <
typename ARG>
396 requires requires {
value().makeHandles( arg ); }
398 return value().makeHandles( arg );
403 template <
typename... Args>
404 requires std::invocable<
ValueType&, Args...>
405 constexpr decltype( auto )
operator()( Args&&... args )
const
406 noexcept( std::is_nothrow_invocable_v<ValueType&, Args...> ) {
407 return std::invoke(
value(), std::forward<Args>( args )... );
415 ( std::is_same_v<ValueType, std::string> ) ?
nullptr :
dynamic_cast<const Property*
>( &source );
426 return dest.assign( *
this );
434 }
catch (
const std::exception& err ) {
437 const std::string errMsg =
438 "Cannot convert '" + source +
"' for property '" +
name() +
"' in class '" +
ownerTypeName() +
"'";
439 switch ( parsingErrorPolicy() ) {
440 case ParsingErrorPolicy::Ignore:
442 case ParsingErrorPolicy::Exception:
445 case ParsingErrorPolicy::Warning:
446 std::cerr <<
"WARNING: " << errMsg <<
"': " << err.what() <<
'\n';
448 case ParsingErrorPolicy::Abort:
449 std::cerr <<
"FATAL: " << errMsg <<
"': " << err.what() <<
'\n';
462 void toStream( std::ostream& out )
const override {
470 template <
typename T,
typename TP,
typename V,
typename H>
472 return p.operator==( v );
476 template <
typename T,
typename TP,
typename V,
typename H>
478 return p.operator!=( v );
482 template <
typename T,
typename TP,
typename V,
typename H>
483 requires( !std::is_base_of_v<Details::PropertyBase, T> )
485 return v + p.
value();
488 template <
typename TYPE,
typename HANDLERS = Details::Property::UpdateHandler>
489 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
491 template <
typename TYPE>
493 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
497template <
typename TYPE>
500template <
typename TYPE>
581template <
typename Handler =
typename Gaudi::Details::Property::UpdateHandler>
590 m_handlers.setReadHandler( std::move( fun ) );
595 m_handlers.setUpdateHandler( std::move( fun ) );
636 std::string
toString()
const override;
638 void toStream( std::ostream& out )
const override;
673 std::string
toString()
const override;
675 void toStream( std::ostream& out )
const override;
788 GAUDI_API bool hasProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
812 getProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
836 template <
typename TYPE>
860 template <
typename TYPE>
862 return setProperty( component, name, value, std::string() );
878 const std::string& doc =
"" );
893 const std::string& doc =
"" );
907 template <
unsigned N>
909 const std::string& doc =
"" ) {
942 template <
typename TYPE>
1017 template <
typename TYPE>
1019 const std::string& doc =
"" ) {
1020 return setProperty( component, name, &value, doc );
1042 template <
typename TYPE>
1044 const std::string& doc =
"" ) {
1062 const std::string& doc =
"" );
1076 const std::string& doc =
"" );
1090 template <
unsigned N>
1092 const std::string& doc =
"" ) {
1094 return setProperty( component, name, std::string{ value, value + N }, doc );
1164 template <
typename TYPE>
1166 const std::string& doc =
"" ) {
1167 return setProperty( component, name, &value, doc );
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Gaudi::Property< float & > FloatPropertyRef
Gaudi::Property< std::vector< int > > IntegerArrayProperty
Gaudi::Property< TYPE > SimpleProperty
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Gaudi::Property< int & > IntegerPropertyRef
Gaudi::Property< std::vector< long > > LongArrayProperty
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Gaudi::Property< std::vector< short > > ShortArrayProperty
Gaudi::Property< bool & > BooleanPropertyRef
Gaudi::Property< int > IntegerProperty
Gaudi::Property< unsigned long > UnsignedLongProperty
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
Gaudi::Property< double & > DoublePropertyRef
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
Gaudi::Property< long double & > LongDoublePropertyRef
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Gaudi::Property< std::vector< double > > DoubleArrayProperty
Gaudi::Property< long long > LongLongProperty
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Gaudi::Property< std::vector< float > > FloatArrayProperty
Gaudi::Property< unsigned char > UnsignedCharProperty
Gaudi::Property< char & > CharPropertyRef
Gaudi::Property< unsigned short > UnsignedShortProperty
Gaudi::Property< float > FloatProperty
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Gaudi::Property< long double > LongDoubleProperty
Gaudi::Property< bool > BooleanProperty
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Gaudi::Property< long > LongProperty
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Gaudi::Property< signed char & > SignedCharPropertyRef
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Gaudi::Property< signed char > SignedCharProperty
Gaudi::Property< TYPE & > SimplePropertyRef
Gaudi::Property< long long & > LongLongPropertyRef
Gaudi::Property< char > CharProperty
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Gaudi::Property< long & > LongPropertyRef
Gaudi::Property< short & > ShortPropertyRef
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
Gaudi::Property< short > ShortProperty
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Gaudi::Property< std::vector< char > > CharArrayProperty
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Gaudi::Property< std::string & > StringPropertyRef
Gaudi::Property< std::string > StringProperty
Gaudi::Property< double > DoubleProperty
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
implementation of various functions for streaming.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
PropertyBase(const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
constructor from the property name and the type
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
void setOwnerType()
set the type of the owner class (used for documentation)
virtual std::string toString() const =0
value -> string
virtual void toStream(std::ostream &out) const =0
value -> stream
virtual StatusCode fromString(const std::string &value)=0
string -> value
std::string semantics() const
property semantics
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
const std::string name() const
property name
Implementation of property with value of concrete type.
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
void toStream(std::ostream &out) const override
value -> stream
bool operator!=(const T &other) const
inequality comparison
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(), std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
Property & operator+=(const T &other)
Details::PropertyBase * clone() const override
clones the current property
decltype(auto) erase(T arg)
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(PropertyBase &), std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
bool load(Details::PropertyBase &dest) const override
set value to another property
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, Details::Property::ImmediatelyInvokeHandler invoke, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
std::ostream & fillStream(std::ostream &stream) const override
Properly quote string properties when printing them.
const VerifierType & verifier() const
Accessor to verifier.
Property(OWNER *owner, std::string name, T &&value, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value and documentation.
bool operator==(const T &other) const
equality comparison
decltype(auto) initialize()
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
const ValueType & value() const
Property()
Construct an anonymous property with default constructed value.
auto operator+(const T &other) const
allow addition if possible between the property and the other types
decltype(auto) key() const
std::string toString() const override
value -> string
decltype(auto) find(const K &key)
Details::Property::NullVerifier VerifierType
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
bool set(const ValueType &v)
bool assign(const Details::PropertyBase &source) override
get the value from another property
decltype(auto) makeHandles() const
bool setValue(const ValueType &v)
operator std::string_view() const
decltype(auto) makeHandles(const ARG &arg) const
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
bool useUpdateHandler() override
manual trigger for callback for update
decltype(auto) fullKey() const
decltype(auto) find(const K &key) const
Property & operator-=(const T &other)
bool operator<(const T &other) const
"less" comparison
Property(T &&v)
Construct an anonymous property from a value.
StatusCode fromString(const std::string &source) override
string -> value
GaudiUtils::HashMap< std::string, T > StorageType
Property & operator=(std::initializer_list< typename T::value_type > ilist)
Details::Property::UpdateHandler HandlersType
decltype(auto) objKey() const
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
typename std::remove_reference< StorageType >::type ValueType
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
VerifierType & verifier()
Accessor to verifier.
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Define general base for Gaudi exception.
Base class of array's of various gaudihandles.
GaudiHandleArrayProperty * clone() const override
clones the current property
bool load(PropertyBase &destination) const override
bool setValue(const GaudiHandleArrayBase &value)
GaudiHandleArrayProperty(std::string name, GaudiHandleArrayBase &ref)
bool assign(const PropertyBase &source) override
const GaudiHandleArrayBase & value() const
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
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
GaudiHandleProperty(std::string name, GaudiHandleBase &ref)
GaudiHandleProperty * clone() const override
clones the current property
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
bool setValue(const GaudiHandleBase &value)
bool load(PropertyBase &destination) const override
bool assign(const PropertyBase &source) override
Property< TYPE, Details::Property::BoundedVerifier< TYPE >, HANDLERS > CheckedProperty
Property< TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler > PropertyWithReadHandler
Definition of the basic interface.
The IProperty is the basic interface for all components which have properties that can be set or get.
PropertyBase(const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
constructor from the property name and the type
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
virtual std::string toString() const =0
value -> string
Helper class to simplify the migration old properties deriving directly from PropertyBase.
bool useUpdateHandler() override
use the call-back function at update, if available
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
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.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
Gaudi::tagged_bool< class ImmediatelyInvokeHandler_tag > ImmediatelyInvokeHandler
ParsingErrorPolicy parsingErrorPolicy()
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.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==