SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
AssocGrouping.cpp
Go to the documentation of this file.
1
17
20
21namespace SourceXtractor {
22
24 : m_group_factory(group_factory), m_hard_limit(hard_limit)
25{
26}
27
31
34 auto source_id = source->getProperty<AssocMode>().getGroupId();
35
36 if (m_source_groups.find(source_id) == m_source_groups.end()) {
37 auto new_group = m_group_factory->createSourceGroup();
38 m_source_groups[source_id] = std::move(new_group);
39 }
40
41 if (m_hard_limit > 0 && m_source_groups.at(source_id)->size() >= m_hard_limit) {
42 // the stored group has reached the hard limit
43 // send the current group to processing
44 sendSource(std::move(m_source_groups.at(source_id)));
45
46 // and replace it with a new empty one
47 auto new_group = m_group_factory->createSourceGroup();
48 m_source_groups[source_id] = std::move(new_group);
49 }
50
51 m_source_groups.at(source_id)->addSource(std::move(source));
52}
53
56 std::vector<unsigned int> groups_to_process;
57
58 // We iterate through all the SourceGroups we have
59 for (auto const& it : m_source_groups) {
60 // We look at its Sources and if we find at least one that needs to be processed
61 for (auto& source : *it.second) {
62 if (event.m_selection_criteria->mustBeProcessed(source)) {
63 groups_to_process.push_back(it.first);
64 break;
65 }
66 }
67 }
68
69 // For each SourceGroup that we put in groups_to_process,
70 for (auto group_id : groups_to_process) {
71 // we remove it from our list of stored SourceGroups and notify our observers
73 m_source_groups.erase(group_id);
74 }
75}
76
77} // SourceXtractor namespace
78
std::map< unsigned int, std::unique_ptr< SourceGroupInterface > > m_source_groups
AssocGrouping(std::shared_ptr< SourceGroupFactory > group_factory, unsigned int hard_limit)
void receiveProcessSignal(const ProcessSourcesEvent &event) override
Handles a ProcessSourcesEvent to trigger the processing of some of the Sources stored in SourceGroupi...
std::shared_ptr< SourceGroupFactory > m_group_factory
void receiveSource(std::unique_ptr< SourceInterface > source) override
Handles a new Source.
std::set< PropertyId > requiredProperties() const override
Returns the set of required properties to compute the grouping.
void sendSource(std::unique_ptr< SourceGroupInterface > source) const
static PropertyId create(unsigned int index=0)
Definition PropertyId.h:45
T move(T... args)
T push_back(T... args)
Event received by SourceGrouping to request the processing of some of the Sources stored.
const std::shared_ptr< SelectionCriteria > m_selection_criteria