The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
15#include <GaudiKernel/System.h>
16
17#include <sstream>
18
19namespace 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
52
53//---------------------------------------------------------------------------
54
55std::string DataHandleProperty::toString() const {
57 return m_pValue->objKey();
58}
59
60//---------------------------------------------------------------------------
61void DataHandleProperty::toStream( std::ostream& out ) const {
62 // implicitly invokes useReadHandler()
63 out << toString();
64}
65
66//---------------------------------------------------------------------------
67
72
73//---------------------------------------------------------------------------
74
76
77//---------------------------------------------------------------------------
78
79bool DataHandleProperty::load( Gaudi::Details::PropertyBase& destination ) const { return destination.assign( *this ); }
80
81//---------------------------------------------------------------------------
82
84 return fromString( source.toString() ).isSuccess();
85}
86
87//---------------------------------------------------------------------------
88
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
DataHandleProperty(const std::string &name, Gaudi::DataHandle &ref)
Gaudi::DataHandle * m_pValue
Pointer to the real property.
bool load(Gaudi::Details::PropertyBase &destination) const override
export the property value to the destination
DataHandleProperty * clone() const override
clones the current property
bool assign(const Gaudi::Details::PropertyBase &source) override
import the property value form the source
void toStream(std::ostream &out) const override
value -> stream
DataHandleProperty & operator=(const Gaudi::DataHandle &value)
const Gaudi::DataHandle & value() const
std::string toString() const override
value -> string
StatusCode fromString(const std::string &s) override
string -> value
bool setValue(const Gaudi::DataHandle &value)
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
virtual std::string toString() const =0
value -> string
virtual bool assign(const PropertyBase &source)=0
import the property value form the source
const std::string name() const
property name
Helper class to simplify the migration old properties deriving directly from PropertyBase.
Definition Property.h:530
bool useUpdateHandler() override
use the call-back function at update, if available
Definition Property.h:556
void useReadHandler() const
use the call-back function at reading, if available
Definition Property.h:553
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
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:304
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1