The Gaudi Framework  master (1a7a3838)
Loading...
Searching...
No Matches
DataHandleProperty.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 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( Gaudi::DataHandleVectorBase ) ), m_pValue( &ref ) {}
38
39//---------------------------------------------------------------------------
40
43 try {
45 } catch ( const std::invalid_argument& ) { return StatusCode::FAILURE; }
46 m_pValue->setKeys( ids );
48}
49
50//---------------------------------------------------------------------------
51
56
57//---------------------------------------------------------------------------
58
61 return Gaudi::Utils::toString( m_pValue->keys() );
62}
63
64//---------------------------------------------------------------------------
65void DataHandleVectorProperty::toStream( std::ostream& out ) const {
67 Gaudi::Utils::toStream( m_pValue->keys(), out );
68}
69
70//---------------------------------------------------------------------------
71
76
77//---------------------------------------------------------------------------
78
80
81//---------------------------------------------------------------------------
82
84 return destination.assign( *this );
85}
86
87//---------------------------------------------------------------------------
88
92
93//---------------------------------------------------------------------------
94
99
100//---------------------------------------------------------------------------
101
103 : PropertyWithHandlers( name, typeid( ref ) ), m_pValue( &ref ) {}
104
105//---------------------------------------------------------------------------
106
108 if ( !Gaudi::Parsers::parse( *m_pValue, s ).isSuccess() ) { return StatusCode::FAILURE; }
110}
111
112//---------------------------------------------------------------------------
113
118
119//---------------------------------------------------------------------------
120
121std::string DataHandleProperty::toString() const {
123 return m_pValue->objKey();
124}
125
126//---------------------------------------------------------------------------
127void DataHandleProperty::toStream( std::ostream& out ) const {
128 // implicitly invokes useReadHandler()
129 out << toString();
130}
131
132//---------------------------------------------------------------------------
133
138
139//---------------------------------------------------------------------------
140
142
143//---------------------------------------------------------------------------
144
145bool DataHandleProperty::load( Gaudi::Details::PropertyBase& destination ) const { return destination.assign( *this ); }
146
147//---------------------------------------------------------------------------
148
150 return fromString( source.toString() ).isSuccess();
151}
152
153//---------------------------------------------------------------------------
154
157 return *m_pValue;
158}
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
std::vector< DataObjID > DataObjIDVector
Definition DataObjID.h:122
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)
DataHandleVectorProperty & operator=(const Gaudi::DataHandleVectorBase &value)
DataHandleVectorProperty(const std::string &name, Gaudi::DataHandleVectorBase &ref)
std::string toString() const override
value -> string
bool load(Gaudi::Details::PropertyBase &destination) const override
export the property value to the destination
Gaudi::DataHandleVectorBase * m_pValue
Pointer to the real property.
bool assign(const Gaudi::Details::PropertyBase &source) override
import the property value form the source
bool setValue(const Gaudi::DataHandleVectorBase &value)
void toStream(std::ostream &out) const override
value -> stream
const Gaudi::DataHandleVectorBase & value() const
DataHandleVectorProperty * clone() const override
clones the current property
StatusCode fromString(const std::string &s) override
string -> value
Type-erased interface for a configurable sequence of data handles.
Definition DataHandle.h:100
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:582
bool useUpdateHandler() override
use the call-back function at update, if available
Definition Property.h:608
void useReadHandler() const
use the call-back function at reading, if available
Definition Property.h:605
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:302
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::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:329
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:307
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
TYPE fromString(const TYPE &, const std::string &s) final override
Definition Property.h:95