11 #ifndef GAUDIKERNEL_PROPERTY_H 12 #define GAUDIKERNEL_PROPERTY_H 18 #include <string_view> 80 virtual bool useUpdateHandler() = 0;
84 return declareReadHandler( [=](
PropertyBase& p ) { ( instance->*MF )( p ); } );
89 return declareUpdateHandler( [=](
PropertyBase& p ) { ( instance->*MF )( p ); } );
110 template <
class OWNER>
112 setOwnerType(
typeid( OWNER ) );
127 : m_name( to_view(
std::move(
name ) ) )
128 , m_documentation( to_view(
std::move( doc ) ) )
129 , m_semantics( to_view(
std::move( semantics ) ) )
130 , m_typeinfo( &
type ) {}
133 : m_name( to_view(
std::move(
name ) ) ), m_documentation( m_name ), m_typeinfo( &
type ) {}
141 static std::string_view to_view(
std::string str );
183 template <
class TYPE>
200 if ( !
parse( buffer, InputData{
s} ).isSuccess() ) {
218 template <
typename TYPE,
typename Enable =
void>
221 TYPE buffer = ref_value;
227 template <
class TYPE>
238 template <
typename TYPE>
239 struct StringConverter : DefaultStringConverter<TYPE> {};
242 template <
class TYPE>
245 template <
class TYPE>
321 throw std::logic_error(
"setUpdateHandler not implemented for this class" );
368 template <
class TYPE,
class VERIFIER = Details::Property::NullVerifier,
369 class HANDLERS = Details::Property::UpdateHandler>
388 static inline constexpr
bool is_this_type_v = std::is_same_v<Property, std::remove_reference_t<T>>;
395 template <
class T = StorageType>
403 template <
typename OWNER,
typename T = ValueType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>,
404 typename = std::enable_if_t<std::is_default_constructible_v<T>>>
406 owner->declareProperty( *
this );
407 setOwnerType<OWNER>();
412 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of<IProperty, OWNER>::value>>
415 owner->declareProperty( *
this );
416 setOwnerType<OWNER>();
421 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
430 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
439 template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of<IProperty, OWNER>::value>>
449 template <
class OWNER,
class T = StorageType,
typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
460 template <
typename T,
typename = not_copying<T>>
465 template <
typename T = StorageType,
typename = std::enable_if_t<!std::is_reference_v<T>>>
508 template <
typename Dummy = TYPE,
typename = std::enable_if_t<std::is_constructible_v<std::
string_view, Dummy>>>
509 operator std::string_view()
const {
534 decltype(
auto ) operator+( const T& other )
const {
539 template <
class T = ValueType>
542 m_value = std::forward<T>( v );
570 template <
class T = const ValueType>
571 decltype(
auto )
size()
const {
572 return value().size();
574 template <
class T = const ValueType>
575 decltype(
auto ) length()
const {
576 return value().length();
578 template <
class T = const ValueType>
579 decltype(
auto ) empty()
const {
580 return value().empty();
582 template <
class T = ValueType>
583 decltype(
auto ) clear() {
586 template <
class T = const ValueType>
587 decltype(
auto )
begin()
const {
588 return value().begin();
590 template <
class T = const ValueType>
591 decltype(
auto )
end()
const {
592 return value().end();
594 template <
class T = ValueType>
595 decltype(
auto )
begin() {
596 return value().begin();
598 template <
class T = ValueType>
599 decltype(
auto )
end() {
600 return value().end();
603 decltype(
auto ) operator[]( const ARG& arg )
const {
607 decltype(
auto ) operator[]( const ARG& arg ) {
610 template <
class T = const ValueType>
611 decltype(
auto ) find( const typename T::key_type& key )
const {
612 return value().find( key );
614 template <
class T = ValueType>
615 decltype(
auto ) find( const typename T::key_type& key ) {
616 return value().find( key );
618 template <
class ARG,
class T = ValueType>
619 decltype(
auto ) erase( ARG arg ) {
620 return value().erase( arg );
622 template <
class = ValueType>
627 template <
class = ValueType>
631 template <
class = ValueType>
636 template <
class = ValueType>
640 template <
class T = ValueType>
645 template <
class T = ValueType>
651 template <
class T = const ValueType>
652 decltype(
auto ) key()
const {
653 return value().key();
655 template <
class T = const ValueType>
656 decltype(
auto ) objKey()
const {
657 return value().objKey();
659 template <
class T = const ValueType>
660 decltype(
auto ) fullKey()
const {
661 return value().fullKey();
663 template <
class T = ValueType>
664 decltype(
auto ) initialize() {
665 return value().initialize();
667 template <
class T = ValueType>
668 decltype(
auto ) makeHandles()
const {
669 return value().makeHandles();
671 template <
class ARG,
class T = ValueType>
672 decltype(
auto ) makeHandles( const ARG& arg )
const {
673 return value().makeHandles( arg );
679 template <
class... Args>
680 decltype( std::declval<ValueType>()( std::declval<Args&&>()... ) ) operator()( Args&&...
args ) const
681 noexcept( noexcept(
std::declval<
ValueType>()(
std::declval<Args&&>()... ) ) ) {
682 return value()( std::forward<Args>(
args )... );
690 ( std::is_same_v<ValueType, std::string> ) ?
nullptr : dynamic_cast<const Property*>( &source );
701 return dest.assign( *
this );
705 using Converter = Details::Property::StringConverter<ValueType>;
711 using Converter = Details::Property::StringConverter<ValueType>;
723 template <
class T,
class TP,
class V,
class H>
729 template <
class T,
class TP,
class V,
class H>
735 template <
class T,
class TP,
class V,
class H>
736 decltype(
auto ) operator+( const T& v, const
Property<TP, V, H>& p ) {
737 return v + p.
value();
740 template <
class TYPE,
class HANDLERS = Details::Property::UpdateHandler>
743 template <
class TYPE>
749 template <
class TYPE>
752 template <
class TYPE>
833 template <
typename Handler =
typename Gaudi::Details::Property::UpdateHandler>
838 using PropertyBase::PropertyBase;
884 bool load( PropertyBase& destination )
const override {
return destination.assign( *
this ); }
886 bool assign(
const PropertyBase& source )
override {
return fromString( source.toString() ).isSuccess(); }
921 bool load( PropertyBase& destination )
const override {
return destination.assign( *
this ); }
923 bool assign(
const PropertyBase& source )
override {
return fromString( source.toString() ).isSuccess(); }
1095 template <
class TYPE>
1120 template <
class TYPE>
1170 template <
unsigned N>
1206 template <
class TYPE>
1284 template <
class TYPE>
1310 template <
class TYPE>
1361 template <
unsigned N>
1438 template <
class TYPE>
1449 #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
std::string_view m_semantics
property semantics
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
void setSemantics(std::string value)
set the semantics string
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
TYPE fromString(const TYPE &ref_value, const std::string &s) final override
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
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...
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)
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
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...
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...
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
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.
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
std::string semantics() const
property semantics
Details::PropertyBase * clone() const override
clones the current property
PropertyBase(const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
constructor from the property name and the type
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.
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
const ValueType & value() const
Backward compatibility (.
Definition of the basic interface.
const std::type_info * m_typeinfo
property type
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Property(OWNER *owner, std::string name, T &&value, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value and documentation.
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
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
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
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.
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
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
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