The Gaudi Framework  v29r0 (ff2e7097)
DataObjIDProperty.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAOBJIDPROPERTY_H
2 #define GAUDIKERNEL_DATAOBJIDPROPERTY_H 1
3 
5 #include "GaudiKernel/Parsers.h"
6 #include "GaudiKernel/Property.h"
8 #include "GaudiKernel/ToStream.h"
9 
10 #include <iostream>
11 
12 //---------------------------------------------------------------------------
13 
24 //---------------------------------------------------------------------------
25 
27 {
28 public:
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:
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 
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 
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 
89 {
90 public:
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:
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 <>
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:
150  };
151 } // namespace Gaudi
152 
154 {
155  setValue( value );
156  return *this;
157 }
158 
160 
162 {
163  return destination.assign( *this );
164 }
165 
167 {
168  return fromString( source.toString() ).isSuccess();
169 }
170 
172 {
173  useReadHandler();
174  return *m_pValue;
175 }
176 
177 #endif
Property(const std::string &name, DataObjIDColl &value)
bool assign(const Property &source) override
Property(OWNER *owner, const std::string &name, const DataObjIDColl &initval=DataObjIDColl{}, std::string doc="")
Autodeclaring constructor with property name, value and documentation.
Implementation of property with value of concrete type.
Definition: Property.h:319
DataObjIDCollProperty * clone() const override
clones the current property
virtual bool load(PropertyBase &dest) const =0
export the property value to the destination
virtual ~Property()
virtual Destructor
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
Property(const std::string &name, DataObjIDColl &value)
virtual std::string toString() const =0
value -> string
bool load(Property &destination) const override
Gaudi::Details::PropertyBase Property
backward compatibility hack for old Property base class
Definition: PropertyFwd.h:28
DataObjIDProperty * clone() const override
clones the current property
std::unique_ptr< DataObjIDColl > m_data
DataObjIDCollProperty & operator=(const DataObjIDColl &value)
virtual void toStream(std::ostream &out) const =0
value -> stream
virtual StatusCode fromString(const std::string &value)=0
string -> value
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:786
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
virtual ~Property()
virtual Destructor
std::ostream & toStream(const Type &, std::ostream &)
DataObjID * m_pValue
Pointer to the real property.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
virtual PropertyBase * clone() const =0
clones the current property
DataObjIDProperty & operator=(const DataObjID &value)
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
const DataObjID & value() const
bool assign(const Property &source) override
virtual ~Property()
virtual Destructor
T move(T...args)
STL class.
DataObjIDProperty.h GaudiKernel/DataObjProperty.h.
string s
Definition: gaudirun.py:253
DataObjIDColl * m_pValue
Pointer to the real property.
Property(const std::string &name, DataObjID &value)
implementation of various functions for streaming.
const DataObjIDColl & value() const
#define GAUDI_API
Definition: Kernel.h:110
STL class.
bool load(Property &destination) const override
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string toString(const Type &)
PropertyBase & operator=(const PropertyBase &)=default
assignment operator