Project
Loading...
Searching...
No Matches
DeliveryType.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12/*
13 * File: DeliveryType.h
14 * Author: John Lång (john.larry.lang@cern.ch)
15 *
16 * Created on 17 July 2015, 9:54
17 */
18
19#ifndef O2_DCS_DELIVERY_TYPE
20#define O2_DCS_DELIVERY_TYPE
21
22#include <string>
23#include <bitset>
24#include <stdexcept>
26
27namespace o2::dcs
28{
52 VOID = 0,
53
59
65
71 RAW_INT = 21,
72
77 DPVAL_INT = 149,
78
85
91
99
105
113
121
128
133
140
145
153
159
167
173 DPVAL_TIME = 132
175
176template <>
177inline DeliveryType read(const std::string& str)
178{
179 if (str == "Raw/Int") {
180 return RAW_INT;
181 } else if (str == "Raw/Uint") {
182 return RAW_UINT;
183 } else if (str == "Raw/Float") {
184 return RAW_FLOAT;
185 } else if (str == "Raw/Double") {
186 return RAW_DOUBLE;
187 } else if (str == "Raw/Bool") {
188 return RAW_BOOL;
189 } else if (str == "Raw/Char") {
190 return RAW_CHAR;
191 } else if (str == "Raw/String") {
192 return RAW_STRING;
193 } else if (str == "Raw/Binary") {
194 return RAW_BINARY;
195 } else if (str == "Raw/Time") {
196 return RAW_TIME;
197 } else if (str == "DPVAL/Int") {
198 return DPVAL_INT;
199 } else if (str == "DPVAL/Uint") {
200 return DPVAL_UINT;
201 } else if (str == "DPVAL/Float") {
202 return DPVAL_FLOAT;
203 } else if (str == "DPVAL/Double") {
204 return DPVAL_DOUBLE;
205 } else if (str == "DPVAL/Bool") {
206 return DPVAL_BOOL;
207 } else if (str == "DPVAL/Char") {
208 return DPVAL_CHAR;
209 } else if (str == "DPVAL/String") {
210 return DPVAL_STRING;
211 } else if (str == "DPVAL/Binary") {
212 return DPVAL_BINARY;
213 } else if (str == "DPVAL/Time") {
214 return DPVAL_TIME;
215 } else if (str == "Void") {
216 return VOID;
217 } else {
218 throw std::domain_error("\"" + str +
219 "\" doesn't represent a DeliveryType.");
220 }
221}
222
223template <>
224inline std::string show(const DeliveryType type)
225{
226 switch (type) {
227 case RAW_INT:
228 return "Raw/Int";
229 case RAW_UINT:
230 return "Raw/Uint";
231 case RAW_BOOL:
232 return "Raw/Bool";
233 case RAW_CHAR:
234 return "Raw/Char";
235 case RAW_FLOAT:
236 return "Raw/Float";
237 case RAW_DOUBLE:
238 return "Raw/Double";
239 case RAW_TIME:
240 return "Raw/Time";
241 case RAW_STRING:
242 return "Raw/String";
243 case RAW_BINARY:
244 return "Raw/Binary";
245 case DPVAL_INT:
246 return "DPVAL/Int";
247 case DPVAL_UINT:
248 return "DPVAL/Uint";
249 case DPVAL_BOOL:
250 return "DPVAL/Bool";
251 case DPVAL_CHAR:
252 return "DPVAL/Char";
253 case DPVAL_FLOAT:
254 return "DPVAL/Float";
255 case DPVAL_DOUBLE:
256 return "DPVAL/Double";
257 case DPVAL_TIME:
258 return "DPVAL/Time";
259 case DPVAL_STRING:
260 return "DPVAL/String";
261 case DPVAL_BINARY:
262 return "DPVAL/Binary";
263 case VOID:
264 return "Void";
265 default:
266 throw std::domain_error("Illegal DeliveryType.");
267 }
268}
269
279{
280 switch (type) {
281 case DPVAL_INT:
282 case DPVAL_UINT:
283 case DPVAL_BOOL:
284 case DPVAL_CHAR:
285 case DPVAL_FLOAT:
286 case DPVAL_DOUBLE:
287 case DPVAL_TIME:
288 case DPVAL_STRING:
289 case DPVAL_BINARY:
290 return true;
291 case RAW_INT:
292 case RAW_UINT:
293 case RAW_BOOL:
294 case RAW_CHAR:
295 case RAW_FLOAT:
296 case RAW_DOUBLE:
297 case RAW_TIME:
298 case RAW_STRING:
299 case RAW_BINARY:
300 case VOID:
301 return false;
302 default:
303 throw std::domain_error("Illegal DeliveryType.");
304 }
305}
306
315inline std::string dim_description(const DeliveryType type)
316{
317
318 switch (type) {
319 case RAW_INT:
320 return "I:1";
321 case RAW_UINT:
322 return "I:1";
323 case RAW_BOOL:
324 return "I:1";
325 case RAW_CHAR:
326 return "C:4";
327 case RAW_FLOAT:
328 return "F:1";
329 case RAW_DOUBLE:
330 return "D:1";
331 case RAW_TIME:
332 return "I:2";
333 case RAW_STRING:
334 return "C:55";
335 case RAW_BINARY:
336 return "C:56";
337 case DPVAL_INT:
338 return "S:2;I:1;I:1";
339 case DPVAL_UINT:
340 return "S:2;I:1;I:1";
341 case DPVAL_BOOL:
342 return "S:2;I:1;I:1";
343 case DPVAL_CHAR:
344 return "S:2;I:1;C:4";
345 case DPVAL_FLOAT:
346 return "S:2;I:1;F:1";
347 case DPVAL_DOUBLE:
348 return "S:2;I:1;D:1";
349 case DPVAL_TIME:
350 return "S:2;I:1;I:2";
351 case DPVAL_STRING:
352 return "S:2;I:1;C:55";
353 case DPVAL_BINARY:
354 return "S:2;I:1;C:56";
355 case VOID:
356 default:
357 throw std::domain_error("Illegal DeliveryType.");
358 }
359}
360
370{
371 switch (type) {
372 case RAW_INT:
373 case RAW_UINT:
374 case RAW_BOOL:
375 case RAW_CHAR:
376 case RAW_FLOAT:
377 return 4;
378 case RAW_DOUBLE:
379 case RAW_TIME:
380 return 8;
381 case RAW_STRING:
382 return 55;
383 case RAW_BINARY:
384 return 56;
385 case DPVAL_INT:
386 case DPVAL_UINT:
387 case DPVAL_BOOL:
388 case DPVAL_CHAR:
389 case DPVAL_FLOAT:
390 case DPVAL_DOUBLE:
391 case DPVAL_TIME:
392 case DPVAL_STRING:
393 case DPVAL_BINARY:
394 return 64;
395 case VOID:
396 return 0;
397 default:
398 throw std::domain_error("Illegal DeliveryType.");
399 }
400}
401} // namespace o2::dcs
402
403
404
405#endif /* O2_DCS_DELIVERY_TYPE */
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
std::string show(const DeliveryType type)
bool DPVAL_variant(const DeliveryType type)
size_t dim_buffer_size(const DeliveryType type)
DeliveryType read(const std::string &str)
std::string dim_description(const DeliveryType type)
const std::string str