IOLink  IOL_v1.6.1_release
iolink::DataFrameView Class Referenceabstract

View to model tabular data. More...

#include <iolink/view/DataFrameView.h>

Inheritance diagram for iolink::DataFrameView:
iolink::View

Public Member Functions

virtual DataFrameCapabilitySet capabilities () const =0
 Return the view's capabilities. More...
 
virtual const Vector2u64shape () const =0
 Return the shape of the data frame. More...
 
virtual const std::string & columnName (size_t index) const =0
 Get the name of a column from its index. More...
 
virtual size_t columnIndex (const std::string &name) const =0
 Get the index of a column from its name. More...
 
virtual DataType columnDataType (size_t index) const =0
 Return the data type of the column. More...
 
virtual void read (size_t column, size_t offset, size_t count, void *dst) const
 Read data from a column. More...
 
template<typename T >
at (size_t column, size_t row) const
 Get the value stored in a cell of the data frame. More...
 
template<typename T >
at (const std::string &columnName, size_t row) const
 Get the value stored in a cell of the data frame. More...
 
virtual void write (size_t column, size_t offset, size_t count, const void *src)
 Write data into a column. More...
 
template<typename T >
void setAt (size_t column, size_t row, T value)
 Set the element value in a cell of the data frame. More...
 
template<typename T >
void setAt (const std::string &columnName, size_t row, T value)
 Set the element value in a cell of the data frame. More...
 
virtual void addColumn (const std::string &name, DataType dtype)
 Add a column to the dataframe. More...
 
virtual void addRows (size_t offset, size_t count)
 Insert rows at the specified position. More...
 
virtual void removeColumn (size_t index)
 Remove a column. More...
 
virtual void removeRows (size_t offset, size_t count)
 Remove a continuous set of rows. More...
 
std::string toString () const
 Return a string representation.
 

Detailed Description

View to model tabular data.

This view is composed of a set of columns, that have a name and a data type. A column's name is unique, and columns in a dataframe can have different data types.

Each column has the same number of elements. The aggregate of all n-th elements of columns are a row of the dataframe.

Member Function Documentation

◆ addColumn()

virtual void iolink::DataFrameView::addColumn ( const std::string &  name,
DataType  dtype 
)
virtual

Add a column to the dataframe.

This method requires the RESHAPE capability.

The new column's data will be undefined after addition.

Parameters
nameThe name of the new column.
dtypeThe type of data stored in the column.
Exceptions
NotImplementedWhen the view does not support reshaping.
Errorif there is already a column with the same name.
Errorif the implementation does not support the data type.

◆ addRows()

virtual void iolink::DataFrameView::addRows ( size_t  offset,
size_t  count 
)
virtual

Insert rows at the specified position.

This method requires the RESHAPE capability.

New rows content will be undefined after insertion.

Parameters
offsetNew rows will be inserted before this row. If the offset is the number of rows in the dataframe, rows will be inserted at the end.
countThe number of rows to insert.
Exceptions
NotImplementedWhen the view does not support reshaping.
ErrorWhen offset is out of bounds.
ErrorWhen it is impossible to add these rows.

◆ at() [1/2]

template<typename T >
T iolink::DataFrameView::at ( const std::string &  columnName,
size_t  row 
) const
inline

Get the value stored in a cell of the data frame.

Template Parameters
TThe type of the data stored in the cell.
Parameters
columnNameThe name of the column where to get the cell.
rowThe row of the chosen cell.
Returns
The value of the chosen cell.
Exceptions
Errorif the column name does not exist in the data frame.
Errorif the row is out of bounds.

◆ at() [2/2]

template<typename T >
T iolink::DataFrameView::at ( size_t  column,
size_t  row 
) const
inline

Get the value stored in a cell of the data frame.

Template Parameters
TThe type of the data stored in the cell.
Parameters
columnThe column of the cell to get.
rowThe row of the cell to get.
Returns
The value of the cell at the given index.
Exceptions
Errorif the column or the cell index is out of bounds.

◆ capabilities()

virtual DataFrameCapabilitySet iolink::DataFrameView::capabilities ( ) const
pure virtual

Return the view's capabilities.

See also
DataFrameCapability

◆ columnDataType()

virtual DataType iolink::DataFrameView::columnDataType ( size_t  index) const
pure virtual

Return the data type of the column.

Parameters
nameThe index of the column.
Exceptions
ErrorWhen index is out of range.

◆ columnIndex()

virtual size_t iolink::DataFrameView::columnIndex ( const std::string &  name) const
pure virtual

Get the index of a column from its name.

Parameters
nameThe name of the column.
Exceptions
ErrorIf there is no column with that name.

◆ columnName()

virtual const std::string& iolink::DataFrameView::columnName ( size_t  index) const
pure virtual

Get the name of a column from its index.

Column indices go from 0 to shape[0] - 1.

Parameters
indexThe index of the column.
Exceptions
ErrorIf index is out of range.

◆ read()

virtual void iolink::DataFrameView::read ( size_t  column,
size_t  offset,
size_t  count,
void *  dst 
) const
virtual

Read data from a column.

This method requires the READ capability.

When reading numeric data, the dst buffer will be filled with continuous values. In the case of strings, it will be a continuous array of string objects.

The destination buffer must be allocated by the user. If its size is under the byte count needed to store the request number of elements, a segmentation fault will rise, as there is no boundaries check.

Parameters
columnThe index of the column to read from.
offsetThe index of the first element to read.
countThe number of elements to read.
dstA buffer where the read data will be written.
Exceptions
NotImplementedWhen the view does not support reading.
ErrorWhen dst is null.
ErrorWhen the column index is invalid.
ErrorWhen offset is out of bounds.
ErrorIf it is impossible to read the number of elements required.

◆ removeColumn()

virtual void iolink::DataFrameView::removeColumn ( size_t  index)
virtual

Remove a column.

This method requires the RESHAPE capability.

Parameters
indexThe index of the column to remove.
Exceptions
NotImplementedWhen the view does not support reshaping.
ErrorIf the index is out of bounds.
ErrorWhen it is impossible to remove that column.

◆ removeRows()

virtual void iolink::DataFrameView::removeRows ( size_t  offset,
size_t  count 
)
virtual

Remove a continuous set of rows.

This method requires the RESHAPE capability.

Parameters
offsetThe index of the first column to remove.
countRow count to delete.
Exceptions
NotImplementedWhen the view does not support reshaping.
ErrorWhen offset is out of bounds.
ErrorWhen it is impossible to remove these rows.

◆ setAt() [1/2]

template<typename T >
void iolink::DataFrameView::setAt ( const std::string &  columnName,
size_t  row,
value 
)
inline

Set the element value in a cell of the data frame.

Template Parameters
TThe type of the data stored in the cell.
Parameters
columnNameThe name of the column where to set the cell.
rowThe row of the cell to set.
valueThe value to store in the cell.
Exceptions
Errorif the column name does not exist in the data frame.
Errorif the row is out of bounds.

◆ setAt() [2/2]

template<typename T >
void iolink::DataFrameView::setAt ( size_t  column,
size_t  row,
value 
)
inline

Set the element value in a cell of the data frame.

Template Parameters
TThe type of the data stored in the cell.
Parameters
columnThe column of the cell to set.
rowThe row of the cell to set.
valueThe value to store in the cell.
Exceptions
Errorif the column name does not exist in the data frame.
Errorif the row is out of bounds.

◆ shape()

virtual const Vector2u64& iolink::DataFrameView::shape ( ) const
pure virtual

Return the shape of the data frame.

First element being the number of columns, and the second, the number of rows.

◆ write()

virtual void iolink::DataFrameView::write ( size_t  column,
size_t  offset,
size_t  count,
const void *  src 
)
virtual

Write data into a column.

This method requires the WRITE capability.

When writing numeric data, the src buffer must be filled with continuous values. In the case of strings, the source must use a continuous array of string objects.

The source buffer must be allocated by the user. If its size is under the byte count needed to store the request number of elements, a segmentation fault will rise, as there is no boundaries check.

Parameters
columnThe index of the column to write into.
offsetThe index of the first element to write.
countThe number of element to write.
dstA buffer whose content will be written in the column.
Exceptions
NotImplementedWhen the view does not support writing.
ErrorWhen src is null.
ErrorWhen the column index is invalid.
ErrorWhen offset is out of bounds.
ErrorIf it is impossible to write the number of elements required.

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