DUDS
Distributed Update of Data from Something
duds::ui::Path Class Reference

Stores a list of pages the user has visited in the order of the visits. More...

#include <Path.hpp>

Collaboration diagram for duds::ui::Path:

Public Types

typedef std::vector< PageSptrPageStack
 The type used to store the page path. More...
 

Public Member Functions

 Path ()
 Constructs a new empty path. More...
 
 Path (const PageSptr &first)
 Constructs a new path with an initial page. More...
 
bool atEnd () const
 True if the current page is the end of the page sequence. More...
 
bool atStart () const
 True if the current page is the start of the page sequence. More...
 
bool back ()
 Changes the current page to the page that was pushed before the current page. More...
 
PageStack::const_iterator begin () const
 Iterator to the start of the page stack. More...
 
void clear ()
 Clears out the stack of all pages. More...
 
void clearPastCurrent ()
 Clears all pages on the stack that are forward of the current page. More...
 
PageStack::const_iterator current () const
 Iterator to the current page. More...
 
const PageSptrcurrentPage () const
 Returns the current page. More...
 
bool empty () const
 Returns true if the page stack is empty. More...
 
PageStack::const_iterator end () const
 Iterator to the end of the page stack. More...
 
bool forward ()
 Changes the current page to the page that was pushed after the current page. More...
 
bool move (int steps)
 Changes the current page by the given amount. More...
 
void push (const PageSptr &page)
 Pushes a new page after the current page. More...
 
void push (PageSptr &&page)
 Pushes a new page after the current page. More...
 
PageStack::const_reverse_iterator rbegin () const
 Reverse iterator to the end of the page stack. More...
 
PageStack::const_reverse_iterator rcurrent () const
 Reverse iterator to the current page. More...
 
PageStack::const_reverse_iterator rend () const
 Reverse iterator to the start of the page stack. More...
 
PageStack::size_type size () const
 Returns the number of pages in the page stack. More...
 

Private Attributes

PageStack pages
 The pages in path order. More...
 
int spot
 Index of the current page. More...
 

Detailed Description

Stores a list of pages the user has visited in the order of the visits.

Note
This is not thread-safe. Not sure if that will be a problem.
Author
Jeff Jackowski
Examples:
bppmenu.cpp.

Definition at line 23 of file Path.hpp.

Member Typedef Documentation

◆ PageStack

typedef std::vector<PageSptr> duds::ui::Path::PageStack

The type used to store the page path.

Definition at line 28 of file Path.hpp.

Constructor & Destructor Documentation

◆ Path() [1/2]

duds::ui::Path::Path ( )
inline

Constructs a new empty path.

Definition at line 42 of file Path.hpp.

◆ Path() [2/2]

duds::ui::Path::Path ( const PageSptr first)

Constructs a new path with an initial page.

Parameters
firstThe first page on the path.

Definition at line 14 of file Path.cpp.

Member Function Documentation

◆ atEnd()

bool duds::ui::Path::atEnd ( ) const
inline

True if the current page is the end of the page sequence.

If no pages have been pushed since construction using Path(), or since the last call to clear(), the result will be false.

Definition at line 104 of file Path.hpp.

◆ atStart()

bool duds::ui::Path::atStart ( ) const
inline

True if the current page is the start of the page sequence.

If no pages have been pushed since construction using Path(), or since the last call to clear(), the result will be false.

Definition at line 96 of file Path.hpp.

◆ back()

bool duds::ui::Path::back ( )
inline

Changes the current page to the page that was pushed before the current page.

If the current page is the first page in the stack, the current page will remain unchanged.

Returns
True if the page changed.
Examples:
bppmenu.cpp.

Definition at line 79 of file Path.hpp.

◆ begin()

PageStack::const_iterator duds::ui::Path::begin ( ) const
inline

Iterator to the start of the page stack.

Definition at line 139 of file Path.hpp.

◆ clear()

void duds::ui::Path::clear ( )

Clears out the stack of all pages.

Definition at line 65 of file Path.cpp.

Referenced by atEnd().

◆ clearPastCurrent()

void duds::ui::Path::clearPastCurrent ( )

Clears all pages on the stack that are forward of the current page.

Postcondition
If !empty(), then atEnd() is true.

Definition at line 70 of file Path.cpp.

Referenced by atEnd().

◆ current()

PageStack::const_iterator duds::ui::Path::current ( ) const
inline

Iterator to the current page.

Precondition
The page stack is not empty.

Definition at line 164 of file Path.hpp.

◆ currentPage()

const PageSptr& duds::ui::Path::currentPage ( ) const
inline

Returns the current page.

Precondition
The page stack is not empty.
Exceptions
std::out_of_rangeThere is no current page; the stack is empty.
Examples:
bppmenu.cpp.

Definition at line 133 of file Path.hpp.

◆ empty()

bool duds::ui::Path::empty ( ) const
inline

Returns true if the page stack is empty.

Definition at line 119 of file Path.hpp.

Referenced by duds::ui::PathStringGenerator::generate().

◆ end()

PageStack::const_iterator duds::ui::Path::end ( ) const
inline

Iterator to the end of the page stack.

Definition at line 151 of file Path.hpp.

◆ forward()

bool duds::ui::Path::forward ( )
inline

Changes the current page to the page that was pushed after the current page.

If the current page is the last page in the stack, the curent page will remain unchanged.

Returns
True if the page changed.
Examples:
bppmenu.cpp.

Definition at line 88 of file Path.hpp.

◆ move()

bool duds::ui::Path::move ( int  steps)

Changes the current page by the given amount.

If the amount would go past the first or last page, the result will be the first or last page without error.

Parameters
stepsThe number of pages to move. A negative value moves backwards, towards the first page. Zero does not change the page.
Returns
True if the page changed.

Definition at line 47 of file Path.cpp.

Referenced by back(), forward(), and Path().

◆ push() [1/2]

void duds::ui::Path::push ( const PageSptr page)

Pushes a new page after the current page.

All pages after the current page prior to the push are removed.

Parameters
pageThe new page.
Postcondition
The new page is now the current page.
Examples:
bppmenu.cpp.

Definition at line 19 of file Path.cpp.

Referenced by Path().

◆ push() [2/2]

void duds::ui::Path::push ( PageSptr &&  page)

Pushes a new page after the current page.

All pages after the current page prior to the push are removed.

Parameters
pageThe new page; its contents will be moved into the internal vector.
Postcondition
The new page is now the current page.

Definition at line 33 of file Path.cpp.

◆ rbegin()

PageStack::const_reverse_iterator duds::ui::Path::rbegin ( ) const
inline

Reverse iterator to the end of the page stack.

Definition at line 145 of file Path.hpp.

Referenced by duds::ui::PathStringGenerator::generate().

◆ rcurrent()

PageStack::const_reverse_iterator duds::ui::Path::rcurrent ( ) const
inline

Reverse iterator to the current page.

Precondition
The page stack is not empty.

Definition at line 171 of file Path.hpp.

Referenced by duds::ui::PathStringGenerator::generate().

◆ rend()

PageStack::const_reverse_iterator duds::ui::Path::rend ( ) const
inline

Reverse iterator to the start of the page stack.

Definition at line 157 of file Path.hpp.

Referenced by duds::ui::PathStringGenerator::generate().

◆ size()

PageStack::size_type duds::ui::Path::size ( ) const
inline

Returns the number of pages in the page stack.

Definition at line 125 of file Path.hpp.

Member Data Documentation

◆ pages

PageStack duds::ui::Path::pages
private

The pages in path order.

Definition at line 33 of file Path.hpp.

Referenced by clear(), clearPastCurrent(), move(), Path(), and push().

◆ spot

int duds::ui::Path::spot
private

Index of the current page.

Definition at line 37 of file Path.hpp.

Referenced by clear(), clearPastCurrent(), current(), move(), Path(), and push().


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