Go to the documentation of this file.
22 #include <string_view>
33 template <
class TYPE,
class VERIFIER = Details::Property::NullVerifier,
34 class HANDLERS = Details::Property::UpdateHandler>
50 template <
class T = StorageType>
58 template <std::derived_from<IProperty> OWNER,
typename T = ValueType>
61 owner->declareProperty( *
this );
62 setOwnerType<OWNER>();
67 template <std::derived_from<IProperty> OWNER,
class T = StorageType>
70 owner->declareProperty( *
this );
71 setOwnerType<OWNER>();
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>
117 [[deprecated(
"anonymous properties are deprecated" )]]
Property( T&&
v )
122 template <
typename T = StorageType>
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 {
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>
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() )>
250 decltype(
auto ) length()
const {
251 return value().length();
253 template <
class T = const ValueType>
254 decltype(
auto ) empty()
const {
255 return value().empty();
257 template <
class T = ValueType>
258 decltype(
auto ) clear() {
261 template <class T = const ValueType, typename = decltype( std::declval<const T>().begin() )>
262 decltype(
auto )
begin()
const {
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() )>
270 decltype(
auto )
begin() {
271 return value().begin();
273 template <
class T = ValueType>
274 decltype(
auto )
end() {
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>
294 decltype(
auto ) erase( ARG arg ) {
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>
331 decltype(
auto ) objKey()
const {
332 return value().objKey();
334 template <
class T = const ValueType>
335 decltype(
auto ) fullKey()
const {
336 return value().fullKey();
338 template <
class T = ValueType>
339 decltype(
auto ) initialize() {
340 return value().initialize();
342 template <
class T = ValueType>
343 decltype(
auto ) makeHandles()
const {
344 return value().makeHandles();
346 template <
class ARG,
class T = ValueType>
347 decltype(
auto ) makeHandles( const ARG& arg )
const {
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() +
"'";
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';
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>
432 decltype(
auto ) operator+( const T&
v, const
Property<TP, V, H>& p ) {
433 return v + p.value();
436 template <
class TYPE,
class HANDLERS = Details::Property::UpdateHandler>
439 template <
class TYPE>
445 template <
class TYPE>
448 template <
class TYPE>
529 template <
typename Handler =
typename Gaudi::Details::Property::UpdateHandler>
534 using PropertyBase::PropertyBase;
538 m_handlers.setReadHandler( std::move( fun ) );
543 m_handlers.setUpdateHandler( std::move( fun ) );
580 bool load( PropertyBase& destination )
const override {
return destination.assign( *
this ); }
584 std::string
toString()
const override;
617 bool load( PropertyBase& destination )
const override {
return destination.assign( *
this ); }
621 std::string
toString()
const override;
760 getProperty(
const std::vector<const Gaudi::Details::PropertyBase*>* p, std::string_view
name );
784 template <
class TYPE>
808 template <
class TYPE>
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 =
"" ) {
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 =
"" ) {
VerifierType & verifier()
Accessor to verifier.
Gaudi::Property< unsigned long & > UnsignedLongPropertyRef
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.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Property & operator-=(const T &other)
const std::function< void(PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Gaudi::Property< signed char & > SignedCharPropertyRef
constexpr auto size(const T &, Args &&...) noexcept
Gaudi::Property< int & > IntegerPropertyRef
bool load(PropertyBase &destination) const override
GaudiHandleBase * m_pValue
Pointer to the real property.
Gaudi::Property< std::vector< std::string > > StringArrayProperty
const GaudiHandleArrayBase & value() const
PropertyBase & operator=(const PropertyBase &)=default
assignment operator
Gaudi::Property< std::vector< char > & > CharArrayPropertyRef
const std::function< void(Details::PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
Gaudi::Property< std::vector< unsigned short > & > UnsignedShortArrayPropertyRef
ValueType operator++(int)
Gaudi::Property< std::vector< unsigned long long > & > UnsignedLongLongArrayPropertyRef
Gaudi::Property< std::vector< char > > CharArrayProperty
Gaudi::Property< short & > ShortPropertyRef
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
const VerifierType & verifier() const
Accessor to verifier.
Gaudi::Property< unsigned long long & > UnsignedLongLongPropertyRef
Gaudi::Property< long & > LongPropertyRef
Gaudi::Property< unsigned int > UnsignedIntegerProperty
Gaudi::Property< std::vector< std::string > & > StringArrayPropertyRef
requires(!std::is_same_v< Property, std::remove_reference_t< T >>) Property(T &&v)
Construct an anonymous property from a value.
Gaudi::Property< std::vector< unsigned char > & > UnsignedCharArrayPropertyRef
Gaudi::Property< unsigned int & > UnsignedIntegerPropertyRef
Gaudi::Property< std::vector< signed char > > SignedCharArrayProperty
Gaudi::Property< long double & > LongDoublePropertyRef
Details::PropertyBase * clone() const override
clones the current property
Gaudi::Property< double > DoubleProperty
Gaudi::Property< std::vector< double > > DoubleArrayProperty
bool assign(const Details::PropertyBase &source) override
get the value from another property
requires(std::is_default_constructible_v< T >) Property(OWNER *owner
Autodeclaring constructor with property name, value and documentation.
virtual void toStream(std::ostream &out) const =0
value -> stream
Gaudi::Property< unsigned char > UnsignedCharProperty
Gaudi::Property< std::vector< unsigned long long > > UnsignedLongLongArrayProperty
bool load(Details::PropertyBase &dest) const override
set value to another property
virtual StatusCode fromString(const std::string &value)=0
string -> value
Gaudi::Property< short > ShortProperty
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
Gaudi::Property< std::vector< long double > & > LongDoubleArrayPropertyRef
StatusCode fromString(const std::string &source) override
string -> value
bool setValue(const ValueType &v)
Gaudi::Property< std::vector< unsigned int > > UnsignedIntegerArrayProperty
Gaudi::Property< long > LongProperty
std::vector< std::pair< int, int > > StorageType
Hosted type.
requires(!std::is_reference_v< T >) Property()
Construct an anonymous property with default constructed value.
Gaudi::Property< char & > CharPropertyRef
ValueType operator--(int)
PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun) override
set new callback for reading
AttribStringParser::Iterator begin(const AttribStringParser &parser)
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Gaudi::Property< float & > FloatPropertyRef
requires(std::is_constructible_v< std::string_view, Dummy >) operator std
Gaudi::Property< long long > LongLongProperty
Gaudi::Property< std::vector< float > > FloatArrayProperty
bool assign(const PropertyBase &source) override
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< std::vector< bool > > BooleanArrayProperty
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
Gaudi::Property< unsigned char & > UnsignedCharPropertyRef
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
const ValueType & value() const
PropertyBase(const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
constructor from the property name and the type
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.
Property & operator+=(const T &other)
Gaudi::Property< std::vector< long > > LongArrayProperty
bool set(const ValueType &v)
Gaudi::Property< char > CharProperty
Gaudi::Property< std::vector< double > & > DoubleArrayPropertyRef
const GaudiHandleBase & value() const
Gaudi::Property< std::vector< unsigned short > > UnsignedShortArrayProperty
std::string semantics() const
property semantics
PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun) override
set new callback for update
bool useUpdateHandler() override
manual trigger for callback for update
ParsingErrorPolicy parsingErrorPolicy()
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Base class of array's of various gaudihandles.
GaudiHandleArrayProperty * clone() const override
clones the current property
Gaudi::Property< std::vector< short > > ShortArrayProperty
Gaudi::Property< unsigned short & > UnsignedShortPropertyRef
GaudiHandleProperty & operator=(const GaudiHandleBase &value)
Gaudi::Property< long long & > LongLongPropertyRef
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
Gaudi::Property< std::vector< long long > > LongLongArrayProperty
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
void toStream(std::ostream &out) const override
value -> stream
Helper class to simplify the migration old properties deriving directly from PropertyBase.
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...
Gaudi::Property< float > FloatProperty
constexpr static const auto SUCCESS
Details::PropertyBase & declareReadHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for reading
const std::function< void(Details::PropertyBase &)> readCallBack() const override
get a reference to the readCallBack
Gaudi::Property< std::vector< long long > & > LongLongArrayPropertyRef
const std::function< void(PropertyBase &)> updateCallBack() const override
get a reference to the updateCallBack
virtual std::string toString() const =0
value -> string
Gaudi::Property< bool > BooleanProperty
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 int > & > UnsignedIntegerArrayPropertyRef
bool useUpdateHandler() override
use the call-back function at update, if available
bool assign(const PropertyBase &source) override
Gaudi::Property< unsigned short > UnsignedShortProperty
Gaudi::Property< std::vector< unsigned long > & > UnsignedLongArrayPropertyRef
std::string toString() const override
value -> string
bool operator<(const Gaudi::Histo1DDef &left, const Gaudi::Histo1DDef &right)
Gaudi::Property< std::vector< float > & > FloatArrayPropertyRef
Gaudi::Property< std::vector< unsigned long > > UnsignedLongArrayProperty
GaudiHandleProperty * clone() const override
clones the current property
Property(std::string name, T &&value, std::string doc="", std::string semantics="")
the constructor with property name, value and documentation.
Gaudi::Property< unsigned long > UnsignedLongProperty
Property(OWNER *owner, std::string name, T &&value, std::string doc="", std::string semantics="")
Autodeclaring constructor with property name, value and documentation.
Gaudi::Property< std::vector< unsigned char > > UnsignedCharArrayProperty
Gaudi::Property< signed char > SignedCharProperty
Gaudi::Property< std::vector< int > > IntegerArrayProperty
constexpr static const auto FAILURE
Gaudi::Property< long double > LongDoubleProperty
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Gaudi::Property< std::vector< long double > > LongDoubleArrayProperty
GaudiHandleArrayProperty & operator=(const GaudiHandleArrayBase &value)
Gaudi::Property< unsigned long long > UnsignedLongLongProperty
bool load(PropertyBase &destination) const override
GaudiHandleArrayBase * m_pValue
Pointer to the real property.
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...
void useReadHandler() const
use the call-back function at reading, if available
typename std::remove_reference< StorageType >::type ValueType
Gaudi::Property< std::vector< long > & > LongArrayPropertyRef
Implementation of property with value of concrete type.
GAUDI_API bool hasProperty(const IProperty *p, std::string_view name)
simple function which check the existence of the property with the given name.
Gaudi::Property< std::vector< bool > & > BooleanArrayPropertyRef
Gaudi::Property< std::vector< int > & > IntegerArrayPropertyRef
Gaudi::Property< int > IntegerProperty
Gaudi::Property< std::string > StringProperty
Gaudi::Property< std::vector< signed char > & > SignedCharArrayPropertyRef
Gaudi::Property< std::string & > StringPropertyRef
Gaudi::Property< double & > DoublePropertyRef
Gaudi::Property< bool & > BooleanPropertyRef
Gaudi::Property< std::vector< short > & > ShortArrayPropertyRef