| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

DataObjectHandleProperty.cpp
Go to the documentation of this file.
1 #include "GaudiKernel/DataObjectHandleProperty.h"
2
3 #include "GaudiKernel/DataObjectHandleBase.h"
4 #include "GaudiKernel/Parsers.h"
5 #include "GaudiKernel/System.h"
6
7 #include <sstream>
8
9 namespace Gaudi
10 {
11 namespace Parsers
12 {
13
14 StatusCode parse( DataObjectHandleBase& v, const std::string& s )
15 {
16 std::string prop;
17 auto sc = Gaudi::Parsers::parse( prop, s );
18 if ( sc ) v.setKey( DataObjID( s ) );
19 return sc;
20 }
21 }
22
23 namespace Utils
24 {
25
26 std::ostream& toStream( const DataObjectHandleBase& v, std::ostream& o ) { return o << v; }
27 }
28 }
29
30 //---------------------------------------------------------------------------
31
32 DataObjectHandleProperty::DataObjectHandleProperty( const std::string& name, DataObjectHandleBase& ref )
33 : PropertyWithHandlers( name, typeid( DataObjectHandleBase ) ), m_pValue( &ref )
34 {
35 }
36
37 //---------------------------------------------------------------------------
38
39 StatusCode DataObjectHandleProperty::fromString( const std::string& s )
40 {
41 if ( !Gaudi::Parsers::parse( *m_pValue, s ).isSuccess() ) {
42 return StatusCode::FAILURE;
43 }
44 return useUpdateHandler() ? StatusCode::SUCCESS : StatusCode::FAILURE;
45 }
46
47 std::string DataObjectHandleProperty::pythonRepr() const { return "DataObjectHandleBase(\"" + toString() + "\")"; }
48
49 //---------------------------------------------------------------------------
50
51 bool DataObjectHandleProperty::setValue( const DataObjectHandleBase& value )
52 {
53 m_pValue->operator=( value );
54 return useUpdateHandler();
55 }
56
57 //---------------------------------------------------------------------------
58
59 std::string DataObjectHandleProperty::toString() const
60 {
61 useReadHandler();
62 return m_pValue->toString();
63 }
64
65 //---------------------------------------------------------------------------
66 void DataObjectHandleProperty::toStream( std::ostream& out ) const
67 {
68 // implicitly invokes useReadHandler()
69 out << toString();
70 }
71
72 //---------------------------------------------------------------------------
73
74 DataObjectHandleProperty& DataObjectHandleProperty::operator=( const DataObjectHandleBase& value )
75 {
76 setValue( value );
77 return *this;
78 }
79
80 //---------------------------------------------------------------------------
81
82 DataObjectHandleProperty* DataObjectHandleProperty::clone() const { return new DataObjectHandleProperty( *this ); }
83
84 //---------------------------------------------------------------------------
85
86 bool DataObjectHandleProperty::load( Property& destination ) const { return destination.assign( *this ); }
87
88 //---------------------------------------------------------------------------
89
90 bool DataObjectHandleProperty::assign( const Property& source ) { return fromString( source.toString() ).isSuccess(); }
91
92 //---------------------------------------------------------------------------
93
94 const DataObjectHandleBase& DataObjectHandleProperty::value() const
95 {
96 useReadHandler();
97 return *m_pValue;
98 }
DataObjectHandleProperty::load
bool load(Property &destination) const override
Definition: DataObjectHandleProperty.cpp:86
System.h
StatusCode::SUCCESS
Definition: StatusCode.h:30
DataObjectHandleProperty::pythonRepr
std::string pythonRepr() const
Definition: DataObjectHandleProperty.cpp:47
DataObjectHandleProperty.h
Gaudi::Utils::toStream
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:315
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
StatusCode::FAILURE
Definition: StatusCode.h:29
DataObjID
Definition: DataObjID.h:38
DataObjectHandleProperty::operator=
DataObjectHandleProperty & operator=(const DataObjectHandleBase &value)
Definition: DataObjectHandleProperty.cpp:74
DataObjectHandleProperty::m_pValue
DataObjectHandleBase * m_pValue
Pointer to the real property.
Definition: DataObjectHandleProperty.h:44
Parsers.h
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:11
DataObjectHandleBase::toString
std::string toString() const
Definition: DataObjectHandleBase.cpp:120
Gaudi::DataHandle::setKey
virtual void setKey(const DataObjID &key) const
Definition: DataHandle.h:53
Property
Gaudi::Details::PropertyBase Property
backward compatibility hack for old Property base class
Definition: PropertyFwd.h:28
DataObjectHandleProperty::assign
bool assign(const Property &source) override
Definition: DataObjectHandleProperty.cpp:90
DataObjectHandleProperty
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
Definition: DataObjectHandleProperty.h:23
PropertyWithHandlers
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:751
DataObjectHandleProperty::toStream
void toStream(std::ostream &out) const override
value -> stream
Definition: DataObjectHandleProperty.cpp:66
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
DataObjectHandleProperty::clone
DataObjectHandleProperty * clone() const override
clones the current property
Definition: DataObjectHandleProperty.cpp:82
DataObjectHandleProperty::DataObjectHandleProperty
DataObjectHandleProperty(const std::string &name, DataObjectHandleBase &ref)
Definition: DataObjectHandleProperty.cpp:32
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
DataObjectHandleProperty::setValue
bool setValue(const DataObjectHandleBase &value)
Definition: DataObjectHandleProperty.cpp:51
DataObjectHandleBase.h
PropertyWithHandlers<>::useReadHandler
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:777
DataObjectHandleProperty::fromString
StatusCode fromString(const std::string &s) override
string -> value
Definition: DataObjectHandleProperty.cpp:39
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:24
PropertyWithHandlers<>::useUpdateHandler
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:780
gaudirun.s
string s
Definition: gaudirun.py:245
DataObjectHandleProperty::value
const DataObjectHandleBase & value() const
Definition: DataObjectHandleProperty.cpp:94
std::ostream
STL class.
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
DataObjectHandleProperty::toString
std::string toString() const override
value -> string
Definition: DataObjectHandleProperty.cpp:59