gdata
Loading...
Searching...
No Matches
gRunHeader.h
Go to the documentation of this file.
1#pragma once
2
3// gemc
4#include "gbase.h"
5
6// C++
7#include <string>
8
22constexpr const char* GDATARUNHEADER_LOGGER = "run_header";
23
24namespace grun_header {
25
35inline auto defineOptions() -> GOptions {
37 return goptions;
38}
39
40} // namespace grun_header
41
68class GRunHeader : public GBase<GRunHeader>
69{
70public:
82 GRunHeader(const std::shared_ptr<GOptions>& gopts, int rid, int tid = -1)
83 : GBase(gopts, GDATARUNHEADER_LOGGER), runID(rid) {
84 log->debug(CONSTRUCTOR, "GRunHeader");
85 if (tid != -1) {
86 log->info(1, "\n",
87 TPOINTITEM, " Run ID: ", rid, "\n",
88 TPOINTITEM, " Number of events processed: ", events_processed, "\n",
89 TPOINTITEM, " Number of events with payload: ", events_with_payload, "\n",
90 TPOINTITEM, " Thread ID: ", tid);
91 }
92 else {
93 log->info(1, "\n",
94 TPOINTITEM, " Run ID: ", rid, "\n",
95 TPOINTITEM, " Number of events processed: ", events_processed, "\n",
96 TPOINTITEM, " Number of events with payload: ", events_with_payload);
97 }
98 }
99
105 [[nodiscard]] auto getRunID() const -> int { return runID; }
106
112 [[nodiscard]] auto get_events_processed() const -> int { return events_processed; }
113
119 [[nodiscard]] auto get_events_with_payload() const -> int { return events_with_payload; }
120
127 void increment_events_processed() { events_processed++; }
128
136 void increment_events_with_payload() { events_with_payload++; }
137
143 void add_events_processed(int count) { events_processed += count; }
144
150 void add_events_with_payload(int count) { events_with_payload += count; }
151
152private:
154 int events_processed{0};
155
157 int events_with_payload{0};
158
160 int runID;
161};
std::shared_ptr< GLogger > log
void debug(debug_type type, Args &&... args) const
void info(int level, Args &&... args) const
Stores minimal run metadata and run-level event counters.
Definition gRunHeader.h:69
void add_events_processed(int count)
Adds an arbitrary number of processed events to the counter.
Definition gRunHeader.h:143
GRunHeader(const std::shared_ptr< GOptions > &gopts, int rid, int tid=-1)
Constructs a run header.
Definition gRunHeader.h:82
void increment_events_processed()
Increments the processed-event counter by one.
Definition gRunHeader.h:127
void add_events_with_payload(int count)
Adds an arbitrary number of payload-producing events to the counter.
Definition gRunHeader.h:150
auto get_events_processed() const -> int
Returns the total number of processed events tracked by this header.
Definition gRunHeader.h:112
auto getRunID() const -> int
Returns the run identifier.
Definition gRunHeader.h:105
auto get_events_with_payload() const -> int
Returns the number of processed events that contributed payload.
Definition gRunHeader.h:119
void increment_events_with_payload()
Increments the payload-producing-event counter by one.
Definition gRunHeader.h:136
constexpr const char * GDATARUNHEADER_LOGGER
Definition gRunHeader.h:22
CONSTRUCTOR
#define TPOINTITEM
auto defineOptions() -> GOptions
Defines the options subtree used by the run-header logger domain.
Definition gRunHeader.h:35