SourceXtractorPlusPlus
0.11
Please provide a description of the project.
SEImplementation
SEImplementation
Output
TableOutput.h
Go to the documentation of this file.
1
17
/*
18
* @file TableOutput.h
19
* @author nikoapos
20
*/
21
22
#ifndef _SEIMPLEMENTATION_TABLEOUTPUT_H
23
#define _SEIMPLEMENTATION_TABLEOUTPUT_H
24
25
#include "
Table/Table.h
"
26
#include "
Table/CastVisitor.h
"
27
28
#include "
SEFramework/Output/Output.h
"
29
30
namespace
SourceXtractor
{
31
32
class
TableOutput
:
public
Output
{
33
34
public
:
35
36
using
SourceToRowConverter
=
std::function<Euclid::Table::Row(const SourceInterface&)>
;
37
using
TableHandler
=
std::function<void(const Euclid::Table::Table&)>
;
38
using
SourceHandler
=
std::function<void(const SourceInterface& source)>
;
39
40
size_t
flush
()
override
{
41
if
(!
m_rows
.
empty
()) {
42
Euclid::Table::Table
table {
m_rows
};
43
m_table_handler
(table);
44
}
45
m_total_rows_written
+=
m_rows
.
size
();
46
m_rows
.
clear
();
47
return
m_total_rows_written
;
48
}
49
50
TableOutput
(
SourceToRowConverter
source_to_row,
TableHandler
table_handler,
SourceHandler
source_handler,
51
size_t
flush_size)
52
:
m_source_to_row
(source_to_row),
m_table_handler
(table_handler),
m_source_handler
(source_handler),
53
m_flush_size
(flush_size),
m_total_rows_written
(0) {
54
}
55
56
void
outputSource
(
const
SourceInterface
& source)
override
{
57
if
(
m_source_handler
)
58
m_source_handler
(source);
59
m_rows
.
emplace_back
(
m_source_to_row
(source));
60
if
(
m_flush_size
> 0 &&
m_rows
.
size
() %
m_flush_size
== 0) {
61
flush
();
62
}
63
}
64
65
private
:
66
SourceToRowConverter
m_source_to_row
;
67
TableHandler
m_table_handler
;
68
SourceHandler
m_source_handler
;
69
std::vector<Euclid::Table::Row>
m_rows
{};
70
size_t
m_flush_size
;
71
size_t
m_total_rows_written
;
72
};
73
74
}
/* namespace SourceXtractor */
75
76
#endif
/* _SEIMPLEMENTATION_TABLEOUTPUT_H */
77
std::vector::empty
T empty(T... args)
SourceXtractor::TableOutput::flush
size_t flush() override
Definition:
TableOutput.h:40
SourceXtractor::TableOutput::m_flush_size
size_t m_flush_size
Definition:
TableOutput.h:70
SourceXtractor::TableOutput::m_source_to_row
SourceToRowConverter m_source_to_row
Definition:
TableOutput.h:66
std::function< Euclid::Table::Row(const SourceInterface &)>
Output.h
SourceXtractor::TableOutput::m_table_handler
TableHandler m_table_handler
Definition:
TableOutput.h:67
CastVisitor.h
SourceXtractor::TableOutput::outputSource
void outputSource(const SourceInterface &source) override
Definition:
TableOutput.h:56
SourceXtractor::Output
Definition:
Output.h:33
SourceXtractor::TableOutput::TableOutput
TableOutput(SourceToRowConverter source_to_row, TableHandler table_handler, SourceHandler source_handler, size_t flush_size)
Definition:
TableOutput.h:50
SourceXtractor::TableOutput::m_rows
std::vector< Euclid::Table::Row > m_rows
Definition:
TableOutput.h:69
SourceXtractor
Definition:
Aperture.h:30
std::vector::clear
T clear(T... args)
Euclid::Table::Table
SourceXtractor::TableOutput
Definition:
TableOutput.h:32
std::vector::size
T size(T... args)
std::vector< Euclid::Table::Row >
Table.h
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition:
SourceInterface.h:46
SourceXtractor::TableOutput::m_source_handler
SourceHandler m_source_handler
Definition:
TableOutput.h:68
SourceXtractor::TableOutput::m_total_rows_written
size_t m_total_rows_written
Definition:
TableOutput.h:71
std::vector::emplace_back
T emplace_back(T... args)
Generated by
1.8.14