SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
SEImplementation
Output
FlushableOutput.h
Go to the documentation of this file.
1
/*
2
* FlushableOutput.h
3
*
4
* Created on: Feb 8, 2022
5
* Author: mschefer
6
*/
7
8
#ifndef _SEIMPLEMENTATION_OUTPUT_FLUSHABLEOUTPUT_H_
9
#define _SEIMPLEMENTATION_OUTPUT_FLUSHABLEOUTPUT_H_
10
11
#include "Table/Row.h"
12
13
#include "
SEFramework/Output/Output.h
"
14
15
namespace
SourceXtractor
{
16
17
class
FlushableOutput
:
public
Output
{
18
19
public
:
20
using
SourceToRowConverter
=
std::function
<
Euclid::Table::Row
(
const
SourceInterface
&)>;
21
22
FlushableOutput
(
SourceToRowConverter
source_to_row
,
size_t
flush_size
)
23
:
m_source_to_row
(
source_to_row
),
m_flush_size
(
flush_size
),
m_total_rows_written
(0) {
24
}
25
26
virtual
~FlushableOutput
() =
default
;
27
28
size_t
flush
()
override
{
29
if
(!
m_rows
.
empty
()) {
30
writeRows
(
m_rows
);
31
}
32
m_total_rows_written
+=
m_rows
.
size
();
33
m_rows
.
clear
();
34
return
m_total_rows_written
;
35
}
36
37
void
outputSource
(
const
SourceInterface
&
source
)
override
{
38
m_rows
.
emplace_back
(
m_source_to_row
(
source
));
39
if
(
m_flush_size
> 0 &&
m_rows
.
size
() %
m_flush_size
== 0) {
40
flush
();
41
}
42
}
43
44
protected
:
45
virtual
void
writeRows
(
const
std::vector<Euclid::Table::Row>
&
rows
) = 0;
46
47
private
:
48
SourceToRowConverter
m_source_to_row
;
49
size_t
m_flush_size
;
50
51
std::vector<Euclid::Table::Row>
m_rows
{};
52
size_t
m_total_rows_written
;
53
};
54
55
}
56
57
#endif
/* SEIMPLEMENTATION_SEIMPLEMENTATION_OUTPUT_FLUSHABLEOUTPUT_H_ */
Output.h
Euclid::Table::Row
SourceXtractor::FlushableOutput
Definition
FlushableOutput.h:17
SourceXtractor::FlushableOutput::~FlushableOutput
virtual ~FlushableOutput()=default
SourceXtractor::FlushableOutput::writeRows
virtual void writeRows(const std::vector< Euclid::Table::Row > &rows)=0
SourceXtractor::FlushableOutput::FlushableOutput
FlushableOutput(SourceToRowConverter source_to_row, size_t flush_size)
Definition
FlushableOutput.h:22
SourceXtractor::FlushableOutput::m_flush_size
size_t m_flush_size
Definition
FlushableOutput.h:49
SourceXtractor::FlushableOutput::m_total_rows_written
size_t m_total_rows_written
Definition
FlushableOutput.h:52
SourceXtractor::FlushableOutput::outputSource
void outputSource(const SourceInterface &source) override
Definition
FlushableOutput.h:37
SourceXtractor::FlushableOutput::flush
size_t flush() override
Definition
FlushableOutput.h:28
SourceXtractor::FlushableOutput::m_rows
std::vector< Euclid::Table::Row > m_rows
Definition
FlushableOutput.h:51
SourceXtractor::FlushableOutput::m_source_to_row
SourceToRowConverter m_source_to_row
Definition
FlushableOutput.h:48
SourceXtractor::Output
Definition
Output.h:33
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
std::vector::clear
T clear(T... args)
std::vector::emplace_back
T emplace_back(T... args)
std::vector::empty
T empty(T... args)
std::function< Euclid::Table::Row(const SourceInterface &)>
SourceXtractor
Definition
Aperture.h:30
std::vector::size
T size(T... args)
Generated by
1.10.0