Go to the documentation of this file.
20 #include <string_view>
25 class WeakPropertyRef;
77 return declareReadHandler( [=](
PropertyBase& p ) { ( instance->*MF )( p ); } );
82 return declareUpdateHandler( [=](
PropertyBase& p ) { ( instance->*MF )( p ); } );
103 template <
class OWNER>
105 setOwnerType(
typeid( OWNER ) );
119 : m_name( to_view(
std::move(
name ) ) )
120 , m_documentation( to_view(
std::move( doc ) ) )
121 , m_semantics( to_view(
std::move( semantics ) ) )
122 , m_typeinfo( &
type ) {}
125 : m_name( to_view(
std::move(
name ) ) ), m_documentation( m_name ), m_typeinfo( &
type ) {}
133 static std::string_view to_view(
std::string str );
164 : m_property{ other.m_property }, m_value{
std::move( other.m_value ) }, m_unset{ other.m_unset } {
166 other.m_property =
nullptr;
167 m_property->remove( &other );
168 m_property->add(
this );
172 if ( m_property ) m_property->remove(
this );
175 if (
this != &other ) {
176 if ( m_property ) m_property->remove(
this );
178 other.m_property =
nullptr;
180 m_property->
remove( &other );
181 m_property->add(
this );
184 m_unset = other.m_unset;
189 if ( m_property != &value ) {
191 m_property->remove(
this );
192 if ( !m_unset ) m_value = m_property->toString();
201 if ( m_property ) m_property->fromString( value ).ignore();
208 inline bool isBound()
const {
return m_property; }
209 inline bool isSet()
const {
return !m_unset; }
PropertyBase & declareUpdateHandler(void(HT::*MF)(PropertyBase &), HT *instance)
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
WeakPropertyRef(PropertyBase &property)
virtual bool load(PropertyBase &dest) const =0
export the property value to the destination
WeakPropertyRef & operator=(const std::string &value)
const std::string name() const
property name
PropertyBase & operator=(const PropertyBase &)=default
assignment operator
const std::type_info * type_info() const
property type-info
WeakPropertyRef & operator=(PropertyBase &value)
std::string documentation() const
property documentation
std::string type() const
property type
WeakPropertyRef(WeakPropertyRef &&other)
void remove(WeakPropertyRef *ref)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
virtual void toStream(std::ostream &out) const =0
value -> stream
virtual StatusCode fromString(const std::string &value)=0
string -> value
virtual PropertyBase & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading
std::ostream & operator<<(std::ostream &stream, const PropertyBase &prop)
const std::type_info * ownerType() const
get the type of the owner class (used for documentation)
Optional reference to a property that can be used to refer to a sting or to the string representation...
std::string_view m_name
property name
WeakPropertyRef & operator=(WeakPropertyRef &&other)
void setDocumentation(std::string value)
set the documentation string
WeakPropertyRef(const WeakPropertyRef &other)=delete
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
virtual const std::function< void(PropertyBase &)> updateCallBack() const =0
get a reference to the updateCallBack
void add(WeakPropertyRef *ref)
std::string_view m_documentation
property doc string
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()
virtual destructor
void setOwnerType(const std::type_info &ownerType)
set the type of the owner class (used for documentation)
virtual bool useUpdateHandler()=0
manual trigger for callback for update
std::string semantics() const
property semantics
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
void setOwnerType()
set the type of the owner class (used for documentation)
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
std::set< WeakPropertyRef * > m_weakReferences
PropertyBase * m_property
std::string_view m_semantics
property semantics
const std::type_info * m_typeinfo
property type
virtual std::string toString() const =0
value -> string
WeakPropertyRef()=default
PropertyBase & declareReadHandler(void(HT::*MF)(PropertyBase &), HT *instance)
virtual const std::function< void(PropertyBase &)> readCallBack() const =0
get a reference to the readCallBack
void setName(std::string value)
set the new value for the property name
WeakPropertyRef(std::string value)
PropertyBase(const PropertyBase &)=default
copy constructor
std::string ownerTypeName() const
get the string for the type of the owner class (used for documentation)
virtual PropertyBase * clone() const =0
clones the current property
void setSemantics(std::string value)
set the semantics string
PropertyBase(std::string name, const std::type_info &type)
constructor from the property name and the type