SourceXtractorPlusPlus  0.15
Please provide a description of the project.
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 <memory>
27 #include <list>
28 
29 #include "SEUtils/Observable.h"
30 
34 
35 namespace SourceXtractor {
36 
43 public:
47  virtual ~SelectionCriteria() = default;
48 
50  virtual bool mustBeProcessed(const SourceInterface& source) const = 0;
51 };
52 
59 public:
60  virtual bool mustBeProcessed(const SourceInterface& ) const override {
61  return true;
62  }
63 };
64 
65 
72 
73  const std::shared_ptr<SelectionCriteria> m_selection_criteria; // Used to identify the Sources to process
74 
76  : m_selection_criteria(selection_criteria) {}
77 };
78 
85 public:
89  virtual ~GroupingCriteria() = default;
90 
92  virtual bool shouldGroup(const SourceInterface& first, const SourceInterface& second) const = 0;
93 
95  virtual std::set<PropertyId> requiredProperties() const { return {}; }
96 };
97 
105 class SourceGrouping : public Observer<std::shared_ptr<SourceInterface>>,
106  public Observer<ProcessSourcesEvent>, public Observable<std::shared_ptr<SourceGroupInterface>> {
107 public:
108 
112  virtual ~SourceGrouping() = default;
113 
116 
118  virtual void handleMessage(const std::shared_ptr<SourceInterface>& source) override;
119 
121  virtual void handleMessage(const ProcessSourcesEvent& source) override;
122 
125 
126 private:
127 
131 
132 }; /* End of SourceGrouping class */
133 
134 
135 } /* namespace SourceXtractor */
136 
137 
138 #endif
SourceXtractor::Observer
Observer interface to be used with Observable to implement the Observer pattern.
Definition: Observable.h:38
SourceXtractor::SourceGrouping::SourceGrouping
SourceGrouping(std::shared_ptr< GroupingCriteria > grouping_criteria, std::shared_ptr< SourceGroupFactory > group_factory)
Definition: SourceGrouping.cpp:28
std::shared_ptr
STL class.
SourceXtractor::SelectAllCriteria::mustBeProcessed
virtual bool mustBeProcessed(const SourceInterface &) const override
Determines if the given Source must be processed or not.
Definition: SourceGrouping.h:60
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition: SourceGrouping.h:71
std::list
STL class.
SourceGroupInterface.h
SourceInterface.h
SourceXtractor::GroupingCriteria::~GroupingCriteria
virtual ~GroupingCriteria()=default
Destructor.
SourceXtractor::SourceGrouping::m_group_factory
std::shared_ptr< SourceGroupFactory > m_group_factory
Definition: SourceGrouping.h:129
SourceXtractor::SelectAllCriteria
An implementation of SelectionCriteria that just marks all Sources as selected.
Definition: SourceGrouping.h:58
SourceXtractor::SourceGrouping::handleMessage
virtual void handleMessage(const std::shared_ptr< SourceInterface > &source) override
Handles a new Source.
Definition: SourceGrouping.cpp:33
SourceXtractor::GroupingCriteria
Criteria used by SourceGrouping to determine if two sources should be grouped together.
Definition: SourceGrouping.h:84
SourceXtractor::SourceGrouping
SourceGrouping takes Source, groups them together according to its GroupingCriteria and stores them....
Definition: SourceGrouping.h:106
SourceXtractor::SourceGrouping::~SourceGrouping
virtual ~SourceGrouping()=default
Destructor.
SourceXtractor::GroupingCriteria::shouldGroup
virtual bool shouldGroup(const SourceInterface &first, const SourceInterface &second) const =0
Determines if the two sources should be grouped together.
SourceXtractor::SelectionCriteria::~SelectionCriteria
virtual ~SelectionCriteria()=default
Destructor.
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::SourceGrouping::m_source_groups
std::list< std::shared_ptr< SourceGroupInterface > > m_source_groups
Definition: SourceGrouping.h:130
SourceXtractor::ProcessSourcesEvent::ProcessSourcesEvent
ProcessSourcesEvent(const std::shared_ptr< SelectionCriteria > &selection_criteria)
Definition: SourceGrouping.h:75
SourceXtractor::ProcessSourcesEvent::m_selection_criteria
const std::shared_ptr< SelectionCriteria > m_selection_criteria
Definition: SourceGrouping.h:73
SourceXtractor::GroupingCriteria::requiredProperties
virtual std::set< PropertyId > requiredProperties() const
Return a set of used properties so they can be pre-fetched.
Definition: SourceGrouping.h:95
SourceGroupFactory.h
Observable.h
SourceXtractor::Observable
Implements the Observer pattern. Notifications will be made using a message of type T.
Definition: Observable.h:51
SourceXtractor::SourceGrouping::m_grouping_criteria
std::shared_ptr< GroupingCriteria > m_grouping_criteria
Definition: SourceGrouping.h:128
SourceXtractor::SelectionCriteria::mustBeProcessed
virtual bool mustBeProcessed(const SourceInterface &source) const =0
Determines if the given Source must be processed or not.
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
SourceXtractor::SourceGrouping::requiredProperties
std::set< PropertyId > requiredProperties() const
Returns the set of required properties to compute the grouping.
Definition: SourceGrouping.cpp:94
std::set
STL class.
SourceXtractor::SelectionCriteria
Used to determine if a Source is selected for processing.
Definition: SourceGrouping.h:42