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

Interface for classes reading tables. More...

#include <TableReader.h>

Inheritance diagram for Euclid::Table::TableReader:
Inheritance graph
[legend]

Public Member Functions

 TableReader ()=default
 
 TableReader (TableReader &&)=default
 
TableReaderoperator= (TableReader &&)=default
 
 TableReader (const TableReader &)=delete
 
TableReaderoperator= (const TableReader &)=delete
 
virtual ~TableReader ()=default
 
virtual std::string getComment ()=0
 
virtual const ColumnInfogetInfo ()=0
 Returns the column information of the table.
 
Table read (long rows=-1)
 Reads next rows as a table.
 
virtual void skip (long rows)=0
 Skips next rows.
 
virtual bool hasMoreRows ()=0
 Checks if there are any rows left to read.
 
virtual std::size_t rowsLeft ()=0
 Returns the number of rows left to read.
 

Protected Member Functions

virtual Table readImpl (long rows)=0
 Method to be implemented by subclasses for reading the table.
 

Detailed Description

Interface for classes reading tables.

Each TableReader implementation should behave like a stream to a table. It must implement the methods getComment(), getInfo(), readImpl(), skip() and hasMoreRows(). See the documentation of these methods for more information of how to implement them.

Note that all TableReader implementations, as they are representing streams to a single table, should not be able to be copied, something that is forced by the TableReader interface. There is no such restriction for move operations.

Definition at line 48 of file TableReader.h.

Constructor & Destructor Documentation

◆ TableReader() [1/3]

Euclid::Table::TableReader::TableReader ( )
default

◆ TableReader() [2/3]

Euclid::Table::TableReader::TableReader ( TableReader &&  )
default

◆ TableReader() [3/3]

Euclid::Table::TableReader::TableReader ( const TableReader )
delete

◆ ~TableReader()

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

Member Function Documentation

◆ getComment()

virtual std::string Euclid::Table::TableReader::getComment ( )
pure virtual
Returns
Returns the comment associated to the table

Implemented in Euclid::Table::AsciiReader, and Euclid::Table::FitsReader.

◆ getInfo()

virtual const ColumnInfo & Euclid::Table::TableReader::getInfo ( )
pure virtual

Returns the column information of the table.

The different implementations should try to implement this method in such way so the full parsing of the table is not necessary and multiple calls of this method do not trigger the reading again.

Returns
The table column information

Implemented in Euclid::Table::AsciiReader, and Euclid::Table::FitsReader.

◆ hasMoreRows()

virtual bool Euclid::Table::TableReader::hasMoreRows ( )
pure virtual

Checks if there are any rows left to read.

Implementations should implement this method to return true if there are still rows not read using the read() method and false otherwise. If the result of this method is true, a call to read() should successfully return a table object, If the result of this method is false, a call th read() will throw an Elements::Exception.

Returns
true if there are more rows to read

Implemented in Euclid::Table::AsciiReader, and Euclid::Table::FitsReader.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ read()

Table Euclid::Table::TableReader::read ( long  rows = -1)
inline

Reads next rows as a table.

If the given parameter is a number bigger than the rows left, the result is a table with all of them (and size less than the parameter). If the parameter is a negative number, the returned Table object contains all the remaining rows. If the all the rows of the table have already been read, an exception is thrown.

Parameters
rowsThe number of rows to read
Returns
A Table object containing the rows read
Exceptions
Elements::ExceptionIf the reader has already read all the available rows

Definition at line 91 of file TableReader.h.

References readImpl().

Referenced by Euclid::XYDataset::FitsParser::getDataset().

Here is the call graph for this function:

◆ readImpl()

virtual Table Euclid::Table::TableReader::readImpl ( long  rows)
protectedpure virtual

Method to be implemented by subclasses for reading the table.

Implementations should implement this method to behave as described at the documentation of the read() method.

Parameters
rowsThe number of rows to read
Returns
A Table object containing the rows read
Exceptions
Elements::ExceptionIf the reader has already read all the available rows

Implemented in Euclid::Table::AsciiReader, and Euclid::Table::FitsReader.

Referenced by read().

◆ rowsLeft()

virtual std::size_t Euclid::Table::TableReader::rowsLeft ( )
pure virtual

Returns the number of rows left to read.

When using this method keep in mind that some formats (like ASCII) might require to parse the full file.

Returns
The number of rows left to read

Implemented in Euclid::Table::AsciiReader, and Euclid::Table::FitsReader.

◆ skip()

virtual void Euclid::Table::TableReader::skip ( long  rows)
pure virtual

Skips next rows.

Implementations should implement this method so the next read() call will ignore that many rows as the given parameter. If the given number is greater or equal to the number of rows left, a consequent call of read() should throw an exception and a call to hasMoreRows() should return false.

Parameters
rowsThe number of rows to skip

Implemented in Euclid::Table::AsciiReader, and Euclid::Table::FitsReader.


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