morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::testing::MemoryHistory Class Referencefinal

A history of routes in memory: the entries, the current one, and back, forward and an edited address. More...

#include <memory_history.hpp>

Inheritance diagram for morph::ui::testing::MemoryHistory:
morph::ui::IHistory

Public Member Functions

 MemoryHistory (std::string initial={})
 A history of one entry.
std::string current () const override
 The route the current entry holds.
void push (std::string const &route) override
 Adds an entry after the current one, dropping any entries forward of it, and makes it current.
void replace (std::string const &route) override
 Replaces the route the current entry holds.
void onPop (std::function< void(std::string const &route)> popped) override
 Sets what is called when the current entry changes from outside: back, forward, or an address the user edited. Replaces the previous callback; an empty one stops the calls.
bool back ()
 Moves to the previous entry, as the browser's back does.
bool forward ()
 Moves to the next entry, as the browser's forward does.
void follow (std::string const &route)
 Follows an address the user typed: adds an entry for route and reports the change, unless it is the current entry's.
std::vector< std::string > const & entries () const noexcept
 Every entry, oldest first.
std::size_t index () const noexcept
 The current entry's index.
Public Member Functions inherited from morph::ui::IHistory
 IHistory (IHistory const &)=delete
IHistory & operator= (IHistory const &)=delete
 IHistory (IHistory &&)=delete
IHistory & operator= (IHistory &&)=delete

Detailed Description

A history of routes in memory: the entries, the current one, and back, forward and an edited address.

Definition at line 19 of file memory_history.hpp.

Constructor & Destructor Documentation

◆ MemoryHistory()

morph::ui::testing::MemoryHistory::MemoryHistory ( std::string initial = {})
inlineexplicit

A history of one entry.

Parameters
initialThe route the first entry holds, as a reloaded page or a shared link has it; empty for none.

Definition at line 23 of file memory_history.hpp.

Member Function Documentation

◆ current()

std::string morph::ui::testing::MemoryHistory::current ( ) const
inlinenodiscardoverridevirtual

The route the current entry holds.

Returns
It, or empty when the entry holds none.

Implements morph::ui::IHistory.

Definition at line 25 of file memory_history.hpp.

◆ push()

void morph::ui::testing::MemoryHistory::push ( std::string const & route)
inlineoverridevirtual

Adds an entry after the current one, dropping any entries forward of it, and makes it current.

Parameters
routeThe route it holds.

Implements morph::ui::IHistory.

Definition at line 27 of file memory_history.hpp.

◆ replace()

void morph::ui::testing::MemoryHistory::replace ( std::string const & route)
inlineoverridevirtual

Replaces the route the current entry holds.

Parameters
routeThe route.

Implements morph::ui::IHistory.

Definition at line 33 of file memory_history.hpp.

◆ onPop()

void morph::ui::testing::MemoryHistory::onPop ( std::function< void(std::string const &route)> popped)
inlineoverridevirtual

Sets what is called when the current entry changes from outside: back, forward, or an address the user edited. Replaces the previous callback; an empty one stops the calls.

Parameters
poppedCalled with the new current entry's route, empty when it holds none.

Implements morph::ui::IHistory.

Definition at line 35 of file memory_history.hpp.

◆ back()

bool morph::ui::testing::MemoryHistory::back ( )
inline

Moves to the previous entry, as the browser's back does.

Returns
Whether there was one.

Definition at line 39 of file memory_history.hpp.

◆ forward()

bool morph::ui::testing::MemoryHistory::forward ( )
inline

Moves to the next entry, as the browser's forward does.

Returns
Whether there was one.

Definition at line 50 of file memory_history.hpp.

◆ follow()

void morph::ui::testing::MemoryHistory::follow ( std::string const & route)
inline

Follows an address the user typed: adds an entry for route and reports the change, unless it is the current entry's.

Parameters
routeThe route.

Definition at line 62 of file memory_history.hpp.

◆ entries()

std::vector< std::string > const & morph::ui::testing::MemoryHistory::entries ( ) const
inlinenodiscardnoexcept

Every entry, oldest first.

Returns
They.

Definition at line 72 of file memory_history.hpp.

◆ index()

std::size_t morph::ui::testing::MemoryHistory::index ( ) const
inlinenodiscardnoexcept

The current entry's index.

Returns
It.

Definition at line 76 of file memory_history.hpp.


The documentation for this class was generated from the following file: