SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
PipelineStage.h
Go to the documentation of this file.
1
17
18#ifndef _SEFRAMEWORK_PIPELINE_PIPELINESTAGE_H
19#define _SEFRAMEWORK_PIPELINE_PIPELINESTAGE_H
20
22#include "SEUtils/Observable.h"
23
24namespace SourceXtractor {
25
27
34
35 const std::shared_ptr<SelectionCriteria> m_selection_criteria; // Used to identify the Sources to process
36
38 : m_selection_criteria(std::move(selection_criteria)) {}
39};
40
45template <typename T>
47public:
48 virtual ~PipelineReceiver() = default;
49
54 virtual void receiveSource(std::unique_ptr<T> source) = 0;
55
60 virtual void receiveProcessSignal(const ProcessSourcesEvent& event) = 0;
61};
62
67template <typename T>
68class PipelineEmitter : public Observable<T> {
69public:
70 ~PipelineEmitter() override = default;
71
78 if (m_next_stage) {
79 throw Elements::Exception() << "Next stage already set";
80 }
82 }
83
84protected:
85 void sendSource(std::unique_ptr<T> source) const {
87 if (m_next_stage) {
88 m_next_stage->receiveSource(std::move(source));
89 }
90 }
91
92 void sendProcessSignal(const ProcessSourcesEvent& event) const {
93 if (m_next_stage) {
94 m_next_stage->receiveProcessSignal(event);
95 }
96 }
97
98private:
100};
101
102} // namespace SourceXtractor
103
104#endif // _SEFRAMEWORK_PIPELINE_PIPELINESTAGE_H
Implements the Observer pattern. Notifications will be made using a message of type T.
Definition Observable.h:51
void notifyObservers(const T &message) const
Definition Observable.h:71
std::shared_ptr< PipelineReceiver< T > > m_next_stage
void sendProcessSignal(const ProcessSourcesEvent &event) const
void sendSource(std::unique_ptr< T > source) const
~PipelineEmitter() override=default
void setNextStage(std::shared_ptr< PipelineReceiver< T > > next)
virtual void receiveProcessSignal(const ProcessSourcesEvent &event)=0
virtual ~PipelineReceiver()=default
virtual void receiveSource(std::unique_ptr< T > source)=0
Used to determine if a Source is selected for processing.
T move(T... args)
STL namespace.
T next(T... args)
Event received by SourceGrouping to request the processing of some of the Sources stored.
ProcessSourcesEvent(std::shared_ptr< SelectionCriteria > selection_criteria)
const std::shared_ptr< SelectionCriteria > m_selection_criteria