API
4.5.1
For C++ developers
|
AbstractDataTable is the base-class of all DataTable_(templated) allowing storage of DataTable_ templated on different types to be stored in a container like std::vector. More...
Public Member Functions | |
AbstractDataTable ()=default | |
AbstractDataTable (const AbstractDataTable &)=default | |
AbstractDataTable (AbstractDataTable &&)=default | |
AbstractDataTable & | operator= (const AbstractDataTable &)=default |
AbstractDataTable & | operator= (AbstractDataTable &&)=default |
virtual std::shared_ptr< AbstractDataTable > | clone () const =0 |
virtual | ~AbstractDataTable ()=default |
virtual unsigned | numComponentsPerElement () const =0 |
Get number of components per element of the DataTable. More... | |
size_t | getNumRows () const |
Get number of rows. More... | |
size_t | getNumColumns () const |
Get number of dependent columns. More... | |
bool | hasColumn (const size_t columnIndex) const |
Check if the table has a column with the given index. More... | |
MetaData accessors/mutators. | |
template<typename Value > | |
void | addTableMetaData (const std::string &key, const Value &value) |
Add key-value pair to the table metadata. More... | |
bool | hasTableMetaDataKey (const std::string &key) const |
Whether or not table metadata for the given key exists. More... | |
template<typename Value > | |
Value | getTableMetaData (const std::string &key) const |
Get table metadata for a given key. More... | |
std::string | getTableMetaDataAsString (const std::string &key) const |
Get table metadata for a given key as a string. More... | |
void | removeTableMetaDataKey (const std::string &key) |
Remove key-value pair associated with the given key from table metadata. More... | |
std::vector< std::string > | getTableMetaDataKeys () const |
Get table metadata keys. More... | |
const TableMetaData & | getTableMetaData () const |
Get metadata associated with the table. More... | |
TableMetaData & | updTableMetaData () |
Update metadata associated with the table. More... | |
const IndependentMetaData & | getIndependentMetaData () const |
Get metadata associated with the independent column. More... | |
void | setIndependentMetaData (const IndependentMetaData &independentMetaData) |
Set metadata associated with the independent column. More... | |
const DependentsMetaData & | getDependentsMetaData () const |
Get metadata associated with the dependent columns. More... | |
void | setDependentsMetaData (const DependentsMetaData &dependentsMetaData) |
Set metadata associated with the dependent columns. More... | |
void | removeDependentsMetaDataForKey (const std::string &key) |
Remove key-value pair associated with the given key from dependents metadata. More... | |
Column-labels related accessors/mutators. | |
Following functions operate on column labels of dependent columns only excluding the independent column. Following are examples on using setColumnLabels(). If you have a sequence of strings, you can pretty much call setColumnLabels() on it. // Simplest way to set column labels is to provide them directly to // setColumnLabels. table.setColumnLabels({"col1", "col2", "col3"}); // if you have a sequence container like std::vector or std::list of // std::string holding column labels, pass the container directly to // setColumnLabels. std::list<std::string> columnLabels{"col1", "col2", "col3"}; table.setColumnLabels(columnLabels); // If you have a sequence container like std::vector or std::list of // std::string holding column labels but you want to use only a subset // of them to set column labels of the table, use iterators like below. std::vector<std::string> columnLabels{"col-not-used1", "col1", "col2", "col3", "col-not-used2"}; table.setColumnLabels(columnLabels.begin() + 1, columnLabels.end() - 1); | |
bool | hasColumnLabels () const |
Does the table have non-zero number of column labels. More... | |
std::vector< std::string > | getColumnLabels () const |
Get column labels. More... | |
const std::string & | getColumnLabel (const size_t columnIndex) const |
Get column label of a given column. More... | |
template<typename InputIt > | |
void | setColumnLabels (InputIt first, InputIt last) |
Set column labels using a pair of iterators. More... | |
template<typename Container > | |
void | setColumnLabels (const Container &columnLabels) |
Set column labels using a sequence container. More... | |
void | setColumnLabels (const std::initializer_list< std::string > &columnLabels) |
Set column labels using a std::initializer_list. More... | |
void | setColumnLabel (const size_t columnIndex, const std::string &columnLabel) |
Set the label for a column. More... | |
size_t | getColumnIndex (const std::string &columnLabel) const |
Get index of a column label. More... | |
bool | hasColumn (const std::string &columnLabel) const |
Check if the table has a column with the given label. More... | |
Public Types | |
typedef ValueArrayDictionary | TableMetaData |
typedef ValueArrayDictionary | DependentsMetaData |
typedef ValueArrayDictionary | IndependentMetaData |
Protected Member Functions | |
void | appendColumnLabel (const std::string &columnLabel) |
Append column-label. More... | |
virtual size_t | implementGetNumRows () const =0 |
Get number of rows. More... | |
virtual size_t | implementGetNumColumns () const =0 |
Get number of columns. More... | |
virtual void | validateIndependentMetaData () const =0 |
Check if metadata for independent column is valid. More... | |
virtual void | validateDependentsMetaData () const =0 |
Check if metadata for dependent column is valid. More... | |
Protected Attributes | |
TableMetaData | _tableMetaData |
DependentsMetaData | _dependentsMetaData |
IndependentMetaData | _independentMetaData |
AbstractDataTable is the base-class of all DataTable_(templated) allowing storage of DataTable_ templated on different types to be stored in a container like std::vector.
DataTable_ represents a matrix and an additional column. The columns of the matrix are dependent columns. The additional column is the independent column. All dependent columns and the independent column can have metadata. AbstractDataTable offers:
This class is abstract and cannot be used directly. Create instances of DataTable_ instead. See DataTable_ for details on usage.
|
default |
|
default |
|
default |
|
virtualdefault |
|
inline |
Add key-value pair to the table metadata.
If using this function from Python/Java/Matlab, use:
where both 'key' and 'value' are strings. The above call translates to C++ as:
Value | Type of the value. This need not be specified explicitly in most cases. It will be deduced automatically. |
KeyExists | If the key provided already exists in table metadata. |
|
protected |
Append column-label.
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendColumn().
|
pure virtual |
Implemented in OpenSim::DataTable_< ETX, ETY >, OpenSim::DataTable_< double, ETY >, OpenSim::DataTable_< double, ET >, OpenSim::DataTable_< double, ValueT >, OpenSim::DataTable_< double, SimTK::Vec3 >, OpenSim::DataTable_< double, SimTK::Rotation >, OpenSim::DataTable_< double, SimTK::Rotation_< double > >, and OpenSim::DataTable_< double, SimTK::Real >.
size_t OpenSim::AbstractDataTable::getColumnIndex | ( | const std::string & | columnLabel | ) | const |
Get index of a column label.
NoColumnLabels | If table has no column labels. |
KeyNotFound | If columnLabel is not found to be label for any column. |
Referenced by OpenSim::TableSource_< ET >::getColumnAtTime(), OpenSim::DataTable_< double, SimTK::Real >::getDependentColumn(), and OpenSim::DataTable_< double, SimTK::Real >::updDependentColumn().
const std::string& OpenSim::AbstractDataTable::getColumnLabel | ( | const size_t | columnIndex | ) | const |
Get column label of a given column.
ColumnIndexOutOfRange | If columnIndex is out of range of number of columns. |
NoColumnLabels | If column labels have not be set for the table. |
std::vector<std::string> OpenSim::AbstractDataTable::getColumnLabels | ( | ) | const |
Get column labels.
NoColumnLabels | If column labels have not be set for the table. |
Referenced by OpenSim::TableReporter_< InputT, ValueT >::clearTable(), OpenSim::TabOpUseAbsoluteStateNames::operate(), OpenSim::DataTable_< double, SimTK::Real >::removeColumn(), OpenSim::DataTable_< double, SimTK::Real >::removeColumnAtIndex(), OpenSim::TableSource_< ET >::setTable_impl(), and OpenSim::DataTable_< double, SimTK::Real >::validateDependentsMetaData().
const DependentsMetaData& OpenSim::AbstractDataTable::getDependentsMetaData | ( | ) | const |
Get metadata associated with the dependent columns.
const IndependentMetaData& OpenSim::AbstractDataTable::getIndependentMetaData | ( | ) | const |
Get metadata associated with the independent column.
size_t OpenSim::AbstractDataTable::getNumColumns | ( | ) | const |
Get number of dependent columns.
Referenced by OpenSim::analyzeMocoTrajectory(), OpenSim::DataTable_< double, SimTK::Real >::isEmpty(), OpenSim::DataTable_< double, SimTK::Real >::removeColumnAtIndex(), and OpenSim::TimeSeriesTable_< SimTK::Vec3 >::trimToIndices().
size_t OpenSim::AbstractDataTable::getNumRows | ( | ) | const |
Get number of rows.
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendColumn(), OpenSim::TableSource_< ET >::getColumnAtTime(), OpenSim::TableSource_< ET >::getRowAtTime(), OpenSim::DataTable_< double, SimTK::Real >::isEmpty(), OpenSim::DataTable_< double, SimTK::Real >::removeRowAtIndex(), OpenSim::TimeSeriesTable_< SimTK::Vec3 >::trim(), and OpenSim::TimeSeriesTable_< SimTK::Vec3 >::trimToIndices().
|
inline |
Get table metadata for a given key.
If using this function from Python/Java/Matlab, use the following table:
C++ | Python / Java / Matlab | Example |
---|---|---|
getTableMetaData<std::string> | getTableMetaDataString | Marker table read from a C3D file could contain quantities DataRate and Units that can be retrieved with this method. |
getTableMetaData<std::vector<SimTK::Matrix_<double>>> | getTableMetaDataVectorMatrix | Forces table read from a C3D file could contain quantities Calibration Matrices, Force Plate Corners and Force Plate Origins that can be retrieved with this method. |
getTableMetaData<std::vector<unsigned>> | getTableMetaDataVectorUnsigned | Forces table read from a C3D file could contain quantity Force Plate Types that can be retrieved with this method |
Value | Type of the value to be retrieved. For example if the metadata contains key-value pair ("sample-rate", 200), this could be specified as 'unsigned'. |
KeyNotFound | If the key provided is not found in table metadata. |
const TableMetaData& OpenSim::AbstractDataTable::getTableMetaData | ( | ) | const |
Get metadata associated with the table.
|
inline |
Get table metadata for a given key as a string.
KeyNotFound | If the key provided is not found in table metadata. |
std::vector<std::string> OpenSim::AbstractDataTable::getTableMetaDataKeys | ( | ) | const |
Get table metadata keys.
bool OpenSim::AbstractDataTable::hasColumn | ( | const std::string & | columnLabel | ) | const |
Check if the table has a column with the given label.
NoColumnLabels | If table has no column labels. |
Referenced by OpenSim::DataTable_< double, SimTK::Real >::appendColumn().
bool OpenSim::AbstractDataTable::hasColumn | ( | const size_t | columnIndex | ) | const |
Check if the table has a column with the given index.
bool OpenSim::AbstractDataTable::hasColumnLabels | ( | ) | const |
Does the table have non-zero number of column labels.
Referenced by OpenSim::TableReporter_< InputT, ValueT >::clearTable().
|
inline |
Whether or not table metadata for the given key exists.
|
protectedpure virtual |
Get number of columns.
Implemented by derived classes.
Implemented in OpenSim::DataTable_< ETX, ETY >, OpenSim::DataTable_< double, ETY >, OpenSim::DataTable_< double, ET >, OpenSim::DataTable_< double, ValueT >, OpenSim::DataTable_< double, SimTK::Vec3 >, OpenSim::DataTable_< double, SimTK::Rotation >, OpenSim::DataTable_< double, SimTK::Rotation_< double > >, and OpenSim::DataTable_< double, SimTK::Real >.
|
protectedpure virtual |
Get number of rows.
Implemented by derived classes.
Implemented in OpenSim::DataTable_< ETX, ETY >, OpenSim::DataTable_< double, ETY >, OpenSim::DataTable_< double, ET >, OpenSim::DataTable_< double, ValueT >, OpenSim::DataTable_< double, SimTK::Vec3 >, OpenSim::DataTable_< double, SimTK::Rotation >, OpenSim::DataTable_< double, SimTK::Rotation_< double > >, and OpenSim::DataTable_< double, SimTK::Real >.
|
pure virtual |
Get number of components per element of the DataTable.
See documentation for DataTable on possible return values.
Implemented in OpenSim::DataTable_< ETX, ETY >, OpenSim::DataTable_< double, ETY >, OpenSim::DataTable_< double, ET >, OpenSim::DataTable_< double, ValueT >, OpenSim::DataTable_< double, SimTK::Vec3 >, OpenSim::DataTable_< double, SimTK::Rotation >, OpenSim::DataTable_< double, SimTK::Rotation_< double > >, and OpenSim::DataTable_< double, SimTK::Real >.
|
default |
|
default |
void OpenSim::AbstractDataTable::removeDependentsMetaDataForKey | ( | const std::string & | key | ) |
Remove key-value pair associated with the given key from dependents metadata.
Referenced by OpenSim::TimeSeriesTable_< SimTK::Vec3 >::TimeSeriesTable_().
void OpenSim::AbstractDataTable::removeTableMetaDataKey | ( | const std::string & | key | ) |
Remove key-value pair associated with the given key from table metadata.
void OpenSim::AbstractDataTable::setColumnLabel | ( | const size_t | columnIndex, |
const std::string & | columnLabel | ||
) |
Set the label for a column.
NoColumnLabels | If table has no column labels. |
ColumnIndexOutOfRange | If columnIndex is out of range for number of columns in the table. |
|
inline |
Set column labels using a pair of iterators.
Example:
first | InputIterator representing the beginning of the sequence of labels. |
last | InputIterator representing the sentinel or one past the end of sequence of labels. |
IncorrectMetaDataLength | If length of the input sequence of labels is incorrect – does not match the number of columns in the table. |
References OpenSim::ValueArray< T >::upd().
Referenced by OpenSim::TableReporter_< InputT, ValueT >::clearTable(), OpenSim::DataTable_< double, SimTK::Real >::DataTable_(), OpenSim::TableReporter_< InputT, ValueT >::extendFinalizeConnections(), OpenSim::TabOpUseAbsoluteStateNames::operate(), and OpenSim::DataTable_< double, SimTK::Real >::removeColumnAtIndex().
|
inline |
Set column labels using a sequence container.
Example:
Container | Any container type (like std::vector, std::list or your own) that supports begin() and end(). Type of the values produced by iterator should be std::string. |
IncorrectMetaDataLength | If length of the input sequence of labels is incorrect – does not match the number of columns in the table. |
void OpenSim::AbstractDataTable::setColumnLabels | ( | const std::initializer_list< std::string > & | columnLabels | ) |
Set column labels using a std::initializer_list.
Example:
IncorrectMetaDataLength | If length of the input sequence of labels is incorrect – does not match the number of columns in the table. |
void OpenSim::AbstractDataTable::setDependentsMetaData | ( | const DependentsMetaData & | dependentsMetaData | ) |
Set metadata associated with the dependent columns.
void OpenSim::AbstractDataTable::setIndependentMetaData | ( | const IndependentMetaData & | independentMetaData | ) |
Set metadata associated with the independent column.
TableMetaData& OpenSim::AbstractDataTable::updTableMetaData | ( | ) |
Update metadata associated with the table.
|
protectedpure virtual |
Check if metadata for dependent column is valid.
Implemented by derived classes.
Implemented in OpenSim::DataTable_< ETX, ETY >, OpenSim::DataTable_< double, ETY >, OpenSim::DataTable_< double, ET >, OpenSim::DataTable_< double, ValueT >, OpenSim::DataTable_< double, SimTK::Vec3 >, OpenSim::DataTable_< double, SimTK::Rotation >, OpenSim::DataTable_< double, SimTK::Rotation_< double > >, and OpenSim::DataTable_< double, SimTK::Real >.
|
protectedpure virtual |
Check if metadata for independent column is valid.
Implemented by derived classes.
Implemented in OpenSim::DataTable_< ETX, ETY >, OpenSim::DataTable_< double, ETY >, OpenSim::DataTable_< double, ET >, OpenSim::DataTable_< double, ValueT >, OpenSim::DataTable_< double, SimTK::Vec3 >, OpenSim::DataTable_< double, SimTK::Rotation >, OpenSim::DataTable_< double, SimTK::Rotation_< double > >, and OpenSim::DataTable_< double, SimTK::Real >.
|
protected |
|
protected |
|
protected |