The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
PropertyBase Class Referenceabstract

PropertyBase base class allowing PropertyBase* collections to be "homogeneous". More...

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

Inherited by Gaudi::Property< GaudiUtils::HashMap< std::string, T > >, Gaudi::Property< TYPE >, Gaudi::Property< TYPE & >, Gaudi::Property< bool >, Gaudi::Property< char >, Gaudi::Property< signed char >, Gaudi::Property< unsigned char >, Gaudi::Property< short >, Gaudi::Property< unsigned short >, Gaudi::Property< int >, Gaudi::Property< unsigned int >, Gaudi::Property< long >, Gaudi::Property< unsigned long >, Gaudi::Property< long long >, Gaudi::Property< unsigned long long >, Gaudi::Property< float >, Gaudi::Property< double >, Gaudi::Property< long double >, Gaudi::Property< std::string >, Gaudi::Property< bool & >, Gaudi::Property< char & >, Gaudi::Property< signed char & >, Gaudi::Property< unsigned char & >, Gaudi::Property< short & >, Gaudi::Property< unsigned short & >, Gaudi::Property< int & >, Gaudi::Property< unsigned int & >, Gaudi::Property< long & >, Gaudi::Property< unsigned long & >, Gaudi::Property< long long & >, Gaudi::Property< unsigned long long & >, Gaudi::Property< float & >, Gaudi::Property< double & >, Gaudi::Property< long double & >, Gaudi::Property< std::string & >, Gaudi::Property< std::vector< bool > >, Gaudi::Property< std::vector< char > >, Gaudi::Property< std::vector< signed char > >, Gaudi::Property< std::vector< unsigned char > >, Gaudi::Property< std::vector< short > >, Gaudi::Property< std::vector< unsigned short > >, Gaudi::Property< std::vector< int > >, Gaudi::Property< std::vector< unsigned int > >, Gaudi::Property< std::vector< long > >, Gaudi::Property< std::vector< unsigned long > >, Gaudi::Property< std::vector< long long > >, Gaudi::Property< std::vector< unsigned long long > >, Gaudi::Property< std::vector< float > >, Gaudi::Property< std::vector< double > >, Gaudi::Property< std::vector< long double > >, Gaudi::Property< std::vector< std::string > >, Gaudi::Property< std::vector< bool > & >, Gaudi::Property< std::vector< char > & >, Gaudi::Property< std::vector< signed char > & >, Gaudi::Property< std::vector< unsigned char > & >, Gaudi::Property< std::vector< short > & >, Gaudi::Property< std::vector< unsigned short > & >, Gaudi::Property< std::vector< int > & >, Gaudi::Property< std::vector< unsigned int > & >, Gaudi::Property< std::vector< long > & >, Gaudi::Property< std::vector< unsigned long > & >, Gaudi::Property< std::vector< long long > & >, Gaudi::Property< std::vector< unsigned long long > & >, Gaudi::Property< std::vector< float > & >, Gaudi::Property< std::vector< double > & >, Gaudi::Property< std::vector< long double > & >, Gaudi::Property< std::vector< std::string > & >, Gaudi::Property< Gaudi::Histo1DDef >, Gaudi::Property< Gaudi::Histo1DDef & >, Gaudi::Property< DataObjIDColl >, Gaudi::Property< std::map< std::string, std::string > >, Gaudi::Property< Setup >, Gaudi::Property< Map >, Gaudi::Property< CLID >, Gaudi::Property< StreamSpecs >, Gaudi::Property< size_t >, Gaudi::Property< std::size_t >, Gaudi::Property< std::pair< double, double > >, Gaudi::Property< std::vector< std::pair< double, double > > >, Gaudi::Property< std::vector< std::vector< std::string > > >, Gaudi::Property< std::vector< std::vector< double > > >, Gaudi::Property< std::map< int, double > >, Gaudi::Property< std::map< std::string, int > >, Gaudi::Property< std::map< std::string, double > >, Gaudi::Property< std::map< std::string, std::vector< std::string > > >, Gaudi::Property< std::pair< int, int > >, Gaudi::Property< std::map< std::string, std::vector< double > > >, Gaudi::Property< std::map< std::string, std::vector< int > > >, Gaudi::Property< std::map< int, int > >, Gaudi::Property< std::vector< std::pair< int, int > > >, Gaudi::Property< std::map< int, std::string > >, Gaudi::Property< std::map< unsigned int, std::string > >, Gaudi::Property< std::tuple< std::string, int, double > >, Gaudi::Property< std::tuple< std::string > >, Gaudi::Property< std::unordered_set< int > >, Gaudi::Property< std::unordered_set< std::string > >, Gaudi::Property< std::array< double, 3 > >, Gaudi::Property< std::array< int, 1 > >, Gaudi::Property< GaudiUtils::Map< std::string, std::string > >, Gaudi::Property< std::vector< Triplet > >, Gaudi::Property< std::set< Triplet > >, Gaudi::Property< std::unordered_set< Triplet, HashFunction > >, Gaudi::Property< std::tuple< int, VS > >, Gaudi::Property< std::tuple< int, SS > >, Gaudi::Property< std::tuple< int, USS > >, Gaudi::Property< std::vector< DataObjID > >, Gaudi::Property< CatalogNames >, Gaudi::Property< std::array< std::string, sizeof...(OUTPUTs)> >, Gaudi::Property< Files >, Gaudi::Property< Particles >, Gaudi::Property< boost::array< double, 5 > >, Gaudi::Property< boost::array< std::string, 4 > >, Gaudi::Property< ConditionKey >, Gaudi::Property< std::unordered_map< std::string, std::string > >, Gaudi::Property< Gaudi::XYZPoint >, Gaudi::Property< Gaudi::XYZVector >, Gaudi::Property< Gaudi::LorentzVector >, Gaudi::Property< Gaudi::Vector5 >, Gaudi::Property< std::vector< Gaudi::XYZPoint > >, Gaudi::Property< std::vector< Gaudi::XYZVector > >, Gaudi::Property< std::vector< Gaudi::LorentzVector > >, Gaudi::Property< Gaudi::StringKey >, Gaudi::Property< Keys >, Gaudi::Property< DBaseEntries >, Gaudi::Property< Histo1DMap >, Gaudi::Property< uint64_t >, Gaudi::Property< std::vector< std::pair< std::string, std::string > > >, Gaudi::Property< std::map< std::string, std::string, std::less<> > >, Gaudi::Property< PartitionDefs >, Gaudi::Property< ItemNames >, Gaudi::Property< AlgDependentItemNames >, Gaudi::Property< std::set< int > >, Gaudi::Property< std::set< std::string > >, Gaudi::Property< std::unordered_set< float > >, Gaudi::Property< T >, Gaudi::Property< R >, Gaudi::Property< TYPE, VERIFIER, HANDLERS >, and PropertyWithHandlers< Handler >.

Collaboration diagram for PropertyBase:

Public Member Functions

const std::string name () const
 property name
 
std::string documentation () const
 property documentation
 
std::string semantics () const
 property semantics
 
const std::type_info * type_info () const
 property type-info
 
std::string type () const
 property type
 
virtual bool load (PropertyBase &dest) const=0
 export the property value to the destination
 
virtual bool assign (const PropertyBase &source)=0
 import the property value form the source
 
virtual std::string toString () const=0
 value -> string
 
virtual void toStream (std::ostream &out) const=0
 value -> stream
 
virtual StatusCode fromString (const std::string &value)=0
 string -> value
 
virtual PropertyBasedeclareReadHandler (std::function< void(PropertyBase &)> fun)=0
 set new callback for reading
 
template<class HT>
PropertyBasedeclareReadHandler (void(HT::*MF)(PropertyBase &), HT *instance)
 
virtual PropertyBasedeclareUpdateHandler (std::function< void(PropertyBase &)> fun)=0
 set new callback for update
 
template<class HT>
PropertyBasedeclareUpdateHandler (void(HT::*MF)(PropertyBase &), HT *instance)
 
virtual const std::function< void(PropertyBase &)> readCallBack () const=0
 get a reference to the readCallBack
 
virtual const std::function< void(PropertyBase &)> updateCallBack () const=0
 get a reference to the updateCallBack
 
virtual bool useUpdateHandler ()=0
 manual trigger for callback for update
 
virtual ~PropertyBase ()
 virtual destructor
 
void setName (std::string value)
 set the new value for the property name
 
void setDocumentation (std::string value)
 set the documentation string
 
void setSemantics (std::string value)
 set the semantics string
 
virtual std::ostream & fillStream (std::ostream &) const
 the printout of the property value
 
virtual PropertyBaseclone () const=0
 clones the current property
 
void setOwnerType (const std::type_info &ownerType)
 set the type of the owner class (used for documentation)
 
template<class OWNER>
void setOwnerType ()
 set the type of the owner class (used for documentation)
 
const std::type_info * ownerType () const
 get the type of the owner class (used for documentation)
 
std::string ownerTypeName () const
 get the string for the type of the owner class (used for documentation)
 

Protected Member Functions

 PropertyBase (const std::type_info &type, std::string name="", std::string doc="", std::string semantics="")
 constructor from the property name and the type
 
 PropertyBase (std::string name, const std::type_info &type)
 constructor from the property name and the type
 
 PropertyBase (const PropertyBase &)=default
 copy constructor
 
PropertyBaseoperator= (const PropertyBase &)=default
 assignment operator
 

Private Member Functions

void add (WeakPropertyRef *ref)
 
void remove (WeakPropertyRef *ref)
 

Static Private Member Functions

static std::string_view to_view (std::string str)
 helper to map a string to a reliable std::string_view
 

Private Attributes

std::string_view m_name
 property name
 
std::string_view m_documentation
 property doc string
 
std::string_view m_semantics
 property semantics
 
const std::type_info * m_typeinfo
 property type
 
const std::type_info * m_ownerType = nullptr
 type of owner of the property (if defined)
 
friend WeakPropertyRef
 
std::set< WeakPropertyRef * > m_weakReferences
 

Detailed Description

PropertyBase base class allowing PropertyBase* collections to be "homogeneous".

Author
Paul Maley
CTDay
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Marco Clemencic

Constructor & Destructor Documentation

◆ ~PropertyBase()

Gaudi::Details::PropertyBase::~PropertyBase ( )
inlinevirtual

virtual destructor

Definition at line 218 of file PropertyBase.h.

218 {
219 for ( auto ref : m_weakReferences ) { ref->detach(); }
220 }
std::set< WeakPropertyRef * > m_weakReferences

◆ PropertyBase() [1/3]

Gaudi::Details::PropertyBase::PropertyBase ( const std::type_info & type,
std::string name = "",
std::string doc = "",
std::string semantics = "" )
inlineprotected

constructor from the property name and the type

Definition at line 117 of file PropertyBase.h.

118 : m_name( to_view( std::move( name ) ) )
119 , m_documentation( to_view( std::move( doc ) ) )
120 , m_semantics( to_view( std::move( semantics ) ) )
121 , m_typeinfo( &type ) {}
const std::type_info * m_typeinfo
property type
std::string type() const
property type
std::string_view m_semantics
property semantics
std::string semantics() const
property semantics
std::string_view m_name
property name
std::string_view m_documentation
property doc string
static std::string_view to_view(std::string str)
helper to map a string to a reliable std::string_view
Definition Property.cpp:41
const std::string name() const
property name

◆ PropertyBase() [2/3]

Gaudi::Details::PropertyBase::PropertyBase ( std::string name,
const std::type_info & type )
inlineprotected

constructor from the property name and the type

Definition at line 123 of file PropertyBase.h.

124 : m_name( to_view( std::move( name ) ) ), m_documentation( m_name ), m_typeinfo( &type ) {}

◆ PropertyBase() [3/3]

Gaudi::Details::PropertyBase::PropertyBase ( const PropertyBase & )
protecteddefault

copy constructor

Member Function Documentation

◆ add()

void Gaudi::Details::PropertyBase::add ( WeakPropertyRef * ref)
inlineprivate

Definition at line 146 of file PropertyBase.h.

146 {
147 if ( ref ) m_weakReferences.insert( ref );
148 }

◆ assign()

virtual bool Gaudi::Details::PropertyBase::assign ( const PropertyBase & source)
pure virtual

import the property value form the source

◆ clone()

virtual PropertyBase * Gaudi::Details::PropertyBase::clone ( ) const
pure virtual

clones the current property

◆ declareReadHandler() [1/2]

virtual PropertyBase & Gaudi::Details::PropertyBase::declareReadHandler ( std::function< void(PropertyBase &)> fun)
pure virtual

set new callback for reading

◆ declareReadHandler() [2/2]

template<class HT>
PropertyBase & Gaudi::Details::PropertyBase::declareReadHandler ( void(HT::* MF )(PropertyBase &),
HT * instance )
inline

Definition at line 75 of file PropertyBase.h.

75 {
76 return declareReadHandler( [=]( PropertyBase& p ) { ( instance->*MF )( p ); } );
77 }
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 & declareReadHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for reading

◆ declareUpdateHandler() [1/2]

virtual PropertyBase & Gaudi::Details::PropertyBase::declareUpdateHandler ( std::function< void(PropertyBase &)> fun)
pure virtual

set new callback for update

◆ declareUpdateHandler() [2/2]

template<class HT>
PropertyBase & Gaudi::Details::PropertyBase::declareUpdateHandler ( void(HT::* MF )(PropertyBase &),
HT * instance )
inline

Definition at line 80 of file PropertyBase.h.

80 {
81 return declareUpdateHandler( [=]( PropertyBase& p ) { ( instance->*MF )( p ); } );
82 }
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update

◆ documentation()

std::string Gaudi::Details::PropertyBase::documentation ( ) const
inline

property documentation

Definition at line 40 of file PropertyBase.h.

40{ return std::string{ m_documentation }; }

◆ fillStream()

std::ostream & PropertyBase::fillStream ( std::ostream & stream) const
virtual

the printout of the property value

Definition at line 45 of file Property.cpp.

45 {
46 return stream << " '" << name() << "':" << toString();
47}
virtual std::string toString() const =0
value -> string
const std::string name() const
property name
stream
Definition Write.py:32

◆ fromString()

virtual StatusCode Gaudi::Details::PropertyBase::fromString ( const std::string & value)
pure virtual

string -> value

◆ load()

virtual bool Gaudi::Details::PropertyBase::load ( PropertyBase & dest) const
pure virtual

export the property value to the destination

◆ name()

const std::string Gaudi::Details::PropertyBase::name ( ) const
inline

property name

Definition at line 38 of file PropertyBase.h.

38{ return std::string{ m_name }; }

◆ operator=()

PropertyBase & Gaudi::Details::PropertyBase::operator= ( const PropertyBase & )
protecteddefault

assignment operator

◆ ownerType()

const std::type_info * Gaudi::Details::PropertyBase::ownerType ( ) const
inline

get the type of the owner class (used for documentation)

Definition at line 108 of file PropertyBase.h.

108{ return m_ownerType; }
const std::type_info * m_ownerType
type of owner of the property (if defined)

◆ ownerTypeName()

std::string Gaudi::Details::PropertyBase::ownerTypeName ( ) const
inline

get the string for the type of the owner class (used for documentation)

Definition at line 111 of file PropertyBase.h.

111 {
112 return m_ownerType ? System::typeinfoName( *m_ownerType ) : std::string( "unknown owner type" );
113 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ readCallBack()

virtual const std::function< void(PropertyBase &)> Gaudi::Details::PropertyBase::readCallBack ( ) const
pure virtual

get a reference to the readCallBack

◆ remove()

void Gaudi::Details::PropertyBase::remove ( WeakPropertyRef * ref)
inlineprivate

Definition at line 149 of file PropertyBase.h.

149{ m_weakReferences.erase( ref ); }

◆ semantics()

std::string Gaudi::Details::PropertyBase::semantics ( ) const
inline

property semantics

Definition at line 42 of file PropertyBase.h.

42{ return std::string{ m_semantics }; }

◆ setDocumentation()

void Gaudi::Details::PropertyBase::setDocumentation ( std::string value)
inline

set the documentation string

Definition at line 90 of file PropertyBase.h.

90{ m_documentation = to_view( std::move( value ) ); }

◆ setName()

void Gaudi::Details::PropertyBase::setName ( std::string value)
inline

set the new value for the property name

Definition at line 88 of file PropertyBase.h.

88{ m_name = to_view( std::move( value ) ); }

◆ setOwnerType() [1/2]

template<class OWNER>
void Gaudi::Details::PropertyBase::setOwnerType ( )
inline

set the type of the owner class (used for documentation)

Definition at line 103 of file PropertyBase.h.

103 {
104 setOwnerType( typeid( OWNER ) );
105 }
void setOwnerType()
set the type of the owner class (used for documentation)

◆ setOwnerType() [2/2]

void Gaudi::Details::PropertyBase::setOwnerType ( const std::type_info & ownerType)
inline

set the type of the owner class (used for documentation)

Definition at line 99 of file PropertyBase.h.

const std::type_info * ownerType() const
get the type of the owner class (used for documentation)

◆ setSemantics()

void Gaudi::Details::PropertyBase::setSemantics ( std::string value)
inline

set the semantics string

Definition at line 92 of file PropertyBase.h.

92{ m_semantics = to_view( std::move( value ) ); }

◆ to_view()

std::string_view PropertyBase::to_view ( std::string str)
staticprivate

helper to map a string to a reliable std::string_view

Definition at line 41 of file Property.cpp.

41 {
42 return **( all_strings.insert( std::make_unique<std::string>( std::move( str ) ) ).first );
43}

◆ toStream()

virtual void Gaudi::Details::PropertyBase::toStream ( std::ostream & out) const
pure virtual

value -> stream

◆ toString()

virtual std::string Gaudi::Details::PropertyBase::toString ( ) const
pure virtual

value -> string

◆ type()

std::string Gaudi::Details::PropertyBase::type ( ) const
inline

property type

Definition at line 46 of file PropertyBase.h.

46{ return m_typeinfo->name(); }

◆ type_info()

const std::type_info * Gaudi::Details::PropertyBase::type_info ( ) const
inline

property type-info

Definition at line 44 of file PropertyBase.h.

44{ return m_typeinfo; }

◆ updateCallBack()

virtual const std::function< void(PropertyBase &)> Gaudi::Details::PropertyBase::updateCallBack ( ) const
pure virtual

get a reference to the updateCallBack

◆ useUpdateHandler()

virtual bool Gaudi::Details::PropertyBase::useUpdateHandler ( )
pure virtual

manual trigger for callback for update

Member Data Documentation

◆ m_documentation

std::string_view Gaudi::Details::PropertyBase::m_documentation
private

property doc string

Definition at line 136 of file PropertyBase.h.

◆ m_name

std::string_view Gaudi::Details::PropertyBase::m_name
private

property name

Definition at line 134 of file PropertyBase.h.

◆ m_ownerType

const std::type_info* Gaudi::Details::PropertyBase::m_ownerType = nullptr
private

type of owner of the property (if defined)

Definition at line 142 of file PropertyBase.h.

◆ m_semantics

std::string_view Gaudi::Details::PropertyBase::m_semantics
private

property semantics

Definition at line 138 of file PropertyBase.h.

◆ m_typeinfo

const std::type_info* Gaudi::Details::PropertyBase::m_typeinfo
private

property type

Definition at line 140 of file PropertyBase.h.

◆ m_weakReferences

std::set<WeakPropertyRef*> Gaudi::Details::PropertyBase::m_weakReferences
private

Definition at line 145 of file PropertyBase.h.

◆ WeakPropertyRef

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

Definition at line 144 of file PropertyBase.h.


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