| IOLink 1.11.0

Loading...
Searching...
No Matches
Public Member Functions | List of all members
iolink::DataFrameView Class Referenceabstract

View to model tabular data. More...

`#include <iolink/view/DataFrameView.h>`

Inheritance diagram for iolink::DataFrameView:

## Public Member Functions
virtual DataFrameCapabilitySet | capabilities () const =0
| Return the view's capabilities.
virtual const Vector2u64 & | shape () const =0
| Return the shape of the data frame.
virtual const std::string & | columnName (size_t index) const =0
| Get the name of a column from its index.
virtual size_t | columnIndex (const std::string &name) const =0
| Get the index of a column from its name.
virtual DataType | columnDataType (size_t index) const =0
| Return the data type of the column.
virtual void | read (size_t column, size_t offset, size_t count, void *dst) const
| Read data from a column.
template<typename T >
T | at (size_t column, size_t row) const
| Get the value stored in a cell of the data frame.
template<typename T >
T | at (const std::string &columnName, size_t row) const
| Get the value stored in a cell of the data frame.
const std::string & | unit (size_t columnIndex)
| Return the unit of the column.
virtual void | write (size_t column, size_t offset, size_t count, const void *src)
| Write data into a column.
template<typename T >
void | setAt (size_t column, size_t row, T value)
| Set the element value in a cell of the data frame.
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.
void | setUnit (size_t columnIndex, const std::string &unit)
| Set the unit of the column.
virtual void | addColumn (const std::string &name, DataType dtype)
| Add a column to the dataframe.
virtual void | addRows (size_t offset, size_t count)
| Insert rows at the specified position.
virtual void | removeColumn (size_t index)
| Remove a column.
virtual void | removeRows (size_t offset, size_t count)
| Remove a continuous set of rows.
std::string | toString () const
| Return a string representation.
void | reshape (const Vector2u64 &shape, const std::string *columnNames, const DataType *columnDataTypes)
| Method to reshape a DataFrame.
Public Member Functions inherited from iolink::View
virtual std::shared_ptr< Extension > | extension (size_t id)
| Get an extension of the view, corresponding to the given identifier.
template<typename T >
std::shared_ptr< T > | extension ()
| Get an extension of the view, corresponding to the given type.
std::shared_ptr< ViewOriginExtension > | viewOrigin ()
| Shortcut to access to ViewOrigin extension.

## 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

  name | The name of the new column.
  dtype | The type of data stored in the column.

Exceptions

  NotImplemented | When the view does not support reshaping.
  Error | if there is already a column with the same name.
  Error | if 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

  offset | New 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.
  count | The number of rows to insert.

Exceptions

  NotImplemented | When the view does not support reshaping.
  Error | When offset is out of bounds.
  Error | When 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

  T | The type of the data stored in the cell.

Parameters

  columnName | The name of the column where to get the cell.
  row | The index of the row

Returns
  The value of the chosen cell.

Exceptions

  Error | if the column name does not exist in the data frame.
  Error | if 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

  T | The type of the data stored in the cell.

Parameters

  column | The index of the column
  row | The index of the row

Returns
  The value of the cell at the given index.

Exceptions

  Error | if 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

  index | The index of the column.

Exceptions

  Error | When 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

  name | The name of the column.

Exceptions

  Error | If 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

  index | The index of the column.

Exceptions

  Error | If 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

  column | The index of the column to read from.
  offset | The index of the first element to read.
  count | The number of elements to read.
  dst | A buffer where the read data will be written.

Exceptions

  NotImplemented | When the view does not support reading.
  Error | When dst is null.
  Error | When the column index is invalid.
  Error | When offset is out of bounds.
  Error | If 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

  index | The index of the column to remove.

Exceptions

  NotImplemented | When the view does not support reshaping.
  Error | If the index is out of bounds.
  Error | When 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

  offset | The index of the first column to remove.
  count | Row count to delete.

Exceptions

  NotImplemented | When the view does not support reshaping.
  Error | When offset is out of bounds.
  Error | When it is impossible to remove these rows.

## ◆ reshape()

void iolink::DataFrameView::reshape | ( | const Vector2u64 & | shape,
|  | const std::string * | columnNames,
|  | const DataType * | columnDataTypes
| ) |  |

Method to reshape a DataFrame.

This method requires the RESHAPE capability.

All the dataframe's data is invalidated after this operation.

Parameters

  shape | shape of the allocated dataframe (column count, row count)
  columnNames | Array which contains the name for each column
  columnDataTypes | Array which contains the data type of each column

Warning
  No check is done on inputs. Pass arguments very carefully. columnNames and columnDataTypes shall have the same element count, and their size must be equal to shape[0].
  column count and row count cannot be 0.

## ◆ setAt() [1/2]

template<typename T >

void iolink::DataFrameView::setAt | ( | const std::string & | columnName,
|  | size_t | row,
|  | T | value
| ) |  |
| inline

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

Template Parameters

  T | The type of the data stored in the cell.

Parameters

  columnName | The name of the column where to set the cell.
  row | The row of the cell to set.
  value | The value to store in the cell.

Exceptions

  Error | if the column name does not exist in the data frame.
  Error | if the row is out of bounds.

## ◆ setAt() [2/2]

template<typename T >

void iolink::DataFrameView::setAt | ( | size_t | column,
|  | size_t | row,
|  | T | value
| ) |  |
| inline

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

Template Parameters

  T | The type of the data stored in the cell.

Parameters

  column | The column of the cell to set.
  row | The row of the cell to set.
  value | The value to store in the cell.

Exceptions

  Error | if the column name does not exist in the data frame.
  Error | if the row is out of bounds.

## ◆ setUnit()

void iolink::DataFrameView::setUnit | ( | size_t | columnIndex,
|  | const std::string & | unit
| ) |  |

Set the unit of the column.

Parameters

  columnIndex | The index of the column.
  unit | The unit of the column.

Exceptions

  Error | if the column index is out of range.
  Error | if DataFrameView does not have the WRITE capability.

## ◆ 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.

## ◆ unit()

const std::string & iolink::DataFrameView::unit | ( | size_t | columnIndex | ) |

Return the unit of the column.

Parameters

  columnIndex | The index of the column.

Returns
  The unit of the column.

Exceptions

  Error | if the column index is out of range.

## ◆ 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

  column | The index of the column to write into.
  offset | The index of the first element to write.
  count | The number of element to write.
  src | A buffer whose content will be written in the column.

Exceptions

  NotImplemented | When the view does not support writing.
  Error | When src is null.
  Error | When the column index is invalid.
  Error | When offset is out of bounds.
  Error | If it is impossible to write the number of elements required.

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

- iolink/public/include/iolink/view/DataFrameView.h