Project
Loading...
Searching...
No Matches
DeviceStateHelpers.cxx
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
#include "
DeviceStateHelpers.h
"
13
#include "
Framework/DeviceState.h
"
14
#include <string_view>
15
#include <cstring>
16
17
namespace
o2::framework
18
{
19
20
DeviceState::LoopReason
loopReasonFromString
(std::string_view reason)
21
{
22
if
(reason ==
"NO_REASON"
) {
23
return
DeviceState::LoopReason::NO_REASON
;
24
}
else
if
(reason ==
"METRICS_MUST_FLUSH"
) {
25
return
DeviceState::LoopReason::METRICS_MUST_FLUSH
;
26
}
else
if
(reason ==
"SIGNAL_ARRIVED"
) {
27
return
DeviceState::LoopReason::SIGNAL_ARRIVED
;
28
}
else
if
(reason ==
"DATA_SOCKET_POLLED"
) {
29
return
DeviceState::LoopReason::DATA_SOCKET_POLLED
;
30
}
else
if
(reason ==
"DATA_INCOMING"
) {
31
return
DeviceState::LoopReason::DATA_INCOMING
;
32
}
else
if
(reason ==
"DATA_OUTGOING"
) {
33
return
DeviceState::LoopReason::DATA_OUTGOING
;
34
}
else
if
(reason ==
"WS_COMMUNICATION"
) {
35
return
DeviceState::LoopReason::WS_COMMUNICATION
;
36
}
else
if
(reason ==
"TIMER_EXPIRED"
) {
37
return
DeviceState::LoopReason::TIMER_EXPIRED
;
38
}
else
if
(reason ==
"WS_CONNECTED"
) {
39
return
DeviceState::LoopReason::WS_CONNECTED
;
40
}
else
if
(reason ==
"WS_CLOSING"
) {
41
return
DeviceState::LoopReason::WS_CLOSING
;
42
}
else
if
(reason ==
"WS_READING"
) {
43
return
DeviceState::LoopReason::WS_READING
;
44
}
else
if
(reason ==
"WS_WRITING"
) {
45
return
DeviceState::LoopReason::WS_WRITING
;
46
}
else
if
(reason ==
"ASYNC_NOTIFICATION"
) {
47
return
DeviceState::LoopReason::ASYNC_NOTIFICATION
;
48
}
else
if
(reason ==
"OOB_ACTIVITY"
) {
49
return
DeviceState::LoopReason::OOB_ACTIVITY
;
50
}
else
if
(reason ==
"UNKNOWN"
) {
51
return
DeviceState::LoopReason::UNKNOWN
;
52
}
else
if
(reason ==
"FIRST_LOOP"
) {
53
return
DeviceState::LoopReason::FIRST_LOOP
;
54
}
else
if
(reason ==
"NEW_STATE_PENDING"
) {
55
return
DeviceState::LoopReason::NEW_STATE_PENDING
;
56
}
else
if
(reason ==
"PREVIOUSLY_ACTIVE"
) {
57
return
DeviceState::LoopReason::PREVIOUSLY_ACTIVE
;
58
}
else
if
(reason ==
"TRACE_CALLBACKS"
) {
59
return
DeviceState::LoopReason::TRACE_CALLBACKS
;
60
}
else
if
(reason ==
"TRACE_USERCODE"
) {
61
return
DeviceState::LoopReason::TRACE_USERCODE
;
62
}
else
{
63
return
DeviceState::LoopReason::UNKNOWN
;
64
}
65
}
66
67
int
DeviceStateHelpers::parseTracingFlags
(std::string
const
& s)
68
{
69
// split string by pipe and convert to int based
70
// on the LoopReason enum
71
std::vector<std::string_view> tokens;
72
char
const
*
first
= s.c_str();
73
char
const
* last = s.c_str();
74
75
while
(
true
) {
76
char
const
* next = std::strchr(last,
'|'
);
77
if
(next) {
78
tokens.emplace_back(
first
, next -
first
);
79
first
= next + 1;
80
last =
first
;
81
}
else
{
82
tokens.emplace_back(
first
, s.size() - (
first
- s.c_str()));
83
break
;
84
}
85
}
86
int
ret = 0;
87
for
(
auto
const
& token : tokens) {
88
ret |=
static_cast<
int
>
(
loopReasonFromString
(token));
89
}
90
return
ret;
91
}
92
}
// namespace o2::framework
DeviceStateHelpers.h
DeviceState.h
int
first
GLint first
Definition
glcorearb.h:399
o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition
TFIDInfo.h:20
o2::framework::loopReasonFromString
DeviceState::LoopReason loopReasonFromString(std::string_view reason)
Definition
DeviceStateHelpers.cxx:20
o2::framework::DeviceStateHelpers::parseTracingFlags
static int parseTracingFlags(std::string const &events)
Definition
DeviceStateHelpers.cxx:67
o2::framework::DeviceState::LoopReason
LoopReason
Motivation for the loop being triggered.
Definition
DeviceState.h:36
o2::framework::DeviceState::TRACE_CALLBACKS
@ TRACE_CALLBACKS
Definition
DeviceState.h:55
o2::framework::DeviceState::UNKNOWN
@ UNKNOWN
Definition
DeviceState.h:51
o2::framework::DeviceState::SIGNAL_ARRIVED
@ SIGNAL_ARRIVED
Definition
DeviceState.h:39
o2::framework::DeviceState::FIRST_LOOP
@ FIRST_LOOP
Definition
DeviceState.h:52
o2::framework::DeviceState::WS_WRITING
@ WS_WRITING
Definition
DeviceState.h:48
o2::framework::DeviceState::DATA_INCOMING
@ DATA_INCOMING
Definition
DeviceState.h:41
o2::framework::DeviceState::ASYNC_NOTIFICATION
@ ASYNC_NOTIFICATION
Definition
DeviceState.h:49
o2::framework::DeviceState::PREVIOUSLY_ACTIVE
@ PREVIOUSLY_ACTIVE
Definition
DeviceState.h:54
o2::framework::DeviceState::WS_CLOSING
@ WS_CLOSING
Definition
DeviceState.h:46
o2::framework::DeviceState::DATA_OUTGOING
@ DATA_OUTGOING
Definition
DeviceState.h:42
o2::framework::DeviceState::NO_REASON
@ NO_REASON
Definition
DeviceState.h:37
o2::framework::DeviceState::TRACE_USERCODE
@ TRACE_USERCODE
Definition
DeviceState.h:56
o2::framework::DeviceState::NEW_STATE_PENDING
@ NEW_STATE_PENDING
Definition
DeviceState.h:53
o2::framework::DeviceState::DATA_SOCKET_POLLED
@ DATA_SOCKET_POLLED
Definition
DeviceState.h:40
o2::framework::DeviceState::METRICS_MUST_FLUSH
@ METRICS_MUST_FLUSH
Definition
DeviceState.h:38
o2::framework::DeviceState::WS_COMMUNICATION
@ WS_COMMUNICATION
Definition
DeviceState.h:43
o2::framework::DeviceState::WS_CONNECTED
@ WS_CONNECTED
Definition
DeviceState.h:45
o2::framework::DeviceState::OOB_ACTIVITY
@ OOB_ACTIVITY
Definition
DeviceState.h:50
o2::framework::DeviceState::WS_READING
@ WS_READING
Definition
DeviceState.h:47
o2::framework::DeviceState::TIMER_EXPIRED
@ TIMER_EXPIRED
Definition
DeviceState.h:44
Framework
Core
src
DeviceStateHelpers.cxx
Generated on Tue Feb 25 2025 17:03:21 for Project by
1.9.8