The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::Details::WeakPropertyRef Class Reference

Optional reference to a property that can be used to refer to a sting or to the string representation of a property instance value. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Details/PropertyBase.h>

Collaboration diagram for Gaudi::Details::WeakPropertyRef:

Public Member Functions

 WeakPropertyRef ()=default
 
 WeakPropertyRef (std::string value)
 
 WeakPropertyRef (PropertyBase &property)
 
 WeakPropertyRef (const WeakPropertyRef &other)=delete
 
 WeakPropertyRef (WeakPropertyRef &&other)
 
 ~WeakPropertyRef ()
 
WeakPropertyRefoperator= (WeakPropertyRef &&other)
 
WeakPropertyRefoperator= (PropertyBase &value)
 
WeakPropertyRefoperator= (const std::string &value)
 
 operator std::string () const
 
bool isBound () const
 
bool isSet () const
 

Private Member Functions

void detach ()
 

Private Attributes

friend PropertyBase
 
PropertyBasem_property = nullptr
 
std::string m_value
 
bool m_unset = true
 

Detailed Description

Optional reference to a property that can be used to refer to a sting or to the string representation of a property instance value.

Definition at line 154 of file PropertyBase.h.

Constructor & Destructor Documentation

◆ WeakPropertyRef() [1/5]

Gaudi::Details::WeakPropertyRef::WeakPropertyRef ( )
default

◆ WeakPropertyRef() [2/5]

Gaudi::Details::WeakPropertyRef::WeakPropertyRef ( std::string value)
inline

Definition at line 159 of file PropertyBase.h.

159: m_value{ std::move( value ) }, m_unset{ false } {}

◆ WeakPropertyRef() [3/5]

Gaudi::Details::WeakPropertyRef::WeakPropertyRef ( PropertyBase & property)
inline

Definition at line 160 of file PropertyBase.h.

160: m_property{ &property } { property.add( this ); }

◆ WeakPropertyRef() [4/5]

Gaudi::Details::WeakPropertyRef::WeakPropertyRef ( const WeakPropertyRef & other)
delete

◆ WeakPropertyRef() [5/5]

Gaudi::Details::WeakPropertyRef::WeakPropertyRef ( WeakPropertyRef && other)
inline

Definition at line 162 of file PropertyBase.h.

163 : m_property{ other.m_property }, m_value{ std::move( other.m_value ) }, m_unset{ other.m_unset } {
164 if ( m_property ) {
165 other.m_property = nullptr;
166 m_property->remove( &other );
167 m_property->add( this );
168 }
169 }

◆ ~WeakPropertyRef()

Gaudi::Details::WeakPropertyRef::~WeakPropertyRef ( )
inline

Definition at line 170 of file PropertyBase.h.

170 {
171 if ( m_property ) m_property->remove( this );
172 }

Member Function Documentation

◆ detach()

void Gaudi::Details::WeakPropertyRef::detach ( )
inlineprivate

Definition at line 215 of file PropertyBase.h.

215{ m_property = nullptr; }

◆ isBound()

bool Gaudi::Details::WeakPropertyRef::isBound ( ) const
inline

Definition at line 207 of file PropertyBase.h.

207{ return m_property; }

◆ isSet()

bool Gaudi::Details::WeakPropertyRef::isSet ( ) const
inline

Definition at line 208 of file PropertyBase.h.

208{ return !m_unset; }

◆ operator std::string()

Gaudi::Details::WeakPropertyRef::operator std::string ( ) const

Definition at line 462 of file Property.cpp.

462 {
464 return m_property ? ( ( m_property->type_info() == &typeid( std::string ) ) ? toString( m_property->toString() )
465 : m_property->toString() )
466 : m_value;
467}
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:326

◆ operator=() [1/3]

WeakPropertyRef & Gaudi::Details::WeakPropertyRef::operator= ( const std::string & value)
inline

Definition at line 199 of file PropertyBase.h.

199 {
200 if ( m_property ) m_property->fromString( value ).ignore();
201 m_value = value;
202 m_unset = false;
203 return *this;
204 }

◆ operator=() [2/3]

WeakPropertyRef & Gaudi::Details::WeakPropertyRef::operator= ( PropertyBase & value)
inline

Definition at line 187 of file PropertyBase.h.

187 {
188 if ( m_property != &value ) {
189 if ( m_property ) {
190 m_property->remove( this );
191 if ( !m_unset ) m_value = m_property->toString();
192 }
193 if ( !m_unset ) value.fromString( m_value ).ignore();
194 m_property = &value;
195 value.add( this );
196 }
197 return *this;
198 }
virtual StatusCode fromString(const std::string &value)=0
string -> value
void add(WeakPropertyRef *ref)
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139

◆ operator=() [3/3]

WeakPropertyRef & Gaudi::Details::WeakPropertyRef::operator= ( WeakPropertyRef && other)
inline

Definition at line 173 of file PropertyBase.h.

173 {
174 if ( this != &other ) {
175 if ( m_property ) m_property->remove( this );
176 m_property = other.m_property;
177 other.m_property = nullptr;
178 if ( m_property ) {
179 m_property->remove( &other );
180 m_property->add( this );
181 }
182 m_value = std::move( other.m_value );
183 m_unset = other.m_unset;
184 }
185 return *this;
186 }

Member Data Documentation

◆ m_property

PropertyBase* Gaudi::Details::WeakPropertyRef::m_property = nullptr
private

Definition at line 211 of file PropertyBase.h.

◆ m_unset

bool Gaudi::Details::WeakPropertyRef::m_unset = true
private

Definition at line 213 of file PropertyBase.h.

◆ m_value

std::string Gaudi::Details::WeakPropertyRef::m_value
private

Definition at line 212 of file PropertyBase.h.

◆ PropertyBase

friend Gaudi::Details::WeakPropertyRef::PropertyBase
private

Definition at line 155 of file PropertyBase.h.


The documentation for this class was generated from the following files: