|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Sorts, filters and maps the view of one table. More...
#include <engine.hpp>
Public Member Functions | |
| Engine (std::shared_ptr< DataSource > source, EngineOptions options={}) | |
| Builds the engine; the initial view is every row in source order. | |
| Engine (Engine const &)=delete | |
| Engine & | operator= (Engine const &)=delete |
| Engine (Engine &&)=delete | |
| Engine & | operator= (Engine &&)=delete |
| ~Engine () override | |
| Stops a running job and unsubscribes from the source. | |
| std::expected< void, TableError > | setSort (SortChain chain) |
| Sets the sort chain; an empty chain is source order. | |
| std::expected< void, TableError > | setFilter (FilterSpec spec) |
| Sets the filter. | |
| SortChain const & | sort () const noexcept |
| The current sort chain. | |
| FilterSpec const & | filter () const noexcept |
| The current filter. | |
| std::span< ColumnInfo const > | columns () const noexcept |
| The columns of the applied view: what cellAt indexes. A reset that changes the columns changes them when its view is applied, with a Reset change. | |
| std::size_t | viewRowCount () const noexcept |
| Rows in the view. | |
| std::size_t | sourceRowCount () const |
| Rows in the source the view was computed from. | |
| std::optional< std::size_t > | sourceRowOf (std::size_t viewRow) const |
| The source row shown at a view row. | |
| std::optional< std::size_t > | viewRowOf (std::size_t sourceRow) const |
| The view row showing a source row. | |
| RowId | rowIdAt (std::size_t viewRow) const |
| The key of the row at a view row. | |
| std::optional< std::size_t > | viewRowOfKey (RowId const &key) const |
The view row of the row keyed id. | |
| Cell | cellAt (std::size_t viewRow, std::size_t column) const |
| One cell of the view. | |
| std::span< std::uint32_t const > | view () const noexcept |
| The view as source rows. | |
| std::shared_ptr< RowSnapshot const > const & | viewSnapshot () const noexcept |
| The snapshot the view's rows index. | |
| bool | pending () const noexcept |
| Whether a computation is in flight. | |
| void | onViewChange (std::function< void(ViewChange const &)> handler) |
| Sets the receiver of view changes, called on the owner after the view changed. | |
| void | onPending (std::function< void(bool)> handler) |
| Sets the receiver of pending() changes. | |
| void | onError (std::function< void(TableError const &)> handler) |
| Sets the receiver of errors no call could return: an injected service that threw in a job that did not run inside the call that asked for it. The sort and filter go back to those of the view shown. | |
| EngineStats const & | stats () const noexcept |
| Counters. | |
| void | beginEdit (RowId const &key) |
| Marks a row as being edited: with Deferred reorder it keeps its place through updates until endEdit. | |
| void | endEdit (RowId const &key) |
| Ends an edit; a held row moves to its sorted place now. | |
| void | settleNow () |
| Releases every deferred row not being edited, as the settle interval does. | |
| std::vector< RowId > | heldRows () const |
| Rows currently held in place by Deferred reorder. | |
Sorts, filters and maps the view of one table.
Owner-affine; see the file comment for how it executes. Holds a shared reference to its source and subscribes to its changes for its lifetime.
Definition at line 661 of file engine.hpp.
|
inlineexplicit |
Builds the engine; the initial view is every row in source order.
| source | The rows. Must not be null. |
| options | How the engine runs. |
Definition at line 666 of file engine.hpp.
|
inlineoverride |
Stops a running job and unsubscribes from the source.
Definition at line 686 of file engine.hpp.
|
inline |
Sets the sort chain; an empty chain is source order.
Keys are checked against the source's latest columns, which columns() shows once the view computed with them is applied.
| chain | The keys, most significant first. |
Definition at line 699 of file engine.hpp.
|
inline |
Sets the filter.
| spec | The filter; an empty spec shows every row. |
Definition at line 717 of file engine.hpp.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
The columns of the applied view: what cellAt indexes. A reset that changes the columns changes them when its view is applied, with a Reset change.
Definition at line 739 of file engine.hpp.
|
inlinenodiscardnoexcept |
|
inlinenodiscard |
Rows in the source the view was computed from.
Definition at line 747 of file engine.hpp.
|
inlinenodiscard |
The source row shown at a view row.
| viewRow | View row index. |
Definition at line 752 of file engine.hpp.
|
inlinenodiscard |
The view row showing a source row.
| sourceRow | Source row index. |
Definition at line 762 of file engine.hpp.
|
inlinenodiscard |
The key of the row at a view row.
| viewRow | View row index, below viewRowCount(). |
Definition at line 773 of file engine.hpp.
|
inlinenodiscard |
The view row of the row keyed id.
| key | A row key. |
Definition at line 778 of file engine.hpp.
|
inlinenodiscard |
One cell of the view.
| viewRow | View row index, below viewRowCount(). |
| column | Column index into columns(). |
Definition at line 789 of file engine.hpp.
|
inlinenodiscardnoexcept |
The view as source rows.
Definition at line 799 of file engine.hpp.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Whether a computation is in flight.
Definition at line 807 of file engine.hpp.
|
inline |
Sets the receiver of view changes, called on the owner after the view changed.
| handler | The receiver; empty to stop receiving. |
Definition at line 812 of file engine.hpp.
|
inline |
Sets the receiver of pending() changes.
| handler | The receiver; empty to stop receiving. |
Definition at line 816 of file engine.hpp.
|
inline |
Sets the receiver of errors no call could return: an injected service that threw in a job that did not run inside the call that asked for it. The sort and filter go back to those of the view shown.
| handler | The receiver; empty to stop receiving. |
Definition at line 823 of file engine.hpp.
|
inlinenodiscardnoexcept |
|
inline |
Marks a row as being edited: with Deferred reorder it keeps its place through updates until endEdit.
| key | The row's key. |
Definition at line 832 of file engine.hpp.
|
inline |
Ends an edit; a held row moves to its sorted place now.
The commit that ends an edit usually patches the row just before, and that update reaches the engine on a later owner turn: the first job that includes it does not hold the row either, so it moves once rather than waiting for the settle interval.
| key | The row's key. |
Definition at line 841 of file engine.hpp.
|
inline |
Releases every deferred row not being edited, as the settle interval does.
Definition at line 853 of file engine.hpp.
|
inlinenodiscard |
Rows currently held in place by Deferred reorder.
Definition at line 860 of file engine.hpp.