1 #ifndef GAUDIKERNEL_PROPERTY_H 2 #define GAUDIKERNEL_PROPERTY_H 68 virtual bool useUpdateHandler() = 0;
72 return declareReadHandler( [=](
PropertyBase& p ) { ( instance->*MF )( p ); } );
77 return declareUpdateHandler( [=](
PropertyBase& p ) { ( instance->*MF )( p ); } );
96 template <
class OWNER>
98 setOwnerType(
typeid( OWNER ) );
112 : m_name( to_view(
std::move(
name ) ) )
113 , m_documentation( to_view(
std::move( doc ) ) )
114 , m_typeinfo( &
type ) {}
117 : m_name( to_view(
std::move(
name ) ) ), m_documentation( m_name ), m_typeinfo( &
type ) {}
125 static std::string_view to_view(
std::string str );
165 template <
class TYPE>
182 if ( !
parse( buffer, InputData{
s} ).isSuccess() ) {
200 template <
typename TYPE,
typename Enable =
void>
203 TYPE buffer = ref_value;
209 template <
class TYPE>
220 template <
typename TYPE>
221 struct StringConverter : DefaultStringConverter<TYPE> {};
224 template <
class TYPE>
227 template <
class TYPE>
303 throw std::logic_error(
"setUpdateHandler not implemented for this class" );
350 template <
class TYPE,
class VERIFIER = Details::Property::NullVerifier,
351 class HANDLERS = Details::Property::UpdateHandler>
370 static inline constexpr
bool is_this_type_v = std::is_same_v<Property, std::remove_reference_t<T>>;
377 template <
class T = StorageType>
385 template <
typename OWNER,
typename T = ValueType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>,
386 typename = std::enable_if_t<std::is_default_constructible_v<T>>>
388 owner->declareProperty( *
this );
389 setOwnerType<OWNER>();
394 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
397 owner->declareProperty( *
this );
398 setOwnerType<OWNER>();
403 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
412 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
420 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
428 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
438 template <
typename T,
typename = not_copying<T>>
443 template <
typename T = StorageType,
typename = std::enable_if_t<!std::is_reference_v<T>>>
506 decltype(
auto ) operator+( const T& other )
const {
511 template <
class T = ValueType>
514 m_value = std::forward<T>( v );
542 template <
class T = const ValueType>
543 decltype(
auto )
size()
const {
544 return value().size();
546 template <
class T = const ValueType>
547 decltype(
auto ) length()
const {
548 return value().length();
550 template <
class T = const ValueType>
551 decltype(
auto ) empty()
const {
552 return value().empty();
554 template <
class T = ValueType>
555 decltype(
auto ) clear() {
558 template <
class T = const ValueType>
559 decltype(
auto )
begin()
const {
560 return value().begin();
562 template <
class T = const ValueType>
563 decltype(
auto )
end()
const {
564 return value().end();
566 template <
class T = ValueType>
567 decltype(
auto )
begin() {
568 return value().begin();
570 template <
class T = ValueType>
571 decltype(
auto )
end() {
572 return value().end();
575 decltype(
auto ) operator[]( const ARG& arg )
const {
579 decltype(
auto ) operator[]( const ARG& arg ) {
582 template <
class T = const ValueType>
583 decltype(
auto ) find( const typename T::key_type& key )
const {
584 return value().find( key );
586 template <
class T = ValueType>
587 decltype(
auto ) find( const typename T::key_type& key ) {
588 return value().find( key );
590 template <
class ARG,
class T = ValueType>
591 decltype(
auto ) erase( ARG arg ) {
592 return value().erase( arg );
594 template <
class = ValueType>
599 template <
class = ValueType>
603 template <
class = ValueType>
608 template <
class = ValueType>
612 template <
class T = ValueType>
617 template <
class T = ValueType>
623 template <
class T = const ValueType>
624 decltype(
auto ) key()
const {
625 return value().key();
627 template <
class T = const ValueType>
628 decltype(
auto ) objKey()
const {
629 return value().objKey();
631 template <
class T = const ValueType>
632 decltype(
auto ) fullKey()
const {
633 return value().fullKey();
635 template <
class T = ValueType>
636 decltype(
auto ) initialize() {
637 return value().initialize();
639 template <
class T = ValueType>
640 decltype(
auto ) makeHandles()
const {
641 return value().makeHandles();
643 template <
class ARG,
class T = ValueType>
644 decltype(
auto ) makeHandles( const ARG& arg )
const {
645 return value().makeHandles( arg );
651 template <
class... Args>
652 decltype( std::declval<ValueType>()( std::declval<Args&&>()... ) ) operator()( Args&&...
args ) const
653 noexcept( noexcept(
std::declval<
ValueType>()(
std::declval<Args&&>()... ) ) ) {
654 return value()( std::forward<Args>(
args )... );
662 ( std::is_same_v<ValueType, std::string> ) ?
nullptr : dynamic_cast<const Property*>( &source );
673 return dest.assign( *
this );
677 using Converter = Details::Property::StringConverter<ValueType>;
683 using Converter = Details::Property::StringConverter<ValueType>;
695 template <
class T,
class TP,
class V,
class H>
701 template <
class T,
class TP,
class V,
class H>
707 template <
class T,
class TP,
class V,
class H>
708 decltype(
auto ) operator+( const T& v, const
Property<TP, V, H>& p ) {
709 return v + p.
value();
712 template <
class TYPE,
class HANDLERS = Details::Property::UpdateHandler>
715 template <
class TYPE>
721 template <
class TYPE>
724 template <
class TYPE>
805 template <
typename Handler =
typename Gaudi::Details::Property::UpdateHandler>
810 using PropertyBase::PropertyBase;
856 bool load( PropertyBase& destination )
const override {
return destination.assign( *
this ); }
858 bool assign(
const PropertyBase& source )
override {
return fromString( source.toString() ).isSuccess(); }
893 bool load( PropertyBase& destination )
const override {
return destination.assign( *
this ); }
895 bool assign(
const PropertyBase& source )
override {
return fromString( source.toString() ).isSuccess(); }
1067 template <
class TYPE>
1092 template <
class TYPE>
1142 template <
unsigned N>
1178 template <
class TYPE>
1256 template <
class TYPE>
1282 template <
class TYPE>
1333 template <
unsigned N>
1410 template <
class TYPE>
1421 #endif // GAUDIKERNEL_PROPERTY_H Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
std::string toString() const override
value -> string
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
Gaudi::Property< signed char & > SignedCharPropertyRef
Details::Property::NullVerifier VerifierType
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
constexpr auto size(const T &, Args &&...) noexcept
bool m_hasLowerBound
Data members.
Property(OWNER *owner, std::string name)
Autodeclaring constructor with property name, value and documentation.
std::function< void(PropertyBase &)> m_readCallBack
std::function< void(PropertyBase &)> getUpdateHandler() const
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
TYPE fromString(const TYPE &ref_value, const std::string &s) final override
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, Details::Property::ImmediatelyInvokeHandler invoke, std::string doc="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
bool setValue(const ValueType &v)
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::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
Gaudi::Property< TYPE > SimpleProperty
Gaudi::Property< long long & > LongLongPropertyRef
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
static constexpr bool is_this_type_v
helper typedefs for SFINAE
Gaudi::Property< std::vector< int > > IntegerArrayProperty
std::ostream & operator<<(std::ostream &stream, const PropertyBase &prop)
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
bool useUpdateHandler() override
manual trigger for callback for update
void setDocumentation(std::string value)
set the documentation string
Gaudi::Property< long long > LongLongProperty
const GaudiHandleArrayBase & value() const
Implementation of property with value of concrete type.
Gaudi::Property< long & > LongPropertyRef
std::enable_if_t<!is_this_type_v< T > > not_copying
std::function< void(PropertyBase &)> m_updateCallBack
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
bool load(PropertyBase &destination) const override
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
bool hasLower() const
Return if it has a lower bound.
Property & operator=(T &&v)
Assignment from value.
Gaudi::Property< float > FloatProperty
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
GAUDI_API bool hasProperty(const IProperty *p, const std::string &name)
simple function which check the existence of the property with the given name.
Gaudi::Property< int > IntegerProperty
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
void setOwnerType()
set the type of the owner class (used for documentation)
void clearUpper()
Clear upper bound value.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Gaudi::tagged_bool< class ImmediatelyInvokeHandler_tag > ImmediatelyInvokeHandler
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
Gaudi::Property< float & > FloatPropertyRef
vector< std::string > StorageType
Hosted type.
constexpr static const auto SUCCESS
std::function< void(PropertyBase &)> getReadHandler() const
virtual void toStream(std::ostream &out) const =0
value -> stream
virtual TYPE fromString(const TYPE &ref_value, const std::string &s)=0
Gaudi::Property< std::vector< std::string > > StringArrayProperty
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
std::string toString(const TYPE &v)
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(), std::string doc="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
const TYPE & upper() const
Return the upper bound value.
void setLower(const TYPE &value)
Set lower bound value.
Gaudi::Property< unsigned short > UnsignedShortProperty
Gaudi::Property< unsigned long > UnsignedLongProperty
bool load(PropertyBase &destination) const override
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Gaudi::Property< std::string & > StringPropertyRef
StorageType m_value
Storage.
std::string_view m_name
property name
Gaudi::Property< char & > CharPropertyRef
const std::string name() const
property name
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
Gaudi::Property< std::vector< double > > DoubleArrayProperty
void setOwnerType(const std::type_info &ownerType)
set the type of the owner class (used for documentation)
Gaudi::Property< std::vector< short > > ShortArrayProperty
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
PropertyBase(const std::type_info &type, std::string name="", std::string doc="")
constructor from the property name and the type
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Property()
Construct an anonymous property with default constructed value.
virtual StatusCode fromString(const std::string &value)=0
string -> value
Helper class to simplify the migration old properties deriving directly from PropertyBase.
void operator()(const TYPE &) const
Property & operator+=(const T &other)
const std::type_info * type_info() const
property type-info
Gaudi::Property< std::vector< long > > LongArrayProperty
typename std::remove_reference< StorageType >::type ValueType
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Gaudi::Property< signed char > SignedCharProperty
Details::PropertyBase * clone() const override
clones the current property
Gaudi::Property< char > CharProperty
Property & operator-=(const T &other)
Gaudi::Property< int & > IntegerPropertyRef
GaudiHandleBase * m_pValue
Pointer to the real property.
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
const TYPE & lower() const
Return the lower bound value.
Property(OWNER *owner, std::string name, T &&value, void(OWNER::*handler)(PropertyBase &), std::string doc="")
Autodeclaring constructor with property name, value, pointer to member function updateHandler and doc...
GaudiHandleProperty * clone() const override
clones the current property
PropertyBase(std::string name, const std::type_info &type)
constructor from the property name and the type
void setBounds(const TYPE &lower, const TYPE &upper)
Set both bounds (lower and upper) at the same time.
void operator()(PropertyBase &p) const
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
TYPE fromString(const TYPE &, const std::string &s) final override
bool load(Details::PropertyBase &dest) const override
set value to another property
This class is used for returning status codes from appropriate routines.
void useReadHandler(const PropertyBase &) const
Property(std::string name, T &&value, std::string doc="")
the constructor with property name, value and documentation.
const ValueType & value() const
Backward compatibility (.
Definition of the basic interface.
const std::type_info * m_typeinfo
property type
Gaudi::Property< unsigned int > UnsignedIntegerProperty
void toStream(std::ostream &out) const override
value -> stream
std::function< void(PropertyBase &)> getReadHandler() const
Gaudi::Property< std::vector< char > > CharArrayProperty
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
Gaudi::Property< bool > BooleanProperty
const std::type_info * ownerType() const
get the type of the owner class (used for documentation)
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
VerifierType & verifier()
Accessor to verifier.
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
bool operator<(const T &other) const
"less" comparison
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
PropertyBase & declareUpdateHandler(void(HT::*MF)(PropertyBase &), HT *instance)
void fromStringImpl(TYPE &buffer, const std::string &s)
std::ostream & toStream(const DataObjID &d, std::ostream &os)
std::string_view m_documentation
property doc string
Gaudi::Property< double > DoubleProperty
GaudiHandleArrayProperty * clone() const override
clones the current property
void setName(std::string value)
set the new value for the property name
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
bool assign(const PropertyBase &source) override
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
Gaudi::Property< double & > DoublePropertyRef
void useReadHandler(const PropertyBase &p) const
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
StatusCode parse(DataObjID &dest, const std::string &src)
Base class of array's of various gaudihandles.
Gaudi::Property< long double & > LongDoublePropertyRef
std::string type() const
property type
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
bool useUpdateHandler() override
use the call-back function at update, if available
Gaudi::Property< std::string > StringProperty
void setUpdateHandler(std::function< void(PropertyBase &)> fun)
Gaudi::Property< long double > LongDoubleProperty
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
virtual ~DefaultStringConverterImpl()=default
SwapCall(callback_t &input)
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
Gaudi::Property< short > ShortProperty
bool set(const ValueType &v)
std::function< void(PropertyBase &)> getUpdateHandler() const
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
Gaudi::Property< TYPE & > SimplePropertyRef
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
constexpr static const auto FAILURE
void operator()(const TYPE &value) const
bool operator!=(const T &other) const
inequality comparison
void clearBounds()
Clear both bounds (lower and upper) at the same time.
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
void setReadHandler(std::function< void(PropertyBase &)> fun)
const VerifierType & verifier() const
Accessor to verifier.
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
bool assign(const Details::PropertyBase &source) override
get the value from another property
bool assign(const PropertyBase &source) override
Gaudi::Property< long > LongProperty
void setUpdateHandler(std::function< void(PropertyBase &)>)
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
Property(OWNER *owner, std::string name, T &&value, std::function< void(PropertyBase &)> handler, std::string doc="")
Autodeclaring constructor with property name, value, updateHandler and documentation.
void clearLower()
Clear lower bound value.
Base class to handles to be used in lieu of naked pointers to various Gaudi components.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
bool hasUpper() const
Return if it has a lower bound.
const GaudiHandleBase & value() const
implementation of various functions for streaming.
Property(T &&v)
Construct an anonymous property from a value.
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
Gaudi::Property< std::vector< float > > FloatArrayProperty
ValueType operator++(int)
The IProperty is the basic interface for all components which have properties that can be set or get.
helper to disable a while triggering it, to avoid infinite recursion
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef
Property(OWNER *owner, std::string name, T &&value, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
virtual std::string toString() const =0
value -> string
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
void useUpdateHandler(const PropertyBase &) const
Header file for std:chrono::duration-based Counters.
Gaudi::Property< unsigned char > UnsignedCharProperty
Gaudi::Property< short & > ShortPropertyRef
void setUpper(const TYPE &value)
Set upper bound value.
std::string documentation() const
property documentation
void setReadHandler(std::function< void(PropertyBase &)>)
Details::Property::UpdateHandler HandlersType
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
ValueType operator--(int)
Gaudi::Property< std::vector< bool > > BooleanArrayProperty
Gaudi::Property< std::vector< unsigned int > & > UnsignedIntegerArrayPropertyRef
bool operator==(const T &other) const
equality comparison
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
StatusCode fromString(const std::string &source) override
string -> value
GAUDI_API Gaudi::Details::PropertyBase * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
Gaudi::Property< bool & > BooleanPropertyRef
void useUpdateHandler(PropertyBase &p)
void useReadHandler() const
use the call-back function at reading, if available