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> ) {
185 operator std::string_view()
const {
191 template <
typename T>
194 {
m_value == other } -> std::convertible_to<bool>;
201 template <
typename T>
204 {
m_value != other } -> std::convertible_to<bool>;
211 template <
typename T>
214 {
m_value < other } -> std::convertible_to<bool>;
221 template <
typename T>
223 requires requires {
m_value + other; }
229 template <
typename T>
230 requires( std::assignable_from<TYPE&, T &&> || std::constructible_from<TYPE, T &&> )
233 m_value = std::forward<T>( v );
238 template <
typename T = TYPE>
239 requires requires {
typename T::value_type; } &&
240 std::constructible_from<TYPE, std::initializer_list<typename T::value_type>>
242 return *
this = TYPE{ ilist };
268 requires requires {
value().size(); }
270 return value().size();
273 requires requires {
value().length(); }
275 return value().length();
278 requires requires {
value().empty(); }
280 return value().empty();
283 requires requires {
value().clear(); }
288 requires requires {
value().begin(); }
290 return value().begin();
293 requires requires {
value().end(); }
295 return value().end();
298 requires requires {
value().begin(); }
300 return value().begin();
303 requires requires {
value().end(); }
305 return value().end();
307 template <
typename ARG>
308 decltype( auto )
operator[](
const ARG& arg )
const
309 requires requires {
value()[arg]; }
313 template <
typename ARG>
314 decltype( auto )
operator[](
const ARG& arg )
315 requires requires {
value()[arg]; }
319 template <
typename K>
321 requires requires {
value().find(
key ); }
325 template <
typename K>
327 requires requires {
value().find(
key ); }
331 template <
typename T>
333 requires requires {
value().erase( arg ); }
335 return value().erase( arg );
338 requires requires { ++
m_value; }
344 requires requires {
m_value++; }
349 requires requires { --
value(); }
355 requires requires {
m_value--; }
359 template <
typename T>
361 requires requires {
m_value += other; }
366 template <
typename T>
368 requires requires {
m_value -= other; }
374 decltype( auto )
key()
const
375 requires requires {
value().key(); }
377 return value().key();
380 requires requires {
value().objKey(); }
382 return value().objKey();
385 requires requires {
value().fullKey(); }
387 return value().fullKey();
390 requires requires {
value().initialize(); }
392 return value().initialize();
395 requires requires {
value().makeHandles(); }
397 return value().makeHandles();
399 template <
typename ARG>
401 requires requires {
value().makeHandles( arg ); }
403 return value().makeHandles( arg );
408 template <
typename... Args>
409 requires std::invocable<
ValueType&, Args...>
410 constexpr decltype( auto )
operator()( Args&&... args )
const
411 noexcept( std::is_nothrow_invocable_v<ValueType&, Args...> ) {
412 return std::invoke(
value(), std::forward<Args>( args )... );
420 ( std::is_same_v<ValueType, std::string> ) ?
nullptr :
dynamic_cast<const Property*
>( &source );
431 return dest.assign( *
this );
439 }
catch (
const std::exception& err ) {
442 const std::string errMsg =
443 "Cannot convert '" + source +
"' for property '" +
name() +
"' in class '" +
ownerTypeName() +
"'";
444 switch ( parsingErrorPolicy() ) {
445 case ParsingErrorPolicy::Ignore:
447 case ParsingErrorPolicy::Exception:
450 case ParsingErrorPolicy::Warning:
451 std::cerr <<
"WARNING: " << errMsg <<
"': " << err.what() <<
'\n';
453 case ParsingErrorPolicy::Abort:
454 std::cerr <<
"FATAL: " << errMsg <<
"': " << err.what() <<
'\n';
467 void toStream( std::ostream& out )
const override {
475 template <
typename T,
typename TP,
typename V,
typename H>
477 return p.operator==( v );
481 template <
typename T,
typename TP,
typename V,
typename H>
483 return p.operator!=( v );
487 template <
typename T,
typename TP,
typename V,
typename H>
488 requires( !std::is_base_of_v<Details::PropertyBase, T> )
490 return v + p.value();
493 template <
typename TYPE,
typename HANDLERS = Details::Property::UpdateHandler>
494 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
496 template <
typename TYPE>
498 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
502template <
typename TYPE>
505template <
typename TYPE>
586template <
typename Handler =
typename Gaudi::Details::Property::UpdateHandler>
595 m_handlers.setReadHandler( std::move( fun ) );
600 m_handlers.setUpdateHandler( std::move( fun ) );
641 std::string
toString()
const override;
643 void toStream( std::ostream& out )
const override;
678 std::string
toString()
const override;
680 void toStream( std::ostream& out )
const override;
793 GAUDI_API bool hasProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
817 getProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
841 template <
typename TYPE>
865 template <
typename TYPE>
867 return setProperty( component, name, value, std::string() );
883 const std::string& doc =
"" );
898 const std::string& doc =
"" );
912 template <
unsigned N>
914 const std::string& doc =
"" ) {
947 template <
typename TYPE>
1022 template <
typename TYPE>
1024 const std::string& doc =
"" ) {
1025 return setProperty( component, name, &value, doc );
1047 template <
typename TYPE>
1049 const std::string& doc =
"" ) {
1067 const std::string& doc =
"" );
1081 const std::string& doc =
"" );
1095 template <
unsigned N>
1097 const std::string& doc =
"" ) {
1099 return setProperty( component, name, std::string{ value, value + N }, doc );
1169 template <
typename TYPE>
1171 const std::string& doc =
"" ) {
1172 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 & operator=(std::initializer_list< typename T::value_type > ilist)
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
Property(T &&v)
Construct an anonymous property from a value.
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
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)
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.
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value 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
StatusCode fromString(const std::string &source) override
string -> value
GaudiUtils::HashMap< std::string, T > StorageType
Property()
Construct an anonymous property with default constructed value.
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
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::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler > PropertyWithReadHandler
Property< TYPE, Details::Property::BoundedVerifier< TYPE >, HANDLERS > CheckedProperty
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...
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==
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)