The Gaudi Framework  v29r0 (ff2e7097)
DataObjectHandleProperty.cpp
Go to the documentation of this file.
2 
4 #include "GaudiKernel/Parsers.h"
5 #include "GaudiKernel/System.h"
6 
7 #include <sstream>
8 
9 namespace Gaudi
10 {
11  namespace Parsers
12  {
13 
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 
33  : PropertyWithHandlers( name, typeid( DataObjectHandleBase ) ), m_pValue( &ref )
34 {
35 }
36 
37 //---------------------------------------------------------------------------
38 
40 {
41  if ( !Gaudi::Parsers::parse( *m_pValue, s ).isSuccess() ) {
42  return StatusCode::FAILURE;
43  }
45 }
46 
47 std::string DataObjectHandleProperty::pythonRepr() const { return "DataObjectHandleBase(\"" + toString() + "\")"; }
48 
49 //---------------------------------------------------------------------------
50 
52 {
53  m_pValue->operator=( value );
54  return useUpdateHandler();
55 }
56 
57 //---------------------------------------------------------------------------
58 
60 {
62  return m_pValue->toString();
63 }
64 
65 //---------------------------------------------------------------------------
67 {
68  // implicitly invokes useReadHandler()
69  out << toString();
70 }
71 
72 //---------------------------------------------------------------------------
73 
75 {
76  setValue( value );
77  return *this;
78 }
79 
80 //---------------------------------------------------------------------------
81 
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 
95 {
97  return *m_pValue;
98 }
bool load(Property &destination) const override
DataObjectHandleProperty & operator=(const DataObjectHandleBase &value)
DataObjectHandleBase * m_pValue
Pointer to the real property.
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
std::string toString() const
virtual void setKey(const DataObjID &key) const
Definition: DataHandle.h:46
Gaudi::Details::PropertyBase Property
backward compatibility hack for old Property base class
Definition: PropertyFwd.h:28
bool assign(const Property &source) override
DataObjectHandleProperty.h GaudiKernel/DataObjectHandleProperty.h.
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:786
void toStream(std::ostream &out) const override
value -> stream
STL class.
DataObjectHandleProperty * clone() const override
clones the current property
std::ostream & toStream(const Type &, std::ostream &)
DataObjectHandleProperty(const std::string &name, DataObjectHandleBase &ref)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
bool setValue(const DataObjectHandleBase &value)
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:812
StatusCode fromString(const std::string &s) override
string -> value
DataObjectHandleBase GaudiKernel/DataObjectHandleBase.h.
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:815
string s
Definition: gaudirun.py:253
const DataObjectHandleBase & value() const
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string toString() const override
value -> string