SourceXtractorPlusPlus
0.15
Please provide a description of the project.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SEMain
src
lib
Sorter.cpp
Go to the documentation of this file.
1
17
#include <
SEImplementation/Plugin/SourceIDs/SourceID.h
>
18
#include <algorithm>
19
#include "
SEMain/Sorter.h
"
20
21
namespace
SourceXtractor {
22
23
static
unsigned
int
extractSourceId
(
const
SourceInterface
&i) {
24
return
i.
getProperty
<
SourceID
>().getId();
25
}
26
27
Sorter::Sorter
(): m_output_next{1} {
28
}
29
30
void
Sorter::handleMessage
(
const
std::shared_ptr<SourceGroupInterface>
&message) {
31
std::vector<unsigned int>
source_ids(message->size());
32
std::transform
(message->cbegin(), message->cend(), source_ids.begin(),
extractSourceId
);
33
std::sort
(source_ids.begin(), source_ids.end());
34
35
auto
first_source_id = source_ids.front();
36
m_output_buffer
.emplace(first_source_id, message);
37
38
while
(!
m_output_buffer
.empty() &&
m_output_buffer
.begin()->first ==
m_output_next
) {
39
auto
&next_group =
m_output_buffer
.begin()->second;
40
m_output_next
+= next_group->size();
41
notifyObservers
(next_group);
42
m_output_buffer
.erase(
m_output_buffer
.begin());
43
}
44
}
45
46
47
}
// end SourceXtractor
Sorter.h
std::shared_ptr< SourceGroupInterface >
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
SourceXtractor::Observable< std::shared_ptr< SourceGroupInterface > >::notifyObservers
void notifyObservers(const std::shared_ptr< SourceGroupInterface > &message) const
Definition:
Observable.h:71
SourceXtractor::Sorter::m_output_next
int m_output_next
Definition:
Sorter.h:43
SourceID.h
SourceXtractor::Sorter::handleMessage
void handleMessage(const std::shared_ptr< SourceGroupInterface > &message) override
Definition:
Sorter.cpp:30
SourceXtractor::Sorter::m_output_buffer
std::map< int, std::shared_ptr< SourceGroupInterface > > m_output_buffer
Definition:
Sorter.h:42
std::vector
STL class.
SourceXtractor::SourceID
Definition:
SourceID.h:33
SourceXtractor::Sorter::Sorter
Sorter()
Definition:
Sorter.cpp:27
std::sort
T sort(T...args)
std::transform
T transform(T...args)
SourceXtractor::extractSourceId
static unsigned int extractSourceId(const SourceInterface &i)
Definition:
Sorter.cpp:23
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition:
SourceInterface.h:46
Generated by
1.8.5