| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

DataObjIDProperty.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAOBJIDPROPERTY_H
2 #define GAUDIKERNEL_DATAOBJIDPROPERTY_H 1
3
4 #include "GaudiKernel/DataObjID.h"
5 #include "GaudiKernel/Parsers.h"
6 #include "GaudiKernel/Property.h"
7 #include "GaudiKernel/StatusCode.h"
8 #include "GaudiKernel/ToStream.h"
9
10 #include <iostream>
11
12 //---------------------------------------------------------------------------
13
24 //---------------------------------------------------------------------------
25
26 class GAUDI_API DataObjIDProperty : public PropertyWithHandlers<>
27 {
28 public:
29 DataObjIDProperty( const std::string& name, DataObjID& ref );
30 DataObjIDProperty& operator=( const DataObjID& value );
31 ~DataObjIDProperty() override;
32
33 DataObjIDProperty* clone() const override;
34 bool load( Property& destination ) const override;
35 bool assign( const Property& source ) override;
36 std::string toString() const override;
37 void toStream( std::ostream& out ) const override;
38 StatusCode fromString( const std::string& s ) override;
39 const DataObjID& value() const;
40 bool setValue( const DataObjID& value );
41
42 private:
46 DataObjID* m_pValue;
47 };
48
49 namespace Gaudi
50 {
51 template <>
52 class Property<DataObjID&> : public ::DataObjIDProperty
53 {
54 public:
55 Property( const std::string& name, DataObjID& value ) : ::DataObjIDProperty( name, value ) {}
56
58 virtual ~Property() {}
59 };
60 } // namespace Gaudi
61
62 inline DataObjIDProperty& DataObjIDProperty::operator=( const DataObjID& value )
63 {
64 setValue( value );
65 return *this;
66 }
67
68 inline DataObjIDProperty* DataObjIDProperty::clone() const { return new DataObjIDProperty( *this ); }
69
70 inline bool DataObjIDProperty::load( Gaudi::Details::PropertyBase& destination ) const
71 {
72 return destination.assign( *this );
73 }
74
75 inline bool DataObjIDProperty::assign( const Gaudi::Details::PropertyBase& source )
76 {
77 return fromString( source.toString() ).isSuccess();
78 }
79
80 inline const DataObjID& DataObjIDProperty::value() const
81 {
82 useReadHandler();
83 return *m_pValue;
84 }
85
86 //---------------------------------------------------------------------------
87
88 class GAUDI_API DataObjIDCollProperty : public PropertyWithHandlers<>
89 {
90 public:
91 DataObjIDCollProperty( const std::string& name, DataObjIDColl& ref );
92 DataObjIDCollProperty& operator=( const DataObjIDColl& value );
93 virtual ~DataObjIDCollProperty();
94
95 DataObjIDCollProperty* clone() const override;
96 bool load( Property& destination ) const override;
97 bool assign( const Property& source ) override;
98 std::string toString() const override;
99 void toStream( std::ostream& out ) const override;
100 StatusCode fromString( const std::string& s ) override;
101 const DataObjIDColl& value() const;
102 bool setValue( const DataObjIDColl& value );
103
104 private:
108 DataObjIDColl* m_pValue;
109 };
110
111 namespace Gaudi
112 {
113 template <>
114 class Property<DataObjIDColl&> : public ::DataObjIDCollProperty
115 {
116 public:
117 Property( const std::string& name, DataObjIDColl& value ) : ::DataObjIDCollProperty( name, value ) {}
118
120 virtual ~Property() {}
121 };
122
123 template <>
124 class Property<DataObjIDColl> : public ::DataObjIDCollProperty
125 {
126 public:
127 Property( const std::string& name, DataObjIDColl& value ) : ::DataObjIDCollProperty( name, value ) {}
128
130 template <class OWNER>
131 inline Property( OWNER* owner, const std::string& name, const DataObjIDColl& initval = DataObjIDColl{},
132 std::string doc = "" )
133 : ::DataObjIDCollProperty( name, *( new DataObjIDColl{initval} ) )
134 {
137 m_data.reset( const_cast<DataObjIDColl*>( &value() ) );
138 setDocumentation( std::move( doc ) );
139 owner->declareProperty( *this );
140 setOwnerType<OWNER>();
141 }
142
143 operator const DataObjIDColl&() const { return value(); }
144
146 virtual ~Property() {}
147
148 private:
149 std::unique_ptr<DataObjIDColl> m_data;
150 };
151 } // namespace Gaudi
152
153 inline DataObjIDCollProperty& DataObjIDCollProperty::operator=( const DataObjIDColl& value )
154 {
155 setValue( value );
156 return *this;
157 }
158
159 inline DataObjIDCollProperty* DataObjIDCollProperty::clone() const { return new DataObjIDCollProperty( *this ); }
160
161 inline bool DataObjIDCollProperty::load( Gaudi::Details::PropertyBase& destination ) const
162 {
163 return destination.assign( *this );
164 }
165
166 inline bool DataObjIDCollProperty::assign( const Gaudi::Details::PropertyBase& source )
167 {
168 return fromString( source.toString() ).isSuccess();
169 }
170
171 inline const DataObjIDColl& DataObjIDCollProperty::value() const
172 {
173 useReadHandler();
174 return *m_pValue;
175 }
176
177 #endif
Gaudi::Property< DataObjIDColl & >::Property
Property(const std::string &name, DataObjIDColl &value)
Definition: DataObjIDProperty.h:117
DataObjIDCollProperty::assign
bool assign(const Property &source) override
Definition: DataObjIDProperty.h:166
Gaudi::Property< DataObjIDColl >::Property
Property(OWNER *owner, const std::string &name, const DataObjIDColl &initval=DataObjIDColl{}, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Definition: DataObjIDProperty.h:131
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
DataObjIDCollProperty::clone
DataObjIDCollProperty * clone() const override
clones the current property
Definition: DataObjIDProperty.h:159
DataObjID
Definition: DataObjID.h:37
Gaudi::Details::PropertyBase::load
virtual bool load(PropertyBase &dest) const =0
export the property value to the destination
Gaudi::Property< DataObjID & >::~Property
virtual ~Property()
virtual Destructor
Definition: DataObjIDProperty.h:58
Gaudi::Details::PropertyBase::assign
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
Parsers.h
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
Gaudi::Property< DataObjIDColl >::Property
Property(const std::string &name, DataObjIDColl &value)
Definition: DataObjIDProperty.h:127
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
DataObjIDCollProperty::load
bool load(Property &destination) const override
Definition: DataObjIDProperty.h:161
Property
Gaudi::Details::PropertyBase Property
backward compatibility hack for old Property base class
Definition: PropertyFwd.h:28
DataObjIDProperty::clone
DataObjIDProperty * clone() const override
clones the current property
Definition: DataObjIDProperty.h:68
Gaudi::Property< DataObjIDColl >::m_data
std::unique_ptr< DataObjIDColl > m_data
Definition: DataObjIDProperty.h:149
DataObjIDCollProperty::operator=
DataObjIDCollProperty & operator=(const DataObjIDColl &value)
Definition: DataObjIDProperty.h:153
Gaudi::Details::PropertyBase::toStream
virtual void toStream(std::ostream &out) const =0
value -> stream
Gaudi::Details::PropertyBase::fromString
virtual StatusCode fromString(const std::string &value)=0
string -> value
PropertyWithHandlers
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:786
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
Gaudi::Property< DataObjIDColl >::~Property
virtual ~Property()
virtual Destructor
Definition: DataObjIDProperty.h:146
GaudiMath::Interpolation::toStream
std::ostream & toStream(const Type &, std::ostream &)
Definition: Interpolation.cpp:47
DataObjIDProperty::m_pValue
DataObjID * m_pValue
Pointer to the real property.
Definition: DataObjIDProperty.h:46
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
DataObjIDCollProperty
Definition: DataObjIDProperty.h:88
Gaudi::Details::PropertyBase::clone
virtual PropertyBase * clone() const =0
clones the current property
DataObjIDProperty::operator=
DataObjIDProperty & operator=(const DataObjID &value)
Definition: DataObjIDProperty.h:62
std::unordered_set
STL class.
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
DataObjIDProperty::value
const DataObjID & value() const
Definition: DataObjIDProperty.h:80
DataObjIDProperty::assign
bool assign(const Property &source) override
Definition: DataObjIDProperty.h:75
Gaudi::Property< DataObjIDColl & >::~Property
virtual ~Property()
virtual Destructor
Definition: DataObjIDProperty.h:120
std::move
T move(T...args)
DataObjID.h
std::unique_ptr
STL class.
DataObjIDProperty
DataObjIDProperty.h GaudiKernel/DataObjProperty.h.
Definition: DataObjIDProperty.h:26
Property.h
gaudirun.s
string s
Definition: gaudirun.py:253
DataObjIDCollProperty::m_pValue
DataObjIDColl * m_pValue
Pointer to the real property.
Definition: DataObjIDProperty.h:108
Gaudi::Property< DataObjID & >::Property
Property(const std::string &name, DataObjID &value)
Definition: DataObjIDProperty.h:55
StatusCode.h
ToStream.h
implementation of various functions for streaming.
DataObjIDCollProperty::value
const DataObjIDColl & value() const
Definition: DataObjIDProperty.h:171
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
std::ostream
STL class.
DataObjIDProperty::load
bool load(Property &destination) const override
Definition: DataObjIDProperty.h:70
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
GaudiMath::Interpolation::toString
std::string toString(const Type &)
Definition: Interpolation.cpp:42
Gaudi::Details::PropertyBase::operator=
PropertyBase & operator=(const PropertyBase &)=default
assignment operator