Project
Loading...
Searching...
No Matches
Metric2DViewIndex.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
13
15
16#include "Framework/Logger.h"
17
18#include <algorithm>
19#include <functional>
20
21namespace o2::framework
22{
23
25{
26 return [](std::array<Metric2DViewIndex*, 2> const& views, std::string const& name, MetricInfo const& metric, int value, int metricsIndex) -> void {
27 for (auto viewPtr : views) {
28 auto& view = *viewPtr;
29 if (view.prefix.size() > name.size()) {
30 continue;
31 }
32 if (std::mismatch(view.prefix.begin(), view.prefix.end(), name.begin()).first != view.prefix.end()) {
33 continue;
34 }
35
36 auto extra = name;
37
38 // +1 is to remove the /
39 extra.erase(0, view.prefix.size() + 1);
40 if (extra == "w") {
41 view.w = value;
42 view.indexes.resize(view.w * view.h, -1);
43 return;
44 } else if (extra == "h") {
45 view.h = value;
46 view.indexes.resize(view.w * view.h, -1);
47 return;
48 }
49 int idx = -1;
50 try {
51 idx = std::stoi(extra, nullptr, 10);
52 } catch (...) {
53 LOG(error) << "Badly formatted metric";
54 }
55 if (idx < 0) {
56 LOG(error) << "Negative metric";
57 return;
58 }
59 if (view.indexes.size() <= idx) {
60 view.indexes.resize(std::max(idx + 1, view.w * view.h), -1);
61 }
62 view.indexes[idx] = metricsIndex;
63 }
64 };
65}
66
67} // namespace o2
GLuint const GLchar * name
Definition glcorearb.h:781
GLsizei const GLfloat * value
Definition glcorearb.h:819
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
static Updater getUpdater()
Get the right updated function given a list of Metric views.
std::function< void(std::array< Metric2DViewIndex *, 2 > &views, std::string const &, MetricInfo const &, int value, size_t metricIndex)> Updater
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"