Skip to content
Snippets Groups Projects
Commit 36db0433 authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

algo: Forward declare cbm::Monitor in ChainContext.

This is a workaround for a bug in older cling versions.
parent 977836b5
No related branches found
No related tags found
1 merge request!1180algo: Add monitoring support in cbmreco.
Pipeline #22583 passed
......@@ -11,6 +11,7 @@ set(DEVICE_SRCS
set(SRCS
${DEVICE_SRCS}
base/ChainContext.cxx
base/Options.cxx
base/util/TimingsFormat.cxx
data/sts/LandauTable.cxx
......
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#include "ChainContext.h"
#include <Monitor.hpp>
using namespace cbm::algo;
ChainContext::ChainContext() {}
ChainContext::~ChainContext() {}
......@@ -4,18 +4,30 @@
#ifndef CBM_ALGO_BASE_CHAINCONTEXT_H
#define CBM_ALGO_BASE_CHAINCONTEXT_H
#include <Monitor.hpp>
#include <memory>
#include <optional>
#include "Options.h"
#include "RecoParams.h"
namespace cbm
{
// cbm::Monitor must be forward declared. This prevents an issue in older ROOT versions,
// where cling would crash upon parsing the header file (in some stl header)
class Monitor;
} // namespace cbm
namespace cbm::algo
{
struct ChainContext {
// default constructor / destructor
// But have to be defined in the .cxx file, because of forward declaration of cbm::Monitor
ChainContext();
~ChainContext();
Options opts;
RecoParams recoParams;
std::optional<cbm::Monitor> monitor; //!
std::unique_ptr<cbm::Monitor> monitor; //! Monitor
};
} // namespace cbm::algo
......
......@@ -18,12 +18,12 @@ namespace cbm::algo
const Options& Opts() const { return gsl::make_not_null(fContext)->opts; }
const RecoParams& Params() const { return gsl::make_not_null(fContext)->recoParams; }
bool HasMonitor() const { return gsl::make_not_null(fContext)->monitor.has_value(); }
bool HasMonitor() const { return gsl::make_not_null(fContext)->monitor != nullptr; }
Monitor& GetMonitor() const
{
// Need Get-prefix to avoid conflict with Monitor-class name
return gsl::make_not_null(fContext)->monitor.value();
return *gsl::make_not_null(fContext)->monitor;
}
private:
......
......@@ -3,6 +3,7 @@
Authors: Felix Weiglhofer [committer] */
#include "Reco.h"
#include <Monitor.hpp>
#include <System.hpp>
#include <xpu/host.h>
......@@ -30,7 +31,7 @@ void Reco::Init(const Options& opts)
L_(info) << "Running CBM Reco on Device " << props.name();
if (!opts.MonitorUri().empty()) {
fContext.monitor.emplace(opts.MonitorUri());
fContext.monitor = std::make_unique<cbm::Monitor>(opts.MonitorUri());
L_(info) << "Monitoring enabled, sending to " << opts.MonitorUri();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment