ATLAS Offline Software
VarHandleKeyProperty.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
13 // STL includes
14 #include <sstream>
15 #include <map>
16 #include <boost/tokenizer.hpp>
17 
18 // StoreGate includes
20 
21 static const char* const storeSeparator = "+";
22 
23 namespace Gaudi {
24 namespace Parsers {
25 
26 
37 parse(SG::VarHandleKey& v, const std::string& s)
38 {
39  std::string prop;
41  if (sc.isSuccess())
42  sc = v.assign (prop);
43  return sc;
44 }
45 
46 } //> ns Parsers
47 
48 namespace Utils {
49 
50 
60 std::ostream&
61 toStream(const SG::VarHandleKey& v, std::ostream& o)
62 {
63  o << "'" << v.storeHandle().name() << storeSeparator << v.key() << "'";
64  return o;
65 }
66 
67 } //> ns Utils
68 
69 } //> ns Gaudi
70 
71 
72 namespace SG {
73 
74 
82  : DataHandleProperty( name, ref ),
83  m_pValue( &ref )
84 {
85 }
86 
87 
96 {
97  setValue( value );
98  return *this;
99 }
100 
101 
110 {
111  return new VarHandleKeyProperty( *this );
112 }
113 
114 
123 bool
124 VarHandleKeyProperty::load( Gaudi::Details::PropertyBase& destination ) const
125 {
126  return destination.assign( *this );
127 }
128 
129 
138 bool
139 VarHandleKeyProperty::assign( const Gaudi::Details::PropertyBase& source )
140 {
141  return fromString( source.toString() ).isSuccess();
142 }
143 
144 
148 std::string
150 {
151  useReadHandler();
152  std::ostringstream o;
154  return o.str();
155 }
156 
157 
162 void
164 {
165  useReadHandler();
166  out << this->toString();
167 }
168 
169 
176 StatusCode
178 {
179  if (!Gaudi::Parsers::parse(*m_pValue, s).isSuccess()) {
180  return StatusCode::FAILURE;
181  }
182  return useUpdateHandler()
183  ? StatusCode::SUCCESS
184  : StatusCode::FAILURE;
185 }
186 
187 
191 const SG::VarHandleKey&
193 {
194  useReadHandler();
195  return *m_pValue;
196 }
197 
198 
205 bool
207 {
208  m_pValue->operator=(value);
209  return useUpdateHandler();
210 }
211 
212 
213 } // namespace SG
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VarHandleKeyProperty.h
Handle Gaudi property setting for VarHandleKey.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
Gaudi::Parsers::parse
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:284
SG::VarHandleKeyProperty::assign
virtual bool assign(const Gaudi::Details::PropertyBase &source) override
Set the value of this Property from another.
Definition: VarHandleKeyProperty.cxx:139
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
SG::VarHandleKeyProperty::load
virtual bool load(Gaudi::Details::PropertyBase &destination) const override
Set the value of another Property.
Definition: VarHandleKeyProperty.cxx:124
athena.value
value
Definition: athena.py:122
SG::VarHandleKeyProperty::m_pValue
SG::VarHandleKey * m_pValue
Pointer to the real property.
Definition: VarHandleKeyProperty.h:173
storeSeparator
constexpr char const storeSeparator
Definition: StoreGate/src/VarHandleKey.cxx:27
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyProperty::setValue
bool setValue(const SG::VarHandleKey &value)
Set the value object for this Property.
Definition: VarHandleKeyProperty.cxx:206
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::VarHandleKeyProperty::toStream
virtual void toStream(std::ostream &out) const override
Write a string representation of the value object to a stream.
Definition: VarHandleKeyProperty.cxx:163
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
python.PyAthena.v
v
Definition: PyAthena.py:157
Gaudi::Utils::toStream
std::ostream &GAUDI_API toStream(const SG::VarHandleKeyArray &v, std::ostream &o)
Gaudi function used to convert a property to a string.
Definition: StoreGate/src/VarHandleKeyArray.cxx:49
SG::VarHandleKeyProperty::VarHandleKeyProperty
VarHandleKeyProperty(const std::string &name, SG::VarHandleKey &ref)
Constructor with parameters.
Definition: VarHandleKeyProperty.cxx:80
ref
const boost::regex ref(r_ef)
SG::VarHandleKeyProperty::value
const SG::VarHandleKey & value() const
Return the value object for this Property.
Definition: VarHandleKeyProperty.cxx:192
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
SG::VarHandleKeyProperty::clone
virtual VarHandleKeyProperty * clone() const override
Return a new copy of this Property object.
Definition: VarHandleKeyProperty.cxx:109
Utils
Definition: CaloCellSelectorUtils.cxx:10
SG::VarHandleKeyProperty
VarHandleKeyProperty is the class which wraps a SG::VarHandleKey.
Definition: VarHandleKeyProperty.h:81
SG::VarHandleKeyProperty::fromString
virtual StatusCode fromString(const std::string &s) override
Set this value object from a string.
Definition: VarHandleKeyProperty.cxx:177
SG::VarHandleKeyProperty::operator=
VarHandleKeyProperty & operator=(const SG::VarHandleKey &value)
Assignment operator.
Definition: VarHandleKeyProperty.cxx:95
SG::VarHandleKeyProperty::toString
virtual std::string toString() const override
Return a string representation of the value object.
Definition: VarHandleKeyProperty.cxx:149