The Gaudi Framework  master (37c0b60a)
DataHandleProperty.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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/DataHandle.h>
15 #include <GaudiKernel/System.h>
16 
17 #include <sstream>
18 
19 namespace Gaudi {
20  namespace Parsers {
21  StatusCode parse( DataHandle& v, std::string_view s ) {
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 Gaudi::DataHandle& v, std::ostream& o ) { return o << v; }
31  } // namespace Utils
32 } // namespace Gaudi
33 
34 //---------------------------------------------------------------------------
35 
37  : PropertyWithHandlers( name, typeid( ref ) ), 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->objKey();
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 DataHandleProperty::load( Gaudi::Details::PropertyBase& destination ) const { return destination.assign( *this ); }
80 
81 //---------------------------------------------------------------------------
82 
84  return fromString( source.toString() ).isSuccess();
85 }
86 
87 //---------------------------------------------------------------------------
88 
91  return *m_pValue;
92 }
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
DataHandleProperty::toString
std::string toString() const override
value -> string
Definition: DataHandleProperty.cpp:55
std::string
STL class.
DataHandleProperty::assign
bool assign(const Gaudi::Details::PropertyBase &source) override
import the property value form the source
Definition: DataHandleProperty.cpp:83
DataHandleProperty::value
const Gaudi::DataHandle & value() const
Definition: DataHandleProperty.cpp:89
std::move
T move(T... args)
DataHandleProperty::toStream
void toStream(std::ostream &out) const override
value -> stream
Definition: DataHandleProperty.cpp:61
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
DataHandleProperty::setValue
bool setValue(const Gaudi::DataHandle &value)
Definition: DataHandleProperty.cpp:48
System.h
DataHandleProperty::clone
DataHandleProperty * clone() const override
clones the current property
Definition: DataHandleProperty.cpp:75
DataHandleProperty.h
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:21
gaudirun.s
string s
Definition: gaudirun.py:346
DataHandleProperty
DataHandleProperty.h GaudiKernel/DataHandleProperty.h.
Definition: DataHandleProperty.h:34
Gaudi::DataHandle
Definition: DataHandle.h:38
DataHandleProperty::operator=
DataHandleProperty & operator=(const Gaudi::DataHandle &value)
Definition: DataHandleProperty.cpp:68
GaudiPartProp.tests.id
id
Definition: tests.py:111
DataHandleProperty::m_pValue
Gaudi::DataHandle * m_pValue
Pointer to the real property.
Definition: DataHandleProperty.h:52
DataHandleProperty::load
bool load(Gaudi::Details::PropertyBase &destination) const override
export the property value to the destination
Definition: DataHandleProperty.cpp:79
DataHandleProperty::fromString
StatusCode fromString(const std::string &s) override
string -> value
Definition: DataHandleProperty.cpp:41
StatusCode
Definition: StatusCode.h:65
std::ostream
STL class.
DataHandleProperty::DataHandleProperty
DataHandleProperty(const std::string &name, Gaudi::DataHandle &ref)
Definition: DataHandleProperty.cpp:36
Gaudi::DataHandle::objKey
virtual const std::string & objKey() const
Definition: DataHandle.h:60
Gaudi::Details::PropertyBase::assign
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
DataObjID
Definition: DataObjID.h:47
PropertyWithHandlers
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition: Property.h:539
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
CommonParsers.h
Gaudi::Details::PropertyBase::toString
virtual std::string toString() const =0
value -> string
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:299
PropertyWithHandlers<>::useUpdateHandler
bool useUpdateHandler() override
use the call-back function at update, if available
Definition: Property.h:565
DataHandle.h
Properties.v
v
Definition: Properties.py:122
compareRootHistos.ref
ref
Definition: compareRootHistos.py:27
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
PropertyWithHandlers<>::useReadHandler
void useReadHandler() const
use the call-back function at reading, if available
Definition: Property.h:562
PrepareBase.out
out
Definition: PrepareBase.py:20