SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PipelineStage.h
Go to the documentation of this file.
1 
18 #ifndef _SEFRAMEWORK_PIPELINE_PIPELINESTAGE_H
19 #define _SEFRAMEWORK_PIPELINE_PIPELINESTAGE_H
20 
22 #include "SEUtils/Observable.h"
23 
24 namespace SourceXtractor {
25 
26 class SelectionCriteria;
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 
45 template <typename T>
47 public:
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 
67 template <typename T>
68 class PipelineEmitter : public Observable<T> {
69 public:
70  ~PipelineEmitter() override = default;
71 
78  if (m_next_stage) {
79  throw Elements::Exception() << "Next stage already set";
80  }
82  }
83 
84 protected:
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 
98 private:
100 };
101 
102 } // namespace SourceXtractor
103 
104 #endif // _SEFRAMEWORK_PIPELINE_PIPELINESTAGE_H
const std::shared_ptr< SelectionCriteria > m_selection_criteria
Definition: PipelineStage.h:35
void sendProcessSignal(const ProcessSourcesEvent &event) const
Definition: PipelineStage.h:92
void notifyObservers(const T &message) const
Definition: Observable.h:71
~PipelineEmitter() override=default
ProcessSourcesEvent(std::shared_ptr< SelectionCriteria > selection_criteria)
Definition: PipelineStage.h:37
Event received by SourceGrouping to request the processing of some of the Sources stored...
Definition: PipelineStage.h:33
void setNextStage(std::shared_ptr< PipelineReceiver< T >> next)
Definition: PipelineStage.h:77
Implements the Observer pattern. Notifications will be made using a message of type T...
Definition: Observable.h:51
T next(T...args)
virtual void receiveSource(std::unique_ptr< T > source)=0
T move(T...args)
STL class.
virtual void receiveProcessSignal(const ProcessSourcesEvent &event)=0
virtual ~PipelineReceiver()=default
std::shared_ptr< PipelineReceiver< T > > m_next_stage
Definition: PipelineStage.h:99
void sendSource(std::unique_ptr< T > source) const
Definition: PipelineStage.h:85