| The Gaudi Framework v32r1 (f65d50dc)

DataObjectHandleProperty.cpp
Go to the documentation of this file.
1 #include "GaudiKernel/DataObjectHandleProperty.h"
2
3 #include "GaudiKernel/DataObjectHandleBase.h"
4 #include "GaudiKernel/System.h"
5 #include <Gaudi/Parsers/CommonParsers.h>
6
7 #include <sstream>
8
9 namespace Gaudi {
10 namespace Parsers {
11 StatusCode parse( DataObjectHandleBase& v, const std::string& s ) {
12 DataObjID id;
13 auto sc = parse( id, s );
14 if ( sc ) v.setKey( std::move( id ) );
15 return sc;
16 }
17 } // namespace Parsers
18
19 namespace Utils {
20 std::ostream& toStream( const DataObjectHandleBase& v, std::ostream& o ) { return o << v; }
21 } // namespace Utils
22 } // namespace Gaudi
23
24 //---------------------------------------------------------------------------
25
26 DataObjectHandleProperty::DataObjectHandleProperty( const std::string& name, DataObjectHandleBase& ref )
27 : PropertyWithHandlers( name, typeid( DataObjectHandleBase ) ), m_pValue( &ref ) {}
28
29 //---------------------------------------------------------------------------
30
31 StatusCode DataObjectHandleProperty::fromString( const std::string& s ) {
32 if ( !Gaudi::Parsers::parse( *m_pValue, s ).isSuccess() ) { return StatusCode::FAILURE; }
33 return useUpdateHandler() ? StatusCode::SUCCESS : StatusCode::FAILURE;
34 }
35
36 //---------------------------------------------------------------------------
37
38 bool DataObjectHandleProperty::setValue( const DataObjectHandleBase& value ) {
39 *m_pValue = value;
40 return useUpdateHandler();
41 }
42
43 //---------------------------------------------------------------------------
44
45 std::string DataObjectHandleProperty::toString() const {
46 useReadHandler();
47 return m_pValue->toString();
48 }
49
50 //---------------------------------------------------------------------------
51 void DataObjectHandleProperty::toStream( std::ostream& out ) const {
52 // implicitly invokes useReadHandler()
53 out << toString();
54 }
55
56 //---------------------------------------------------------------------------
57
58 DataObjectHandleProperty& DataObjectHandleProperty::operator=( const DataObjectHandleBase& value ) {
59 setValue( value );
60 return *this;
61 }
62
63 //---------------------------------------------------------------------------
64
65 DataObjectHandleProperty* DataObjectHandleProperty::clone() const { return new DataObjectHandleProperty( *this ); }
66
67 //---------------------------------------------------------------------------
68
69 bool DataObjectHandleProperty::load( Property& destination ) const { return destination.assign( *this ); }
70
71 //---------------------------------------------------------------------------
72
73 bool DataObjectHandleProperty::assign( const Property& source ) { return fromString( source.toString() ).isSuccess(); }
74
75 //---------------------------------------------------------------------------
76
77 const DataObjectHandleBase& DataObjectHandleProperty::value() const {
78 useReadHandler();
79 return *m_pValue;
80 }
System.h
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:284
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
DataObjID
Definition: DataObjID.h:37
DataObjectHandleProperty::operator=
DataObjectHandleProperty & operator=(const DataObjectHandleBase &value)
Definition: DataObjectHandleProperty.cpp:58
DataObjectHandleProperty::m_pValue
DataObjectHandleBase * m_pValue
Pointer to the real property.
Definition: DataObjectHandleProperty.h:41
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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
Gaudi::DataHandle::setKey
virtual void setKey(const DataObjID &key) const
Definition: DataHandle.h:44
Property
Gaudi::Details::PropertyBase Property
\fixme backward compatibility hack for old Property base class
Definition: PropertyFwd.h:25
CommonParsers.h
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
DataObjectHandleProperty::assign
bool assign(const Property &source) override
Definition: DataObjectHandleProperty.cpp:73
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:806
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
DataObjectHandleProperty::load
bool load(Property &destination) const override
Definition: DataObjectHandleProperty.cpp:69
DataObjectHandleProperty::DataObjectHandleProperty
DataObjectHandleProperty(const std::string &name, DataObjectHandleBase &ref)
Definition: DataObjectHandleProperty.cpp:26
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
std::move
T move(T... args)
DataObjectHandleProperty::setValue
bool setValue(const DataObjectHandleBase &value)
Definition: DataObjectHandleProperty.cpp:38
DataObjectHandleBase.h
DataObjectHandleProperty::value
const DataObjectHandleBase & value() const
Definition: DataObjectHandleProperty.cpp:77
DataObjectHandleProperty::fromString
StatusCode fromString(const std::string &s) override
string -> value
Definition: DataObjectHandleProperty.cpp:31
DataObjectHandleBase
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
Definition: DataObjectHandleBase.h:26
PropertyWithHandlers<>::useUpdateHandler
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:832
DataObjectHandleProperty::toString
std::string toString() const override
value -> string
Definition: DataObjectHandleProperty.cpp:45
gaudirun.s
string s
Definition: gaudirun.py:316
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
DataObjectHandleProperty::clone
DataObjectHandleProperty * clone() const override
clones the current property
Definition: DataObjectHandleProperty.cpp:65
DataObjectHandleBase::toString
std::string toString() const
Definition: DataObjectHandleBase.cpp:109
DataObjectHandleProperty::toStream
void toStream(std::ostream &out) const override
value -> stream
Definition: DataObjectHandleProperty.cpp:51
std::ostream
STL class.
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
PropertyWithHandlers<>::useReadHandler
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:829