A DataSource over rows held in memory, for tests, servers and sources that cannot share their own storage.
More...
#include <data_source.hpp>
|
| | VectorSource (std::vector< ColumnInfo > columns) |
| | Constructs an empty source with columns.
|
| std::span< ColumnInfo const > | columns () const override |
| | The table's columns.
|
| std::shared_ptr< RowSnapshot const > | snapshot () const override |
| | The current rows; a pointer copy.
|
| std::shared_ptr< TableSnapshot const > const & | tableSnapshot () const noexcept |
| | The current rows, typed.
|
| void | subscribe (ChangeListener &listener) override |
| | Registers listener.
|
| void | unsubscribe (ChangeListener &listener) override |
| | Removes listener; safe from inside a notification.
|
| void | setRows (std::vector< RowId > ids, std::vector< std::vector< Cell > > rows, std::optional< std::vector< ColumnInfo > > columns=std::nullopt) |
| | Replaces every row (and optionally the columns), then notifies Reset.
|
| void | updateRow (std::size_t row, std::vector< Cell > cells) |
| | Replaces one row's cells, then notifies Updated.
|
| bool | patchRow (RowId const &key, std::vector< Cell > cells) override |
| | Replaces the cells of the row keyed id, then notifies Updated.
|
| void | insertRow (std::size_t row, RowId key, std::vector< Cell > cells) |
| | Inserts a row before row, then notifies Inserted.
|
| void | removeRow (std::size_t row) |
| | Removes row row, then notifies Removed.
|
| std::optional< std::size_t > | indexOf (RowId const &key) const |
| | The index of the row keyed id.
|
A DataSource over rows held in memory, for tests, servers and sources that cannot share their own storage.
Definition at line 811 of file data_source.hpp.
◆ VectorSource()
| morph::table::VectorSource::VectorSource |
( |
std::vector< ColumnInfo > | columns | ) |
|
|
inlineexplicit |
Constructs an empty source with columns.
- Parameters
-
| columns | The table's columns. |
Definition at line 815 of file data_source.hpp.
◆ columns()
| std::span< ColumnInfo const > morph::table::VectorSource::columns |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
◆ snapshot()
| std::shared_ptr< RowSnapshot const > morph::table::VectorSource::snapshot |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
◆ tableSnapshot()
| std::shared_ptr< TableSnapshot const > const & morph::table::VectorSource::tableSnapshot |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
The current rows, typed.
- Returns
- The snapshot.
Definition at line 828 of file data_source.hpp.
◆ subscribe()
| void morph::table::VectorSource::subscribe |
( |
ChangeListener & | listener | ) |
|
|
inlineoverridevirtual |
◆ unsubscribe()
| void morph::table::VectorSource::unsubscribe |
( |
ChangeListener & | listener | ) |
|
|
inlineoverridevirtual |
◆ setRows()
| void morph::table::VectorSource::setRows |
( |
std::vector< RowId > | ids, |
|
|
std::vector< std::vector< Cell > > | rows, |
|
|
std::optional< std::vector< ColumnInfo > > | columns = std::nullopt ) |
|
inline |
Replaces every row (and optionally the columns), then notifies Reset.
- Parameters
-
| ids | The rows' keys. |
| rows | The rows' cells. |
| columns | New columns, or nothing to keep the current ones. |
Definition at line 842 of file data_source.hpp.
◆ updateRow()
| void morph::table::VectorSource::updateRow |
( |
std::size_t | row, |
|
|
std::vector< Cell > | cells ) |
|
inline |
Replaces one row's cells, then notifies Updated.
- Parameters
-
| row | Row index. |
| cells | The new cells. |
Definition at line 855 of file data_source.hpp.
◆ patchRow()
| bool morph::table::VectorSource::patchRow |
( |
RowId const & | key, |
|
|
std::vector< Cell > | cells ) |
|
inlineoverridevirtual |
Replaces the cells of the row keyed id, then notifies Updated.
- Parameters
-
| key | The row's key. |
| cells | The new cells. |
- Returns
- false when no row has that key.
Implements morph::table::RowPatcher.
Definition at line 864 of file data_source.hpp.
◆ insertRow()
| void morph::table::VectorSource::insertRow |
( |
std::size_t | row, |
|
|
RowId | key, |
|
|
std::vector< Cell > | cells ) |
|
inline |
Inserts a row before row, then notifies Inserted.
- Parameters
-
| row | Insert position. |
| key | The new row's key. |
| cells | The new row's cells. |
Definition at line 877 of file data_source.hpp.
◆ removeRow()
| void morph::table::VectorSource::removeRow |
( |
std::size_t | row | ) |
|
|
inline |
Removes row row, then notifies Removed.
- Parameters
-
Definition at line 885 of file data_source.hpp.
◆ indexOf()
| std::optional< std::size_t > morph::table::VectorSource::indexOf |
( |
RowId const & | key | ) |
const |
|
inlinenodiscard |
The index of the row keyed id.
- Parameters
-
- Returns
- Its row index, or nothing.
Definition at line 894 of file data_source.hpp.
The documentation for this class was generated from the following file: