|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
#include <navigation.hpp>
Public Types | |
| using | RouteParams = std::unordered_map<std::string, std::string> |
| Param map captured from a route pattern (e.g. {id}). | |
| using | RouteFactory = std::function<std::shared_ptr<ViewModel>(const RouteParams&)> |
Public Member Functions | |
| Navigator ()=default | |
| ~Navigator () | |
| Navigator (const Navigator &)=delete | |
| Navigator & | operator= (const Navigator &)=delete |
| template<typename VM, typename... Args> requires std::derived_from<VM, ViewModel> | |
| std::shared_ptr< VM > | push (Args &&... args) |
| template<typename VM, typename... Args> requires std::derived_from<VM, ViewModel> | |
| std::shared_ptr< VM > | replace (Args &&... args) |
| void | push (std::shared_ptr< ViewModel > vm, Presentation kind=Presentation::Push) |
| Push (Presentation::Push). | |
| void | replace (std::shared_ptr< ViewModel > vm) |
| Replace the topmost entry (in place). | |
| template<typename R, typename VM, typename... Args> requires std::derived_from<VM, ViewModel> | |
| std::shared_future< std::optional< R > > | push_for_result (Args &&... args) |
| N-2: push a child entry that will eventually return a typed result R to the caller. | |
| template<typename R> | |
| std::shared_future< std::optional< R > > | push_for_result (std::shared_ptr< ViewModel > vm, Presentation kind=Presentation::Push) |
| template<typename R> | |
| bool | dismiss_with (R result) |
| N-2: dismiss the topmost entry with a typed result. | |
| bool | pop () |
| Pop the topmost entry. | |
| bool | dismiss_modal () |
| N-1: dismiss the topmost MODAL entry. | |
| void | pop_to_root () |
| Pop until only one Push entry remains. | |
| void | clear () |
| bool | empty () const noexcept |
| std::size_t | size () const noexcept |
| std::shared_ptr< ViewModel > | at (std::size_t i) const |
| aria::async::CancellationToken | top_token () const |
| Topmost entry's cancellation token. | |
| Presentation | top_presentation () const |
| Topmost entry's presentation kind. | |
| void | register_route (std::string pattern, RouteFactory factory) |
| Register a route pattern. | |
| bool | route (std::string_view path, RouteOptions opts={}) |
| Resolve path against registered patterns. | |
Public Attributes | |
| Property< std::shared_ptr< ViewModel > > | current {nullptr} |
| Topmost entry's VM, or nullptr if the stack is empty. | |
| Property< std::size_t > | depth {0} |
| Total stack depth (modals included). | |
| using aria::binding::Navigator::RouteParams = std::unordered_map<std::string, std::string> |
Param map captured from a route pattern (e.g. {id}).
| using aria::binding::Navigator::RouteFactory = std::function<std::shared_ptr<ViewModel>(const RouteParams&)> |
|
default |
|
inline |
|
delete |
|
inline |
|
inline |
|
inline |
Push (Presentation::Push).
Activates the new entry and deactivates the previous topmost.
|
inline |
Replace the topmost entry (in place).
The previous entry is deactivated, its cancellation fires, and any pending push_for_result resolves with std::nullopt.
|
inlinenodiscard |
N-2: push a child entry that will eventually return a typed result R to the caller.
The returned shared_future resolves when the child calls Navigator::dismiss_with<R>(result) or is popped without a value (resolves to std::nullopt).
|
inlinenodiscard |
|
inline |
N-2: dismiss the topmost entry with a typed result.
Equivalent to pop() but propagates result to the awaiting future. If the topmost entry was not created via push_for_result<R> the result is discarded (matches Android setResult on a non-result-launched activity).
|
inline |
Pop the topmost entry.
Returns false if the stack is empty. Any pending push_for_result resolves with std::nullopt.
|
inline |
N-1: dismiss the topmost MODAL entry.
Returns false if the topmost is not a modal.
|
inline |
Pop until only one Push entry remains.
Modals are popped first, then Push entries; the deepest Push entry is preserved.
|
inline |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscard |
|
inlinenodiscard |
Topmost entry's cancellation token.
Throws if the stack is empty – callers normally take the token immediately after push and stash it.
|
inlinenodiscard |
Topmost entry's presentation kind.
|
inline |
Register a route pattern.
Pattern segments enclosed in {...} capture into RouteParams; everything else is matched literally. Example: "users/{id}" matches "users/42" -> {id: "42"}.
|
inline |
Resolve path against registered patterns.
Returns false if no pattern matches; in that case the navigator is unchanged. Otherwise applies the action prescribed by opts.
Topmost entry's VM, or nullptr if the stack is empty.
| Property<std::size_t> aria::binding::Navigator::depth {0} |
Total stack depth (modals included).