SourceXtractorPlusPlus
1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEMain
src
lib
Sorter.cpp
Go to the documentation of this file.
1
17
18
#include "
SEMain/Sorter.h
"
19
#include <
SEImplementation/Plugin/SourceIDs/SourceID.h
>
20
#include <algorithm>
21
#include <vector>
22
23
namespace
SourceXtractor
{
24
25
static
unsigned
int
extractSourceId
(
const
SourceInterface
&i) {
26
return
i.
getProperty
<
SourceID
>().getId();
27
}
28
29
Sorter::Sorter
():
m_output_next
{1} {
30
}
31
32
void
Sorter::receiveSource
(
std::unique_ptr<SourceGroupInterface>
message) {
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
}
47
void
Sorter::receiveProcessSignal
(
const
ProcessSourcesEvent
& event) {
48
sendProcessSignal
(event);
49
}
50
51
}
// end SourceXtractor
Sorter.h
SourceID.h
std::vector::begin
T begin(T... args)
SourceXtractor::PipelineEmitter< SourceGroupInterface >::sendProcessSignal
void sendProcessSignal(const ProcessSourcesEvent &event) const
Definition
PipelineStage.h:92
SourceXtractor::PipelineEmitter< SourceGroupInterface >::sendSource
void sendSource(std::unique_ptr< SourceGroupInterface > source) const
Definition
PipelineStage.h:85
SourceXtractor::Sorter::m_output_buffer
std::map< int, std::unique_ptr< SourceGroupInterface > > m_output_buffer
Definition
Sorter.h:43
SourceXtractor::Sorter::Sorter
Sorter()
Definition
Sorter.cpp:29
SourceXtractor::Sorter::receiveSource
void receiveSource(std::unique_ptr< SourceGroupInterface > source) override
Definition
Sorter.cpp:32
SourceXtractor::Sorter::receiveProcessSignal
void receiveProcessSignal(const ProcessSourcesEvent &event) override
Definition
Sorter.cpp:47
SourceXtractor::Sorter::m_output_next
int m_output_next
Definition
Sorter.h:44
SourceXtractor::SourceID
Definition
SourceID.h:33
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
SourceXtractor::SourceInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition
SourceInterface.h:57
std::vector::end
T end(T... args)
std::vector::front
T front(T... args)
std::move
T move(T... args)
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::extractSourceId
static unsigned int extractSourceId(const SourceInterface &i)
Definition
Sorter.cpp:25
std::sort
T sort(T... args)
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition
PipelineStage.h:33
std::transform
T transform(T... args)
std::unique_ptr
std::vector
Generated by
1.15.0