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
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>
23#include <EventLoop/IWorker.h>
26
27//
28// method implementations
29//
30
32
33namespace 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
54 WhiteBoardSvc ::
55 WhiteBoardSvc ()
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 {
127 doSetArray (name, size, values);
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);
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);
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}
#define RCU_INVARIANT(x)
Definition Assert.h:201
#define RCU_ASSERT(x)
Definition Assert.h:222
#define RCU_ASSERT2_SOFT(x, y)
Definition Assert.h:169
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_ASSERT0_NOIMP(y)
Definition Assert.h:194
#define RCU_PROVIDE(x)
Definition Assert.h:215
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:153
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
ClassImp(EL::WhiteBoardSvc) namespace EL
A class implementing a templatized version of the meta-data.
Definition MetaData.h:27
This class defines a templatized version of the meta-data in vector form.
Definition MetaVector.h:28
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