SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
Sorter.cpp
Go to the documentation of this file.
1
17
18#include "SEMain/Sorter.h"
20#include <algorithm>
21#include <vector>
22
23namespace SourceXtractor {
24
25static unsigned int extractSourceId(const SourceInterface &i) {
26 return i.getProperty<SourceID>().getId();
27}
28
31
33 std::vector<unsigned int> source_ids(message->size());
34 std::transform(message->cbegin(), message->cend(), source_ids.begin(), extractSourceId);
35 std::sort(source_ids.begin(), source_ids.end());
36
37 auto first_source_id = source_ids.front();
38 m_output_buffer.emplace(first_source_id, std::move(message));
39
40 while (!m_output_buffer.empty() && m_output_buffer.begin()->first == m_output_next) {
41 auto &next_group = m_output_buffer.begin()->second;
42 m_output_next += next_group->size();
43 sendSource(std::move(next_group));
44 m_output_buffer.erase(m_output_buffer.begin());
45 }
46}
50
51} // end SourceXtractor
T begin(T... args)
void sendProcessSignal(const ProcessSourcesEvent &event) const
void sendSource(std::unique_ptr< SourceGroupInterface > source) const
std::map< int, std::unique_ptr< SourceGroupInterface > > m_output_buffer
Definition Sorter.h:43
void receiveSource(std::unique_ptr< SourceGroupInterface > source) override
Definition Sorter.cpp:32
void receiveProcessSignal(const ProcessSourcesEvent &event) override
Definition Sorter.cpp:47
The SourceInterface is an abstract "source" that has properties attached to it.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
T end(T... args)
T front(T... args)
T move(T... args)
static unsigned int extractSourceId(const SourceInterface &i)
Definition Sorter.cpp:25
T sort(T... args)
Event received by SourceGrouping to request the processing of some of the Sources stored.
T transform(T... args)