Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Interface for classes writing tables. More...
#include <TableWriter.h>
Public Member Functions | |
TableWriter ()=default | |
TableWriter (TableWriter &&)=default | |
TableWriter & | operator= (TableWriter &&)=default |
TableWriter (const TableWriter &)=delete | |
TableWriter & | operator= (const TableWriter &)=delete |
virtual | ~TableWriter ()=default |
virtual void | addComment (const std::string &comment)=0 |
Adds a comment to the output table. | |
void | addData (const Table &table) |
Appends the contents of the given table to the output. | |
Protected Member Functions | |
virtual void | init (const Table &table)=0 |
Initializes the output header based on the given table columns. | |
virtual void | append (const Table &table)=0 |
Appends to the output the contents of the given table. | |
Private Attributes | |
std::unique_ptr< ColumnInfo > | m_column_info {nullptr} |
Interface for classes writing tables.
Each TableWriter implementation should behave like a stream writing a table. It must implement the methods addComment(), init() and append(). See the documentation of these methods for more information of how to implement them.
Note that all TableWriter implementations, as they are representing streams to a single table, should not be able to be copied, something that is forced by the TableWriter interface. There is no such restriction for move operations.
Definition at line 49 of file TableWriter.h.
|
default |
|
default |
|
delete |
|
virtualdefault |
|
pure virtual |
Adds a comment to the output table.
The different implementations should implement this method to write the comment to the output stream. The behavior of this method after data have been already been added is up to the specific implementation, which can either allow for the addition of the comment (if the format supports such action) or throw an exception. Users of the generic interface should not call this method after the addData() has been called.
comment | The comment to add |
Elements::Exception | If data have been already been added and the implementation does not support further comments addition |
Implemented in Euclid::Table::AsciiWriter, and Euclid::Table::FitsWriter.
void Euclid::Table::TableWriter::addData | ( | const Table & | table | ) |
Appends the contents of the given table to the output.
The first time this method is called defines the columns of the output. Any subsequent calls must be done with tables which match exactly these column names and types. When the call ends, the given data should be already written to the underlying stream or file.
table | The table containing the rows to write |
Elements::Exception | If the given table has different columns than one used at a previous call of the addData() method. |
Definition at line 31 of file TableWriter.cpp.
References append(), init(), and m_column_info.
|
protectedpure virtual |
Appends to the output the contents of the given table.
The specific implementations should implement this method to append to the output all the rows of the given table. This method can assume that the init() has already been called. The given table is guaranteed to have the same columns with the one the init() has been called with, so no extra checks are necessary. When the call ends, the given data should be already written to the output.
table | The table containing the rows to write |
Implemented in Euclid::Table::AsciiWriter, and Euclid::Table::FitsWriter.
Referenced by addData().
|
protectedpure virtual |
Initializes the output header based on the given table columns.
This method will be called the first time the addData() is called, before the append() call. The specific implementations should update their output with the column information of the table.
table | The table to get the column information from |
Implemented in Euclid::Table::AsciiWriter, and Euclid::Table::FitsWriter.
Referenced by addData().
|
delete |
|
default |
|
private |
Definition at line 120 of file TableWriter.h.
Referenced by addData().