The Gaudi Framework  v33r1 (b1225454)
DataObjectHandleProperty.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
12 
14 #include "GaudiKernel/System.h"
16 
17 #include <sstream>
18 
19 namespace Gaudi {
20  namespace Parsers {
22  DataObjID id;
23  auto sc = parse( id, s );
24  if ( sc ) v.setKey( std::move( id ) );
25  return sc;
26  }
27  } // namespace Parsers
28 
29  namespace Utils {
30  std::ostream& toStream( const DataObjectHandleBase& v, std::ostream& o ) { return o << v; }
31  } // namespace Utils
32 } // namespace Gaudi
33 
34 //---------------------------------------------------------------------------
35 
37  : PropertyWithHandlers( name, typeid( DataObjectHandleBase ) ), m_pValue( &ref ) {}
38 
39 //---------------------------------------------------------------------------
40 
42  if ( !Gaudi::Parsers::parse( *m_pValue, s ).isSuccess() ) { return StatusCode::FAILURE; }
44 }
45 
46 //---------------------------------------------------------------------------
47 
49  *m_pValue = value;
50  return useUpdateHandler();
51 }
52 
53 //---------------------------------------------------------------------------
54 
57  return m_pValue->toString();
58 }
59 
60 //---------------------------------------------------------------------------
62  // implicitly invokes useReadHandler()
63  out << toString();
64 }
65 
66 //---------------------------------------------------------------------------
67 
69  setValue( value );
70  return *this;
71 }
72 
73 //---------------------------------------------------------------------------
74 
76 
77 //---------------------------------------------------------------------------
78 
79 bool DataObjectHandleProperty::load( Property& destination ) const { return destination.assign( *this ); }
80 
81 //---------------------------------------------------------------------------
82 
83 bool DataObjectHandleProperty::assign( const Property& source ) { return fromString( source.toString() ).isSuccess(); }
84 
85 //---------------------------------------------------------------------------
86 
89  return *m_pValue;
90 }
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:291
DataObjectHandleProperty & operator=(const DataObjectHandleBase &value)
DataObjectHandleBase * m_pValue
Pointer to the real property.
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Gaudi::Details::PropertyBase Property
\fixme backward compatibility hack for old Property base class
Definition: PropertyFwd.h:35
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
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:834
STL class.
bool load(Property &destination) const override
DataObjectHandleProperty(const std::string &name, DataObjectHandleBase &ref)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
T move(T... args)
bool setValue(const DataObjectHandleBase &value)
const DataObjectHandleBase & value() const
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:860
std::string toString() const override
value -> string
string s
Definition: gaudirun.py:328
constexpr static const auto FAILURE
Definition: StatusCode.h:101
virtual void setKey(DataObjID key) const
Definition: DataHandle.h:54
DataObjectHandleProperty * clone() const override
clones the current property
std::string toString() const
void toStream(std::ostream &out) const override
value -> stream
STL class.
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:857