ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7//
8// includes
9//
10//
11
13
14#include <memory>
16#include <EventLoop/IWorker.h>
19
20//
21// method implementations
22//
23
25
26namespace EL
27{
28 WhiteBoardSvc *getWhiteBoardSvc (IWorker *worker)
29 {
30 RCU_REQUIRE_SOFT (worker != 0);
31 WhiteBoardSvc *const result
32 = dynamic_cast<WhiteBoardSvc*>(worker->getAlg ("WhiteBoardSvc"));
33 RCU_ASSERT2_SOFT (result != 0, "whiteboard service not found");
34 return result;
35 }
36
37
38
39 void WhiteBoardSvc ::
40 testInvariant () const
41 {}
42
43
44
45 WhiteBoardSvc ::
46 WhiteBoardSvc ()
47 {
48 RCU_NEW_INVARIANT (this);
49 }
50
51
52
53 bool WhiteBoardSvc ::
54 hasVar (const std::string& name) const
55 {
57 return doHasVar (name);
58 }
59
60
61
62 float WhiteBoardSvc ::
63 getFloat (const std::string& name) const
64 {
66 return doGetFloat (name);
67 }
68
69
70
71 void WhiteBoardSvc ::
72 getArray (const std::string& name, std::size_t& size,
73 const float*& values) const
74 {
76 std::size_t tmpSize = 0;
77 const float *tmpValues = 0;
78 doGetArray (name, tmpSize, tmpValues);
79 size = tmpSize;
80 values = tmpValues;
81 }
82
83
84
85 TObject *WhiteBoardSvc ::
86 getTObject (const std::string& name) const
87 {
89 TObject *result = doGetTObject (name);
90 RCU_PROVIDE (result != 0);
91 return result;
92 }
93
94
95
96 void WhiteBoardSvc ::
97 setFloat (const std::string& name, float value)
98 {
100 doSetFloat (name, value);
101 }
102
103
104
105 void WhiteBoardSvc ::
106 setArray (const std::string& name, const std::vector<float>& value)
107 {
109 doSetArray (name, value.size(), &value[0]);
110 }
111
112
113
114 void WhiteBoardSvc ::
115 setArray (const std::string& name, std::size_t size, const float *values)
116 {
118 doSetArray (name, size, values);
119 }
120
121
122
123 void WhiteBoardSvc ::
124 setTObject (TObject *object, bool swallow)
125 {
127 doSetTObject (object, swallow);
128 }
129
130
131
132 const char *WhiteBoardSvc ::
133 GetName () const
134 {
135 RCU_READ_INVARIANT (this);
136 return "WhiteBoardSvc";
137 }
138
139
140
141 bool WhiteBoardSvc ::
142 doHasVar (const std::string& /*name*/) const
143 {
144 RCU_ASSERT0_NOIMP ("failed to override WhiteBoardSvc::doHasVar");
145 return false; // compiler dummy
146 }
147
148
149
150 float WhiteBoardSvc ::
151 doGetFloat (const std::string& name) const
152 {
154
155 TObject *const object = getTObject (name);
156 RCU_ASSERT (object != 0);
158 = dynamic_cast<SH::MetaData<float>*>(object);
159 RCU_ASSERT2_SOFT (meta != 0, ("variable " + name + " not of type float").c_str());
160 return meta->value;
161 }
162
163
164
165 void WhiteBoardSvc ::
166 doGetArray (const std::string& name, std::size_t& size,
167 const float*& values) const
168 {
170
171 TObject *const object = getTObject (name);
172 RCU_ASSERT (object != 0);
174 = dynamic_cast<SH::MetaVector<float>*>(object);
175 RCU_ASSERT2_SOFT (meta != 0, ("variable " + name + " not of type float array").c_str());
176 size = meta->value.size();
177 values = &meta->value[0];
178 }
179
180
181
182 TObject *WhiteBoardSvc ::
183 doGetTObject (const std::string& /*name*/) const
184 {
185 RCU_ASSERT0_NOIMP ("function WhiteBoardSvc::doGetTObject not overloaded");
186 return 0; // compiler dummy
187 }
188
189
190
191 void WhiteBoardSvc ::
192 doSetFloat (const std::string& name, float value)
193 {
195
196 std::unique_ptr<SH::MetaData<float> > meta (new SH::MetaData<float>);
197 meta->SetName (name.c_str());
198 meta->value = value;
199 setTObject (meta.release(), true);
200 }
201
202
203
204 void WhiteBoardSvc ::
205 doSetArray (const std::string& name, std::size_t size, const float *values)
206 {
208
209 std::unique_ptr<SH::MetaVector<float> > meta (new SH::MetaVector<float>);
210 meta->SetName (name.c_str());
211 std::vector<float> (values, values+size).swap (meta->value);
212 setTObject (meta.release(), true);
213 }
214
215
216
217 void WhiteBoardSvc ::
218 doSetTObject (TObject *object, bool swallow)
219 {
220 if (swallow)
221 delete object;
222 RCU_ASSERT0_NOIMP ("function WhiteBoardSvc::doSetTObject not overloaded");
223 }
224}
#define RCU_ASSERT(x)
Definition Assert.h:210
#define RCU_ASSERT2_SOFT(x, y)
Definition Assert.h:157
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
#define RCU_ASSERT0_NOIMP(y)
Definition Assert.h:182
#define RCU_PROVIDE(x)
Definition Assert.h:203
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:141
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217
size_t size() const
Number of registered mappings.
ClassImp(EL::WhiteBoardSvc) namespace EL
A class implementing a templatized version of the meta-data.
Definition MetaData.h:19
This class defines a templatized version of the meta-data in vector form.
Definition MetaVector.h:20
This module defines the arguments passed from the BATCH driver to the BATCH worker.
WhiteBoardSvc * getWhiteBoardSvc(IWorker *worker)
effects: get the whiteboard service for this worker guarantee: strong failures: formula service not c...
-diff