Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Euclid::Table::TableWriter Class Referenceabstract

Interface for classes writing tables. More...

#include <TableWriter.h>

Inheritance diagram for Euclid::Table::TableWriter:
Inheritance graph
[legend]
Collaboration diagram for Euclid::Table::TableWriter:
Collaboration graph
[legend]

Public Member Functions

 TableWriter ()=default
 
 TableWriter (TableWriter &&)=default
 
TableWriteroperator= (TableWriter &&)=default
 
 TableWriter (const TableWriter &)=delete
 
TableWriteroperator= (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< ColumnInfom_column_info {nullptr}
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TableWriter() [1/3]

Euclid::Table::TableWriter::TableWriter ( )
default

◆ TableWriter() [2/3]

Euclid::Table::TableWriter::TableWriter ( TableWriter &&  )
default

◆ TableWriter() [3/3]

Euclid::Table::TableWriter::TableWriter ( const TableWriter )
delete

◆ ~TableWriter()

virtual Euclid::Table::TableWriter::~TableWriter ( )
virtualdefault

Member Function Documentation

◆ addComment()

virtual void Euclid::Table::TableWriter::addComment ( const std::string comment)
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.

Parameters
commentThe comment to add
Exceptions
Elements::ExceptionIf data have been already been added and the implementation does not support further comments addition

Implemented in Euclid::Table::AsciiWriter, and Euclid::Table::FitsWriter.

◆ addData()

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.

Parameters
tableThe table containing the rows to write
Exceptions
Elements::ExceptionIf 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.

Here is the call graph for this function:

◆ append()

virtual void Euclid::Table::TableWriter::append ( const Table table)
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.

Parameters
tableThe table containing the rows to write

Implemented in Euclid::Table::AsciiWriter, and Euclid::Table::FitsWriter.

Referenced by addData().

◆ init()

virtual void Euclid::Table::TableWriter::init ( const Table table)
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.

Parameters
tableThe table to get the column information from

Implemented in Euclid::Table::AsciiWriter, and Euclid::Table::FitsWriter.

Referenced by addData().

◆ operator=() [1/2]

TableWriter & Euclid::Table::TableWriter::operator= ( const TableWriter )
delete

◆ operator=() [2/2]

TableWriter & Euclid::Table::TableWriter::operator= ( TableWriter &&  )
default

Member Data Documentation

◆ m_column_info

std::unique_ptr<ColumnInfo> Euclid::Table::TableWriter::m_column_info {nullptr}
private

Definition at line 120 of file TableWriter.h.

Referenced by addData().


The documentation for this class was generated from the following files: