File indexing completed on 2025-01-18 09:57:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013
0014 #include <Gaudi/Details/PropertyBase.h>
0015 #include <GaudiKernel/GaudiException.h>
0016 #include <GaudiKernel/IInterface.h>
0017 #include <GaudiKernel/INamedInterface.h>
0018 #include <GaudiKernel/ToStream.h>
0019 #include <iostream>
0020 #include <string>
0021 #include <string_view>
0022 #include <vector>
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class GAUDI_API IProperty : virtual public IInterface {
0034 public:
0035
0036 DeclareInterfaceID( IProperty, 3, 0 );
0037
0038
0039 StatusCode setProperty( const Gaudi::Details::PropertyBase& p ) { return setProperty( p.name(), p ); }
0040
0041 virtual StatusCode setProperty( const std::string& name, const Gaudi::Details::PropertyBase& p ) = 0;
0042
0043 virtual StatusCode setProperty( const std::string& s ) = 0;
0044
0045 virtual StatusCode setPropertyRepr( const std::string& n, const std::string& r ) = 0;
0046
0047 StatusCode setProperty( const std::string& name, const char* v ) { return setProperty( name, std::string{ v } ); }
0048
0049 StatusCode setProperty( const std::string& name, const std::string& v ) {
0050 if ( !hasProperty( name ) ) return StatusCode::FAILURE;
0051 return setPropertyRepr( name, v );
0052 }
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 template <class TYPE, typename = std::enable_if_t<!std::is_base_of_v<Gaudi::Details::PropertyBase, TYPE>>>
0082 StatusCode setProperty( const std::string& name, const TYPE& value ) {
0083 using Gaudi::Utils::toString;
0084 if ( !hasProperty( name ) ) return StatusCode::FAILURE;
0085 return setPropertyRepr( name, toString( value ) );
0086 }
0087
0088 virtual StatusCode getProperty( Gaudi::Details::PropertyBase* p
0089 ) const = 0;
0090
0091 virtual const Gaudi::Details::PropertyBase& getProperty( std::string_view name
0092 ) const = 0;
0093
0094 virtual StatusCode getProperty( std::string_view n, std::string& v ) const = 0;
0095
0096 virtual const std::vector<Gaudi::Details::PropertyBase*>& getProperties() const = 0;
0097
0098
0099 virtual bool hasProperty( std::string_view name ) const = 0;
0100 };