Skip to content

Commit fe0e85a

Browse files
authored
DPL GUI: simplify and speed up (#14700)
* Avoid cumbersome retrivial of the lifetime * No need to create a string just to format it.
1 parent 360d8fe commit fe0e85a

File tree

5 files changed

+50
-40
lines changed

5 files changed

+50
-40
lines changed

Framework/GUISupport/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ o2_add_library(FrameworkGUISupport
2020
src/PaletteHelpers.cxx
2121
src/SpyService.cxx
2222
src/SpyServiceHelpers.cxx
23+
src/InspectorHelpers.cxx
2324
PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src
2425
PUBLIC_LINK_LIBRARIES O2::Framework AliceO2::DebugGUI)
2526

Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void displayDataRelayer(DeviceMetricsInfo const& /*metrics*/,
233233
continue;
234234
}
235235
if (i == (size_t)row) {
236-
ImGui::Text("%d %.*s (%s)", row, int(end - input), input, InspectorHelpers::getLifeTimeStr(spec.inputs[i].matcher.lifetime).c_str());
236+
ImGui::Text("%d %.*s (%s)", row, int(end - input), input, InspectorHelpers::getLifeTimeStr(spec.inputs[i].matcher.lifetime));
237237
break;
238238
}
239239
++i;

Framework/GUISupport/src/FrameworkGUIDeviceInspector.cxx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ void deviceStateTable(DataProcessingStates const& states)
7979
}
8080
}
8181

82-
void deviceInfoTable(char const* label, ProcessingStateId id, DataProcessingStates const& states, std::variant<std::vector<InputRoute>, std::vector<OutputRoute>> routes, DeviceMetricsInfo const& metrics)
82+
template <typename Routes>
83+
void deviceInfoTable(char const* label, ProcessingStateId id, DataProcessingStates const& states, Routes const& routes, DeviceMetricsInfo const& metrics)
8384
{
8485
// Find the state spec associated to data_queries
8586
auto& view = states.statesViews[(int)id];
@@ -95,17 +96,10 @@ void deviceInfoTable(char const* label, ProcessingStateId id, DataProcessingStat
9596
if ((end - input) == 0) {
9697
continue;
9798
}
98-
auto getLifetime = [&routes, &i]() -> Lifetime {
99-
if (std::get_if<std::vector<InputRoute>>(&routes)) {
100-
return std::get<std::vector<InputRoute>>(routes)[i].matcher.lifetime;
101-
} else {
102-
return std::get<std::vector<OutputRoute>>(routes)[i].matcher.lifetime;
103-
}
104-
};
105-
ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(getLifetime()).c_str());
99+
ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(routes[i].matcher.lifetime));
106100
if (ImGui::IsItemHovered()) {
107101
ImGui::BeginTooltip();
108-
ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(getLifetime()).c_str());
102+
ImGui::Text("%zu: %.*s (%s)", i, int(end - input), input, InspectorHelpers::getLifeTimeStr(routes[i].matcher.lifetime));
109103
ImGui::EndTooltip();
110104
}
111105
input = end + 1;
@@ -346,8 +340,8 @@ void displayDeviceInspector(DeviceSpec const& spec,
346340
}
347341

348342
deviceStateTable(states);
349-
deviceInfoTable("Inputs:", ProcessingStateId::DATA_QUERIES, states, std::variant<std::vector<InputRoute>, std::vector<OutputRoute>>(spec.inputs), metrics);
350-
deviceInfoTable("Outputs:", ProcessingStateId::OUTPUT_MATCHERS, states, std::variant<std::vector<InputRoute>, std::vector<OutputRoute>>(spec.outputs), metrics);
343+
deviceInfoTable("Inputs:", ProcessingStateId::DATA_QUERIES, states, spec.inputs, metrics);
344+
deviceInfoTable("Outputs:", ProcessingStateId::OUTPUT_MATCHERS, states, spec.outputs, metrics);
351345
configurationTable(info.currentConfig, info.currentProvenance);
352346
optionsTable("Workflow Options", metadata.workflowOptions, control);
353347
if (ImGui::CollapsingHeader("Labels", ImGuiTreeNodeFlags_DefaultOpen)) {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2019-2025 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 "InspectorHelpers.h"
13+
14+
namespace o2::framework
15+
{
16+
char const* InspectorHelpers::getLifeTimeStr(Lifetime lifetime)
17+
{
18+
switch (lifetime) {
19+
case Lifetime::Timeframe:
20+
return "Timeframe";
21+
case Lifetime::Condition:
22+
return "Condition";
23+
case Lifetime::Sporadic:
24+
return "Sporadic";
25+
case Lifetime::Transient:
26+
return "Transient";
27+
case Lifetime::Timer:
28+
return "Timer";
29+
case Lifetime::Enumeration:
30+
return "Enumeration";
31+
case Lifetime::Signal:
32+
return "Signal";
33+
case Lifetime::Optional:
34+
return "Optional";
35+
case Lifetime::OutOfBand:
36+
return "OutOfBand";
37+
}
38+
return "none";
39+
};
40+
} // namespace o2::framework

Framework/GUISupport/src/InspectorHelpers.h

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
22
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33
// All rights not expressly granted are reserved.
44
//
@@ -11,39 +11,14 @@
1111
#ifndef O2_FRAMEWORK_INSPECTORHELPERS_H_
1212
#define O2_FRAMEWORK_INSPECTORHELPERS_H_
1313

14-
#include <string>
15-
1614
#include "Framework/Lifetime.h"
1715

1816
namespace o2::framework
1917
{
2018

2119
/// A helper class for inpsection of device information
2220
struct InspectorHelpers {
23-
static const std::string getLifeTimeStr(Lifetime lifetime)
24-
{
25-
switch (lifetime) {
26-
case Lifetime::Timeframe:
27-
return "Timeframe";
28-
case Lifetime::Condition:
29-
return "Condition";
30-
case Lifetime::Sporadic:
31-
return "Sporadic";
32-
case Lifetime::Transient:
33-
return "Transient";
34-
case Lifetime::Timer:
35-
return "Timer";
36-
case Lifetime::Enumeration:
37-
return "Enumeration";
38-
case Lifetime::Signal:
39-
return "Signal";
40-
case Lifetime::Optional:
41-
return "Optional";
42-
case Lifetime::OutOfBand:
43-
return "OutOfBand";
44-
}
45-
return "none";
46-
};
21+
static const char* getLifeTimeStr(Lifetime lifetime);
4722
};
4823

4924
} // namespace o2::framework

0 commit comments

Comments
 (0)