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

Provides access to a MenuOutput for rendering. More...

#include <MenuOutputAccess.hpp>

Collaboration diagram for duds::ui::menu::MenuOutputAccess:

Public Member Functions

 MenuOutputAccess (MenuOutput *mov, std::size_t newRange=-1)
 Creates a new MenuOutputAccess object that will provide information on the visible items from the given output view. More...
 
 MenuOutputAccess (MenuOutput &mov, std::size_t newRange=-1)
 Creates a new MenuOutputAccess object that will provide information on the visible items from the given output view. More...
 
 MenuOutputAccess (const MenuOutputSptr &mov, std::size_t newRange=-1)
 Creates a new MenuOutputAccess object that will provide information on the visible items from the given output view. More...
 
 ~MenuOutputAccess ()
 Relinquishes access to the outview's data. More...
 
MenuVisibleList::const_iterator begin () const
 Returns an iterator to the start of the visible menu items. More...
 
bool changed () const
 True if the view has changed since the last access. More...
 
bool empty () const
 Returns true if there are no visible menu items. More...
 
MenuVisibleList::const_iterator end () const
 Returns an iterator to the end of the visible menu items. More...
 
std::size_t firstIndex () const
 Returns the index of the first visible menu item, or -1 for an empty menu. More...
 
bool haveToggles () const
 True if the menu has at least one MenuItem that is a toggle, even if none of the toggles are visible. More...
 
const std::shared_ptr< MenuItem > & item (std::size_t index) const
 Returns the MenuItem object at the given position on the menu, not the position of visible items. More...
 
std::size_t lastIndex () const
 Returns the index of the last visible menu item, or -1 for an empty menu. More...
 
std::size_t maxVisible () const
 Returns the currently set maximum number of visible menu items. More...
 
void maxVisible (std::size_t newRange) const
 Changes the maximum number of visible menu items and causes the visible list to be regenerated. More...
 
const Menumenu () const
 Returns the Menu in use. More...
 
const MenuOutputoutputView () const
 Returns the MenuOutput being accessed. More...
 
void retire () noexcept
 Relinquishes access to the outview's data. More...
 
std::size_t selectedIndex () const
 Returns the index of the currently selected MenuItem from Menu's container. More...
 
const MenuItemselectedItem () const
 Returns the selected MenuItem object. More...
 
const MenuVisibleList::const_iterator & selectedIter () const
 Returns an iterator to the selected menu item. More...
 
std::size_t selectedVisible () const
 Returns the index of the currently selected MenuItem within the list of currently visible items. More...
 
bool showingAll () const
 True if the entire menu is currently visible. More...
 
bool showingFirst () const
 True if the menu's first visible item is one of the currently visible items. More...
 
bool showingLast () const
 True if the menu's last visible item is one of the currently visible items. More...
 
std::size_t size () const
 Returns the number of visible menu items. More...
 

Private Attributes

friend MenuOutput
 
MenuOutputoutview
 The output view being accessed. More...
 
MenuVisibleList::const_iterator seliter
 An iterator to the selected item. More...
 
Menuviewmenu
 The menu used by the view. More...
 

Detailed Description

Provides access to a MenuOutput for rendering.

Input processing in the MenuView may occur during this object's constructor, which may cause a MenuItem's chose() function to be called.

This will acquire a shared lock on the associated Menu and MenuView objects that are released when this object is destroyed or retire() is called. It will also get an exclusive lock on the MenuOutput during the constructor. None of these locks are recursive; a thread must not have multiple MenuOutputAccess objects from the same MenuOutput on the stack at the same time.

Author
Jeff Jackowski

Definition at line 29 of file MenuOutputAccess.hpp.

Constructor & Destructor Documentation

◆ MenuOutputAccess() [1/3]

duds::ui::menu::MenuOutputAccess::MenuOutputAccess ( MenuOutput mov,
std::size_t  newRange = -1 
)

Creates a new MenuOutputAccess object that will provide information on the visible items from the given output view.

Parameters
movThe output view to use.
newRangeThe number of menu items that can be displayed, or -1 to not change the range.

Definition at line 14 of file MenuOutputAccess.cpp.

◆ MenuOutputAccess() [2/3]

duds::ui::menu::MenuOutputAccess::MenuOutputAccess ( MenuOutput mov,
std::size_t  newRange = -1 
)
inline

Creates a new MenuOutputAccess object that will provide information on the visible items from the given output view.

Parameters
movThe output view to use.
newRangeThe number of menu items that can be displayed, or -1 to not change the range.

Definition at line 59 of file MenuOutputAccess.hpp.

◆ MenuOutputAccess() [3/3]

duds::ui::menu::MenuOutputAccess::MenuOutputAccess ( const MenuOutputSptr mov,
std::size_t  newRange = -1 
)
inline

Creates a new MenuOutputAccess object that will provide information on the visible items from the given output view.

Parameters
movThe output view to use.
newRangeThe number of menu items that can be displayed, or -1 to not change the range.

Definition at line 68 of file MenuOutputAccess.hpp.

◆ ~MenuOutputAccess()

duds::ui::menu::MenuOutputAccess::~MenuOutputAccess ( )
inline

Relinquishes access to the outview's data.

Definition at line 75 of file MenuOutputAccess.hpp.

Member Function Documentation

◆ begin()

MenuVisibleList::const_iterator duds::ui::menu::MenuOutputAccess::begin ( ) const
inline

Returns an iterator to the start of the visible menu items.

Warning
The iterator must be considered invalid after this access object has been retired or destructed. Further use of the iterator may appear to work, but will introduce race conditions that may cause spurious failures.

Definition at line 158 of file MenuOutputAccess.hpp.

◆ changed()

bool duds::ui::menu::MenuOutputAccess::changed ( ) const
inline

True if the view has changed since the last access.

Definition at line 117 of file MenuOutputAccess.hpp.

◆ empty()

bool duds::ui::menu::MenuOutputAccess::empty ( ) const
inline

Returns true if there are no visible menu items.

This may be true even when the menu has items.

Definition at line 148 of file MenuOutputAccess.hpp.

◆ end()

MenuVisibleList::const_iterator duds::ui::menu::MenuOutputAccess::end ( ) const
inline

Returns an iterator to the end of the visible menu items.

As with regular C++ containers, this iterator cannot be dereferenced.

Warning
The iterator must be considered invalid after this access object has been retired or destructed. Further use of the iterator may appear to work, but will introduce race conditions that may cause spurious failures.

Definition at line 169 of file MenuOutputAccess.hpp.

◆ firstIndex()

std::size_t duds::ui::menu::MenuOutputAccess::firstIndex ( ) const
inline

Returns the index of the first visible menu item, or -1 for an empty menu.

Definition at line 212 of file MenuOutputAccess.hpp.

◆ haveToggles()

bool duds::ui::menu::MenuOutputAccess::haveToggles ( ) const
inline

True if the menu has at least one MenuItem that is a toggle, even if none of the toggles are visible.

Room should be left on the rendered menu for toggles if the menu has toggles.

Definition at line 134 of file MenuOutputAccess.hpp.

◆ item()

const std::shared_ptr<MenuItem>& duds::ui::menu::MenuOutputAccess::item ( std::size_t  index) const
inline

Returns the MenuItem object at the given position on the menu, not the position of visible items.

Items that are not visible may be requested.

Parameters
indexThe position of the menu item to return.
Exceptions
MenuBoundsErrorThe index is beyond the bounds of this menu.

Definition at line 126 of file MenuOutputAccess.hpp.

◆ lastIndex()

std::size_t duds::ui::menu::MenuOutputAccess::lastIndex ( ) const
inline

Returns the index of the last visible menu item, or -1 for an empty menu.

Definition at line 218 of file MenuOutputAccess.hpp.

◆ maxVisible() [1/2]

std::size_t duds::ui::menu::MenuOutputAccess::maxVisible ( ) const
inline

Returns the currently set maximum number of visible menu items.

Definition at line 97 of file MenuOutputAccess.hpp.

Referenced by duds::ui::menu::renderers::BppMenuRenderer::render().

◆ maxVisible() [2/2]

void duds::ui::menu::MenuOutputAccess::maxVisible ( std::size_t  newRange) const
inline

Changes the maximum number of visible menu items and causes the visible list to be regenerated.

Since the visible list is generated as part of constructing this object, it is best to tell the constructor of any change in the number of visible items. If the number of visible items does not change, the list will not be regenerated.

Warning
Any visible list iterators obtained from other member functions must be considered invalid immediately following a call to this function.
Parameters
newRangeThe number of menu items that can be displayed.

Definition at line 111 of file MenuOutputAccess.hpp.

◆ menu()

const Menu* duds::ui::menu::MenuOutputAccess::menu ( ) const
inline

Returns the Menu in use.

Definition at line 85 of file MenuOutputAccess.hpp.

◆ outputView()

const MenuOutput* duds::ui::menu::MenuOutputAccess::outputView ( ) const
inline

Returns the MenuOutput being accessed.

Definition at line 91 of file MenuOutputAccess.hpp.

◆ retire()

void duds::ui::menu::MenuOutputAccess::retire ( )
noexcept

Relinquishes access to the outview's data.

Definition at line 27 of file MenuOutputAccess.cpp.

Referenced by ~MenuOutputAccess().

◆ selectedIndex()

std::size_t duds::ui::menu::MenuOutputAccess::selectedIndex ( ) const
inline

Returns the index of the currently selected MenuItem from Menu's container.

This is not the position within the visible items; it is the position within all items for the menu. If the menu is empty, this value should not be used.

Definition at line 196 of file MenuOutputAccess.hpp.

◆ selectedItem()

const MenuItem& duds::ui::menu::MenuOutputAccess::selectedItem ( ) const
inline

Returns the selected MenuItem object.

Definition at line 187 of file MenuOutputAccess.hpp.

◆ selectedIter()

const MenuVisibleList::const_iterator& duds::ui::menu::MenuOutputAccess::selectedIter ( ) const
inline

Returns an iterator to the selected menu item.

The iterator may be the same as end() if there is no selected item, but this should only be true for empty menus.

Warning
The iterator must be considered invalid after this access object has been retired or destructed. Further use of the iterator may appear to work, but will introduce race conditions that may cause spurious failures.

Definition at line 181 of file MenuOutputAccess.hpp.

◆ selectedVisible()

std::size_t duds::ui::menu::MenuOutputAccess::selectedVisible ( ) const
inline

Returns the index of the currently selected MenuItem within the list of currently visible items.

This must only be used by rendering code; menu operations requiring the selected index must use selected() instead. If the menu has no visible items (empty() is true), this value should not be used.

Definition at line 206 of file MenuOutputAccess.hpp.

Referenced by duds::ui::menu::renderers::BppMenuRenderer::render().

◆ showingAll()

bool duds::ui::menu::MenuOutputAccess::showingAll ( ) const
inline

True if the entire menu is currently visible.

Definition at line 238 of file MenuOutputAccess.hpp.

Referenced by duds::ui::menu::renderers::BppMenuRenderer::render().

◆ showingFirst()

bool duds::ui::menu::MenuOutputAccess::showingFirst ( ) const
inline

True if the menu's first visible item is one of the currently visible items.

Definition at line 225 of file MenuOutputAccess.hpp.

◆ showingLast()

bool duds::ui::menu::MenuOutputAccess::showingLast ( ) const
inline

True if the menu's last visible item is one of the currently visible items.

Definition at line 232 of file MenuOutputAccess.hpp.

Referenced by duds::ui::menu::renderers::BppMenuRenderer::render().

◆ size()

std::size_t duds::ui::menu::MenuOutputAccess::size ( ) const
inline

Returns the number of visible menu items.

This may be smaller than the maximum number of items that can be displayed.

Definition at line 141 of file MenuOutputAccess.hpp.

Referenced by duds::ui::menu::renderers::BppMenuRenderer::render().

Member Data Documentation

◆ MenuOutput

friend duds::ui::menu::MenuOutputAccess::MenuOutput
private

Definition at line 42 of file MenuOutputAccess.hpp.

◆ outview

MenuOutput* duds::ui::menu::MenuOutputAccess::outview
private

The output view being accessed.

Definition at line 33 of file MenuOutputAccess.hpp.

Referenced by MenuOutputAccess(), outputView(), and retire().

◆ seliter

MenuVisibleList::const_iterator duds::ui::menu::MenuOutputAccess::seliter
private

An iterator to the selected item.

Definition at line 41 of file MenuOutputAccess.hpp.

Referenced by MenuOutputAccess().

◆ viewmenu

Menu* duds::ui::menu::MenuOutputAccess::viewmenu
private

The menu used by the view.

Definition at line 37 of file MenuOutputAccess.hpp.

Referenced by menu(), MenuOutputAccess(), and retire().


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