39 using ValueType =
typename std::remove_reference<StorageType>::type;
50 template <
class 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,
class T = StorageType>
70 owner->declareProperty( *
this );
76 template <std::derived_from<IProperty> OWNER,
class T = StorageType>
78 std::string doc =
"", std::string
semantics =
"" )
85 template <std::derived_from<IProperty> OWNER,
class 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,
class 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,
class 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 template <
typename Dummy = TYPE>
167 requires( std::is_constructible_v<std::string_view, Dummy> )
168 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 {
210 decltype( auto )
operator+(
const T& other )
const {
215 template <
class T = ValueType>
218 m_value = std::forward<T>( v );
245 template <
class T = const ValueType>
246 decltype( auto )
size()
const {
247 return value().size();
249 template <class T = const ValueType, typename = decltype( std::declval<const T>().length() )>
251 return value().length();
253 template <
class T = const ValueType>
255 return value().empty();
257 template <
class T = ValueType>
261 template <class T = const ValueType, typename = decltype( std::declval<const T>().begin() )>
263 return value().begin();
265 template <
class T = const ValueType>
266 decltype( auto )
end()
const {
267 return value().end();
269 template <class T = ValueType, typename = decltype( std::declval<T>().begin() )>
271 return value().begin();
273 template <
class T = ValueType>
275 return value().end();
278 decltype( auto )
operator[](
const ARG& arg )
const {
282 decltype( auto )
operator[](
const ARG& arg ) {
285 template <
class T = const ValueType>
286 decltype( auto )
find(
const typename T::key_type&
key )
const {
289 template <
class T = ValueType>
290 decltype( auto )
find(
const typename T::key_type&
key ) {
293 template <
class ARG,
class T = ValueType>
295 return value().erase( arg );
297 template <
class = ValueType>
302 template <
class = ValueType>
306 template <
class = ValueType>
311 template <
class = ValueType>
315 template <
class T = ValueType>
320 template <
class T = ValueType>
326 template <
class T = const ValueType>
327 decltype( auto )
key()
const {
328 return value().key();
330 template <
class T = const ValueType>
332 return value().objKey();
334 template <
class T = const ValueType>
336 return value().fullKey();
338 template <
class T = ValueType>
340 return value().initialize();
342 template <
class T = ValueType>
344 return value().makeHandles();
346 template <
class ARG,
class T = ValueType>
348 return value().makeHandles( arg );
353 template <
class... Args>
354 decltype( std::declval<ValueType>()( std::declval<Args&&>()... ) )
operator()( Args&&... args )
const
355 noexcept(
noexcept( std::declval<ValueType>()( std::declval<Args&&>()... ) ) ) {
356 return value()( std::forward<Args>( args )... );
364 ( std::is_same_v<ValueType, std::string> ) ?
nullptr :
dynamic_cast<const Property*
>( &source );
375 return dest.assign( *
this );
383 }
catch (
const std::exception& err ) {
386 const std::string errMsg =
387 "Cannot convert '" + source +
"' for property '" +
name() +
"' in class '" +
ownerTypeName() +
"'";
388 switch ( parsingErrorPolicy() ) {
389 case ParsingErrorPolicy::Ignore:
391 case ParsingErrorPolicy::Exception:
394 case ParsingErrorPolicy::Warning:
395 std::cerr <<
"WARNING: " << errMsg <<
"': " << err.what() <<
'\n';
397 case ParsingErrorPolicy::Abort:
398 std::cerr <<
"FATAL: " << errMsg <<
"': " << err.what() <<
'\n';
411 void toStream( std::ostream& out )
const override {
419 template <
class T,
class TP,
class V,
class H>
421 return p.operator==( v );
425 template <
class T,
class TP,
class V,
class H>
427 return p.operator!=( v );
431 template <
class T,
class TP,
class V,
class H>
433 return v + p.value();
436 template <
class TYPE,
class HANDLERS = Details::Property::UpdateHandler>
437 using CheckedProperty = Property<TYPE, Details::Property::BoundedVerifier<TYPE>, HANDLERS>;
439 template <
class TYPE>
441 Property<TYPE, Details::Property::NullVerifier, Gaudi::Details::Property::ReadUpdateHandler>;
529template <
typename Handler =
typename Gaudi::Details::Property::UpdateHandler>
538 m_handlers.setReadHandler( std::move( fun ) );
543 m_handlers.setUpdateHandler( std::move( fun ) );
584 std::string
toString()
const override;
586 void toStream( std::ostream& out )
const override;
621 std::string
toString()
const override;
623 void toStream( std::ostream& out )
const override;
736 GAUDI_API bool hasProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
760 getProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view name );
784 template <
class TYPE>
808 template <
class TYPE>
810 return setProperty( component, name, value, std::string() );
826 const std::string& doc =
"" );
841 const std::string& doc =
"" );
855 template <
unsigned N>
857 const std::string& doc =
"" ) {
890 template <
class TYPE>
965 template <
class TYPE>
967 const std::string& doc =
"" ) {
968 return setProperty( component, name, &value, doc );
990 template <
class TYPE>
992 const std::string& doc =
"" ) {
1010 const std::string& doc =
"" );
1024 const std::string& doc =
"" );
1038 template <
unsigned N>
1040 const std::string& doc =
"" ) {
1042 return setProperty( component, name, std::string{ value, value + N }, doc );
1112 template <
class TYPE>
1114 const std::string& doc =
"" ) {
1115 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.
bool operator<(const T &other) const
"less" comparison
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
decltype(auto) objKey() const
Property(T &&v)
Construct an anonymous property from a value.
decltype(auto) erase(ARG arg)
bool operator!=(const T &other) const
inequality comparison
void toStream(std::ostream &out) const override
value -> stream
decltype(std::declval< ValueType >()(std::declval< Args && >()...)) operator()(Args &&... args) const noexcept(noexcept(std::declval< ValueType >()(std::declval< Args && >()...)))
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...
decltype(auto) empty() const
Details::PropertyBase * clone() const override
clones the current property
decltype(auto) makeHandles() const
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.
decltype(auto) end() const
decltype(auto) key() const
Property & operator-=(const T &other)
decltype(auto) size() const
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
const ValueType & value() const
decltype(auto) find(const typename T::key_type &key)
ValueType operator++(int)
decltype(auto) makeHandles(const ARG &arg) const
decltype(auto) find(const typename T::key_type &key) const
bool operator==(const T &other) const
equality comparison
Property & operator+=(const T &other)
Property & operator=(T &&v)
Assignment from value.
decltype(auto) begin() const
decltype(auto) initialize()
std::string toString() const override
value -> string
ValueType operator--(int)
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
bool setValue(const ValueType &v)
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
StatusCode fromString(const std::string &source) override
string -> value
GaudiUtils::HashMap< std::string, T > StorageType
decltype(auto) length() const
Property()
Construct an anonymous property with default constructed value.
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==