ATLAS Offline Software
WhiteBoardSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 // Please feel free to contact me (krumnack@iastate.edu) for bug
11 // reports, feature suggestions, praise and complaints.
12 
13 
14 //
15 // includes
16 //
17 //
18 
20 
21 #include <memory>
22 #include <RootCoreUtils/Assert.h>
23 #include <EventLoop/IWorker.h>
24 #include <SampleHandler/MetaData.h>
26 
27 //
28 // method implementations
29 //
30 
32 
33 namespace EL
34 {
35  WhiteBoardSvc *getWhiteBoardSvc (IWorker *worker)
36  {
37  RCU_REQUIRE_SOFT (worker != 0);
38  WhiteBoardSvc *const result
39  = dynamic_cast<WhiteBoardSvc*>(worker->getAlg ("WhiteBoardSvc"));
40  RCU_ASSERT2_SOFT (result != 0, "whiteboard service not found");
41  return result;
42  }
43 
44 
45 
46  void WhiteBoardSvc ::
47  testInvariant () const
48  {
49  RCU_INVARIANT (this != 0);
50  }
51 
52 
53 
56  {
57  RCU_NEW_INVARIANT (this);
58  }
59 
60 
61 
62  bool WhiteBoardSvc ::
63  hasVar (const std::string& name) const
64  {
66  return doHasVar (name);
67  }
68 
69 
70 
71  float WhiteBoardSvc ::
72  getFloat (const std::string& name) const
73  {
75  return doGetFloat (name);
76  }
77 
78 
79 
80  void WhiteBoardSvc ::
81  getArray (const std::string& name, std::size_t& size,
82  const float*& values) const
83  {
85  std::size_t tmpSize = 0;
86  const float *tmpValues = 0;
87  doGetArray (name, tmpSize, tmpValues);
88  size = tmpSize;
89  values = tmpValues;
90  }
91 
92 
93 
94  TObject *WhiteBoardSvc ::
95  getTObject (const std::string& name) const
96  {
98  TObject *result = doGetTObject (name);
99  RCU_PROVIDE (result != 0);
100  return result;
101  }
102 
103 
104 
105  void WhiteBoardSvc ::
106  setFloat (const std::string& name, float value)
107  {
109  doSetFloat (name, value);
110  }
111 
112 
113 
114  void WhiteBoardSvc ::
115  setArray (const std::string& name, const std::vector<float>& value)
116  {
118  doSetArray (name, value.size(), &value[0]);
119  }
120 
121 
122 
123  void WhiteBoardSvc ::
124  setArray (const std::string& name, std::size_t size, const float *values)
125  {
128  }
129 
130 
131 
132  void WhiteBoardSvc ::
133  setTObject (TObject *object, bool swallow)
134  {
136  doSetTObject (object, swallow);
137  }
138 
139 
140 
141  const char *WhiteBoardSvc ::
142  GetName () const
143  {
144  RCU_READ_INVARIANT (this);
145  return "WhiteBoardSvc";
146  }
147 
148 
149 
150  bool WhiteBoardSvc ::
151  doHasVar (const std::string& /*name*/) const
152  {
153  RCU_ASSERT0_NOIMP ("failed to override WhiteBoardSvc::doHasVar");
154  return false; // compiler dummy
155  }
156 
157 
158 
159  float WhiteBoardSvc ::
160  doGetFloat (const std::string& name) const
161  {
163 
164  TObject *const object = getTObject (name);
165  RCU_ASSERT (object != 0);
166  SH::MetaData<float> *const meta
167  = dynamic_cast<SH::MetaData<float>*>(object);
168  RCU_ASSERT2_SOFT (meta != 0, ("variable " + name + " not of type float").c_str());
169  return meta->value;
170  }
171 
172 
173 
174  void WhiteBoardSvc ::
175  doGetArray (const std::string& name, std::size_t& size,
176  const float*& values) const
177  {
179 
180  TObject *const object = getTObject (name);
181  RCU_ASSERT (object != 0);
182  SH::MetaVector<float> *const meta
183  = dynamic_cast<SH::MetaVector<float>*>(object);
184  RCU_ASSERT2_SOFT (meta != 0, ("variable " + name + " not of type float array").c_str());
185  size = meta->value.size();
186  values = &meta->value[0];
187  }
188 
189 
190 
191  TObject *WhiteBoardSvc ::
192  doGetTObject (const std::string& /*name*/) const
193  {
194  RCU_ASSERT0_NOIMP ("function WhiteBoardSvc::doGetTObject not overloaded");
195  return 0; // compiler dummy
196  }
197 
198 
199 
200  void WhiteBoardSvc ::
201  doSetFloat (const std::string& name, float value)
202  {
204 
205  std::unique_ptr<SH::MetaData<float> > meta (new SH::MetaData<float>);
206  meta->SetName (name.c_str());
207  meta->value = value;
208  setTObject (meta.release(), true);
209  }
210 
211 
212 
213  void WhiteBoardSvc ::
214  doSetArray (const std::string& name, std::size_t size, const float *values)
215  {
217 
218  std::unique_ptr<SH::MetaVector<float> > meta (new SH::MetaVector<float>);
219  meta->SetName (name.c_str());
220  std::vector<float> (values, values+size).swap (meta->value);
221  setTObject (meta.release(), true);
222  }
223 
224 
225 
226  void WhiteBoardSvc ::
227  doSetTObject (TObject *object, bool swallow)
228  {
229  if (swallow)
230  delete object;
231  RCU_ASSERT0_NOIMP ("function WhiteBoardSvc::doSetTObject not overloaded");
232  }
233 }
get_generator_info.result
result
Definition: get_generator_info.py:21
EL::WhiteBoardSvc::doGetArray
virtual void doGetArray(const std::string &name, std::size_t &size, const float *&values) const
EL::WhiteBoardSvc::doHasVar
virtual bool doHasVar(const std::string &name) const
returns: whether we have the given variable guarantee: strong failures: out of memory II rationale: t...
MetaVector.h
MetaData.h
EL::WhiteBoardSvc::doGetTObject
virtual TObject * doGetTObject(const std::string &name) const
SH::MetaVector::value
std::vector< T > value
the value contained
Definition: MetaVector.h:65
athena.value
value
Definition: athena.py:122
EL::WhiteBoardSvc::testInvariant
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
Assert.h
WhiteBoardSvc.h
SH::MetaVector
This class defines a templatized version of the meta-data in vector form.
Definition: D3PDTools/SampleHandler/SampleHandler/Global.h:42
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
EL::WhiteBoardSvc::getTObject
TObject * getTObject(const std::string &name) const
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
RCU_PROVIDE
#define RCU_PROVIDE(x)
Definition: Assert.h:215
RCU_ASSERT2_SOFT
#define RCU_ASSERT2_SOFT(x, y)
Definition: Assert.h:169
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition: Assert.h:153
EL::WhiteBoardSvc::getArray
void getArray(const std::string &name, std::size_t &size, const float *&values) const
EL::WhiteBoardSvc::setArray
void setArray(const std::string &name, const std::vector< float > &value)
EL::WhiteBoardSvc::getFloat
float getFloat(const std::string &name) const
returns: the content of the variable, assuming the given type guarantee: strong failures: variable no...
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::WhiteBoardSvc::GetName
virtual const char * GetName() const
effects: return the name of this algorithm guarantee: no-fail
EL::Algorithm::name
virtual const std::string & name() const
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EL::WhiteBoardSvc::doSetFloat
virtual void doSetFloat(const std::string &name, float value)
returns: set/create a variable, assuming the given type guarantee: strong failures: given type not su...
EL::WhiteBoardSvc::WhiteBoardSvc
WhiteBoardSvc()
effects: standard constructor guarantee: strong failures: out of memory I rationale: this constructor...
EL::WhiteBoardSvc::setTObject
void setTObject(TObject *object, bool swallow=true)
EL::WhiteBoardSvc::doSetArray
virtual void doSetArray(const std::string &name, std::size_t size, const float *values)
EL::WhiteBoardSvc::hasVar
bool hasVar(const std::string &name) const
returns: whether we have the given variable guarantee: strong failures: out of memory II
EL::WhiteBoardSvc::doSetTObject
virtual void doSetTObject(TObject *object, bool swallow)
EL::WhiteBoardSvc::setFloat
void setFloat(const std::string &name, float value)
returns: set/create a variable, assuming the given type guarantee: strong failures: given type not su...
SH::MetaData
A class implementing a templatized version of the meta-data.
Definition: D3PDTools/SampleHandler/SampleHandler/Global.h:36
EL::getWhiteBoardSvc
WhiteBoardSvc * getWhiteBoardSvc(IWorker *worker)
effects: get the whiteboard service for this worker guarantee: strong failures: formula service not c...
pickleTool.object
object
Definition: pickleTool.py:30
ClassImp
ClassImp(EL::WhiteBoardSvc) namespace EL
Definition: WhiteBoardSvc.cxx:31
EL::WhiteBoardSvc
Definition: WhiteBoardSvc.h:41
IWorker.h
RCU_ASSERT0_NOIMP
#define RCU_ASSERT0_NOIMP(y)
Definition: Assert.h:194
RCU_ASSERT
#define RCU_ASSERT(x)
Definition: Assert.h:222
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
EL::WhiteBoardSvc::doGetFloat
virtual float doGetFloat(const std::string &name) const
returns: the content of the variable, assuming the given type guarantee: strong failures: variable no...
SH::MetaData::value
T value
the value contained
Definition: MetaData.h:64
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233