Workspace 6.21.5
|
This class defines the DataTable data type. A DataTable is a table that contains a set of columns and a collection of data records (i.e. rows). More...
#include <Workspace/DataExecution/DataObjects/datatable.h>
Public Member Functions | |
DataTable () | |
DataTable (const DataTable &other) | |
~DataTable () override | |
template<typename T > | |
void | addColumn (const QString &name, const QString &longName, const QStringList &units=QStringList()) |
template<typename T > | |
void | addColumn (const QString &name, const QStringList &units=QStringList()) |
int | appendRecord () |
bool | canSerialize () const override |
void | clear () |
void | clearData () |
DataTableColumn | column (const QString &name) const |
template<typename T > | |
T & | data (int index, const QString &name) |
template<typename T > | |
const T & | data (int index, const QString &name) const |
template<typename T > | |
T & | defaultData (const QString &name) |
template<typename T > | |
const T & | defaultData (const QString &name) const |
QStringList | getColumnsName () const |
DataObject & | getDataObject (int index, const QString &name) |
const DataObject & | getDataObject (int index, const QString &name) const |
void | insertRecord (int index) |
bool | load (const SerializedItem &item) override |
int | numRecords () const |
DataTable & | operator= (const DataTable &other) |
void | removeColumn (const QString &name) |
void | removeRecord (int index) |
bool | save (SerializedItem &item) const override |
void | swapRecords (int index1, int index2) |
Public Member Functions inherited from Serialize | |
virtual | ~Serialize ()=default |
virtual bool | canSerialize () const =0 |
virtual bool | load (const SerializedItem &item)=0 |
virtual bool | save (SerializedItem &item) const =0 |
Protected Member Functions | |
void | addColumn (const DataFactory &factory, const QString &name, const QString &longName, const QStringList &units) |
Each record in the collection of data records contains actual data indexed by the column's names. DataTable supports XML serialisation. The primary intention of this class is to support table-like structure of Workspace-supported data types. The underlying data entries are therefore stored in DataObject and may not be optimised for memory when it is used to store large data sets of simple types such as numbers and strings. For those simpler but large data sets, the users might want to consider using ArrayNd.
DataTable | ( | ) |
Default constructor.
|
overridedefault |
|
protected |
|
inline |
name | The column name. |
longName | The column long name. |
units | Optional. The list of units associated with this column. |
This is an overloaded function.
|
inline |
name | The column name. |
units | Optional. The list of units associated with this column. |
Add a column to the DataTable. This function throws an exception if there is any error, for example: a column with name name already exists.
int appendRecord | ( | ) |
Append a record to the end of the data records.
|
overridevirtual |
void clear | ( | ) |
Clear the data and the structure of the table (its columns and meta data).
void clearData | ( | ) |
Clear the data but preserve the structure of the table (its columns and meta data).
DataTableColumn column | ( | const QString & | name | ) | const |
name | The name of the column. |
|
inline |
index | The record index. |
name | The column name. |
This function provides access to the data entry located at record index index and at column name. This function throws an exception if there is any error, for example: out-of-ranged index, inexisting column, etc.
|
inline |
index | The record index. |
name | The column name. |
This is an overloaded function.
|
inline |
name | The column name. |
This function provides access to the default data for column name. This function throws an exception if there is any error, for example: out-of-ranged index, inexisting column, etc.
|
inline |
name | The column name. |
This is an overloaded function.
QStringList getColumnsName | ( | ) | const |
DataObject & getDataObject | ( | int | index, |
const QString & | name | ||
) |
index | The record index. |
name | The column name. |
This function provides access to the data entry located at record index index and at column name. This function throws an exception if there is any error, for example: out-of-ranged index, inexisting column, etc.
const DataObject & getDataObject | ( | int | index, |
const QString & | name | ||
) | const |
index | The record index. |
name | The column name. |
This is an overloaded function.
void insertRecord | ( | int | index | ) |
index | The position at which the new record will be inserted. |
Insert a new record at position index. This function throws an exception if there is any error, for example: out-of-ranged index.
|
overridevirtual |
item | The SerializedItem to read from. |
Read item into DataTable.
Implements Serialize.
int numRecords | ( | ) | const |
void removeColumn | ( | const QString & | name | ) |
name | The name of the column to remove. |
Remove a column from the DataTable. This function throws an exception if there an error, for example when user tries to remove an inexisting column.
void removeRecord | ( | int | index | ) |
index | The position at which the record will be deleted. |
Delete a record at position index. This function throws an exception if there is any error, for example: out-of-ranged index.
|
overridevirtual |
item | The SerializedItem to write into. |
Write the content of DataTable to item.
Implements Serialize.
void swapRecords | ( | int | index1, |
int | index2 | ||
) |
index1 | The position of one record to be swapped. |
index2 | The position of another record to be swapped with. |
Swap the records at positions index1 and index2. This function throws an exception if there is any error, for example: out-of-ranged indices.