SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
SourceGrouping.h
Go to the documentation of this file.
1 
23 #ifndef _SEFRAMEWORK_PIPELINE_SOURCEGROUPING_H
24 #define _SEFRAMEWORK_PIPELINE_SOURCEGROUPING_H
25 
26 #include <list>
27 #include <memory>
28 
33 
34 namespace SourceXtractor {
35 
42 public:
46  virtual ~SelectionCriteria() = default;
47 
49  virtual bool mustBeProcessed(const SourceInterface& source) const = 0;
50 };
51 
58 public:
59  bool mustBeProcessed(const SourceInterface& ) const override {
60  return true;
61  }
62 };
63 
70 public:
74  virtual ~GroupingCriteria() = default;
75 
77  virtual bool shouldGroup(const SourceInterface& first, const SourceInterface& second) const = 0;
78 
80  virtual std::set<PropertyId> requiredProperties() const { return {}; }
81 };
82 
90 class SourceGrouping : public PipelineEmitter<SourceGroupInterface>, public PipelineReceiver<SourceInterface> {
91 public:
92 
96  virtual ~SourceGrouping() = default;
97 
100  unsigned int hard_limit);
101 
104 
106  void receiveSource(std::unique_ptr<SourceInterface> source) override;
107 
109  void receiveProcessSignal(const ProcessSourcesEvent& event) override;
110 
111 private:
115  unsigned int m_hard_limit;
116 
117 }; /* End of SourceGrouping class */
118 
119 
120 } /* namespace SourceXtractor */
121 
122 
123 #endif
Criteria used by SourceGrouping to determine if two sources should be grouped together.
virtual ~GroupingCriteria()=default
Destructor.
virtual bool shouldGroup(const SourceInterface &first, const SourceInterface &second) const =0
Determines if the two sources should be grouped together.
virtual std::set< PropertyId > requiredProperties() const
Return a set of used properties so they can be pre-fetched.
An implementation of SelectionCriteria that just marks all Sources as selected.
bool mustBeProcessed(const SourceInterface &) const override
Determines if the given Source must be processed or not.
Used to determine if a Source is selected for processing.
virtual ~SelectionCriteria()=default
Destructor.
virtual bool mustBeProcessed(const SourceInterface &source) const =0
Determines if the given Source must be processed or not.
SourceGrouping takes Source, groups them together according to its GroupingCriteria and stores them....
std::shared_ptr< SourceGroupFactory > m_group_factory
std::list< std::unique_ptr< SourceGroupInterface > > m_source_groups
virtual ~SourceGrouping()=default
Destructor.
void receiveSource(std::unique_ptr< SourceInterface > source) override
Handles a new Source.
std::set< PropertyId > requiredProperties() const
Returns the set of required properties to compute the grouping.
SourceGrouping(std::shared_ptr< GroupingCriteria > grouping_criteria, std::shared_ptr< SourceGroupFactory > group_factory, unsigned int hard_limit)
std::shared_ptr< GroupingCriteria > m_grouping_criteria
void receiveProcessSignal(const ProcessSourcesEvent &event) override
Handles a ProcessSourcesEvent to trigger the processing of some of the Sources stored in SourceGroupi...
The SourceInterface is an abstract "source" that has properties attached to it.
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition: PipelineStage.h:33