SourceXtractorPlusPlus  0.13
Please provide a description of the project.
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 
29 
30 namespace SourceXtractor {
31 
32 class TableOutput : public Output {
33 
34 public:
35 
38  using SourceHandler = std::function<void(const SourceInterface& source)>;
39 
40  size_t flush() override {
41  if (!m_rows.empty()) {
43  m_table_handler(table);
44  }
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);
60  if (m_flush_size > 0 && m_rows.size() % m_flush_size == 0) {
61  flush();
62  }
63  }
64 
65 private:
70  size_t m_flush_size;
72 };
73 
74 } /* namespace SourceXtractor */
75 
76 #endif /* _SEIMPLEMENTATION_TABLEOUTPUT_H */
77 
SourceXtractor::TableOutput::flush
size_t flush() override
Definition: TableOutput.h:40
SourceXtractor::TableOutput
Definition: TableOutput.h:32
SourceXtractor::TableOutput::m_total_rows_written
size_t m_total_rows_written
Definition: TableOutput.h:71
SourceXtractor::TableOutput::outputSource
void outputSource(const SourceInterface &source) override
Definition: TableOutput.h:56
std::vector< Euclid::Table::Row >
std::vector::size
T size(T... args)
Table.h
CastVisitor.h
SourceXtractor::TableOutput::m_flush_size
size_t m_flush_size
Definition: TableOutput.h:70
SourceXtractor::TableOutput::m_table_handler
TableHandler m_table_handler
Definition: TableOutput.h:67
std::function< Euclid::Table::Row(const SourceInterface &)>
std::vector::clear
T clear(T... args)
SourceXtractor
Definition: Aperture.h:30
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
Output.h
std::vector::emplace_back
T emplace_back(T... args)
Euclid::Table::Table
std::vector::empty
T empty(T... args)
SourceXtractor::TableOutput::m_source_handler
SourceHandler m_source_handler
Definition: TableOutput.h:68
Euclid::Table::Row
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
SourceXtractor::Output
Definition: Output.h:35
SourceXtractor::TableOutput::m_source_to_row
SourceToRowConverter m_source_to_row
Definition: TableOutput.h:66