DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
AbstractProcessor.hpp
Go to the documentation of this file.
1
9#ifndef TPGLIBS_ABSTRACTPROCESSOR_HPP_
10#define TPGLIBS_ABSTRACTPROCESSOR_HPP_
11
12#include <cstdint>
13#include <nlohmann/json.hpp>
14#include <memory>
17
18namespace tpglibs {
19
24template <class T>
25class AbstractProcessor {
27 std::shared_ptr<AbstractProcessor<T>> m_next_processor;
28
29 public:
31 using signal_type_t = T;
32
33 virtual ~AbstractProcessor() = default;
34
36 virtual void configure(const nlohmann::json& config, const int16_t* plane_numbers) = 0;
37
39 void set_next_processor(std::shared_ptr<AbstractProcessor<T>> next_processor) {
40 m_next_processor = next_processor;
41 }
42
44 virtual T process(const T& signal) {
45 if (m_next_processor) {
46 return m_next_processor->process(signal);
47 }
48 return signal;
49 }
50
53
55 virtual std::vector<std::string> get_metric_items() {
56 return {};
57 }
58
63
65 virtual void attach_to_metric_collector(ProcessorMetricCollector<signal_type_t>& collector, size_t pipeline_id) {
66 collector.attach_processor(*this, pipeline_id);
67 if (m_next_processor == nullptr) return;
68 m_next_processor->attach_to_metric_collector(collector, pipeline_id);
69 }
70};
71
72} // namespace tpglibs
73
74#endif // TPGLIBS_ABSTRACTPROCESSOR_HPP_
T signal_type_t
Signal type to process on. General __m256i.
virtual T process(const T &signal)
Simple signal pass-through.
virtual ~AbstractProcessor()=default
virtual void attach_to_metric_collector(ProcessorMetricCollector< signal_type_t > &collector, size_t pipeline_id)
Register this processor and next processor with the metric collector.
std::shared_ptr< AbstractProcessor< T > > m_next_processor
Points to next processor in the chain.
virtual void save_metric_to_store_buffer()
Save metrics to store buffer; default does nothing.
virtual ProcessorMetricArray< signal_type_t > read_from_metric_store_buffer()
Read metrics from store buffer; default empty.
virtual void configure(const nlohmann::json &config, const int16_t *plane_numbers)=0
Pure virtual function that will configure the processor using plane numbers.
void set_next_processor(std::shared_ptr< AbstractProcessor< T > > next_processor)
Setter for next processor.
virtual std::vector< std::string > get_metric_items()
Returns the string name of metrics recorded (stored and can be read) for this processor.
void attach_processor(AbstractProcessor< signal_t > &processor, size_t pipeline_id)
Dynamic array of processor metrics, templated on signal type.