|
DUDS
|
Distributed Update of Data from Something
|
Provides an exclusive lock on a Menu to allow the menu to be changed. More...
#include <MenuAccess.hpp>
Public Member Functions | |
| MenuAccess (const std::shared_ptr< Menu > &m) | |
| Creates a new MenuAccess object to modify the given Menu. More... | |
| MenuAccess (Menu &m) | |
| Creates a new MenuAccess object to modify the given Menu. More... | |
| ~MenuAccess () | |
| Gives up access to the menu. More... | |
| void | append (MenuItemSptr &&mi) const |
| Appends a new item to the end of the menu. More... | |
| void | append (const MenuItemSptr &mi) const |
| Appends a new item to the end of the menu. More... | |
| void | changeEnabledState (std::size_t index, bool en) const |
| Enables or disables an item on the menu. More... | |
| void | changeToggle (std::size_t index, bool state) const |
| Changes the toggle state of an item on the menu to the indicated state. More... | |
| void | changeVisibility (std::size_t index, bool vis) const |
| Changes the visibility of an item on the menu. More... | |
| void | clear () const |
| Removes all items from the menu. More... | |
| void | clearToggle (std::size_t index) const |
| Clears the toggle state of an item on the menu. More... | |
| void | disable (std::size_t index) const |
| Disables an item on the menu. More... | |
| void | enable (std::size_t index) const |
| Enables an item on the menu. More... | |
| bool | haveToggles () const |
| True if the menu has at least one MenuItem that is a toggle. More... | |
| void | hide (std::size_t index) const |
| Hides an item on the menu from view. More... | |
| void | insert (std::size_t index, MenuItemSptr &&mi) const |
| Inserts a new item into the menu. More... | |
| void | insert (std::size_t index, const MenuItemSptr &mi) const |
| Inserts a new item into the menu. More... | |
| const MenuItemSptr & | item (std::size_t index) const |
| Returns the MenuItem object at the given position. More... | |
| const std::string & | label (std::size_t index) const |
| Returns a menu item's currently set label. More... | |
| void | label (std::size_t index, const std::string &label) |
| Changes a menu item's label text. More... | |
| void | remove (const MenuItemSptr &mi) const |
| Removes an item from the menu. More... | |
| void | remove (std::size_t index) const |
| Removes an item from the menu. More... | |
| void | retire () noexcept |
| Gives up access to the menu. More... | |
| void | setToggle (std::size_t index) const |
| Sets the toggle state of an item on the menu. More... | |
| void | show (std::size_t index) const |
| Shows an item on the menu that was hidden. More... | |
| std::size_t | size () const |
| Returns the number of items in the menu. More... | |
| const std::string & | title () const |
| Returns the title of the menu. More... | |
| void | title (const std::string &newTitle) const |
| Change the title of the menu. More... | |
| bool | toggle (std::size_t index) const |
| Toggles the toggle state of an item on the menu. More... | |
| const std::string & | value (std::size_t index) const |
| Returns a menu item's currently set value. More... | |
| void | value (std::size_t index, const std::string &value) |
| Changes a menu item's optional value. More... | |
Private Attributes | |
| Menu * | menu |
| The menu to operate upon. More... | |
Provides an exclusive lock on a Menu to allow the menu to be changed.
The lock is recursive.
MenuItem objects can also modify the menu. They will also obtain an exclusive lock. The initial lock has a notable amount of overhead, while changing the recursive count for each recurive lock and unlock has minimal overhead. As a result, modifying many MenuItem objects will go quicker if a MenuAccess object is first made, even if its functions are not used. Using a MenuAccess object this way also ensures that no other thread can modify or render the menu until the modifications are complete.
Definition at line 32 of file MenuAccess.hpp.
|
inline |
Creates a new MenuAccess object to modify the given Menu.
| m | The menu to access for modifications. |
Definition at line 42 of file MenuAccess.hpp.
|
inline |
Creates a new MenuAccess object to modify the given Menu.
| m | The menu to access for modifications. |
Definition at line 51 of file MenuAccess.hpp.
|
inline |
Gives up access to the menu.
Definition at line 57 of file MenuAccess.hpp.
|
inline |
Appends a new item to the end of the menu.
| mi | The menu item to add. It will be moved into an internal vector. |
| MenuNoItemError | An attempt was made to add nothing. |
Definition at line 112 of file MenuAccess.hpp.
|
inline |
Appends a new item to the end of the menu.
| mi | The menu item to add. |
| MenuNoItemError | An attempt was made to add nothing. |
Definition at line 120 of file MenuAccess.hpp.
|
inline |
Enables or disables an item on the menu.
| index | The index of the menu item to modify. |
| en | True to enable, false to disable. If this is the same as the current enable/disable state, the menu's update index will not change. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 198 of file MenuAccess.hpp.
|
inline |
Changes the toggle state of an item on the menu to the indicated state.
| index | The index of the menu item to modify. |
| state | The new toggle state. If this is the same as the current state, the menu's update index will not change. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
| MenuItemNotAToggle | The MenuItem is not a toggle. |
Definition at line 239 of file MenuAccess.hpp.
Referenced by clearToggle(), and setToggle().
|
inline |
Changes the visibility of an item on the menu.
| index | The index of the menu item to modify. |
| vis | True to make visible, false for invisible. If this is the same as the current visible state, the menu's update index will not change. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 171 of file MenuAccess.hpp.
|
inline |
Removes all items from the menu.
Definition at line 96 of file MenuAccess.hpp.
|
inline |
Clears the toggle state of an item on the menu.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
| MenuItemNotAToggle | The MenuItem is not a toggle. |
Definition at line 250 of file MenuAccess.hpp.
|
inline |
Disables an item on the menu.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 206 of file MenuAccess.hpp.
|
inline |
Enables an item on the menu.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 214 of file MenuAccess.hpp.
|
inline |
True if the menu has at least one MenuItem that is a toggle.
Definition at line 90 of file MenuAccess.hpp.
|
inline |
Hides an item on the menu from view.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 179 of file MenuAccess.hpp.
|
inline |
Inserts a new item into the menu.
| index | The location where the item will go. |
| mi | The menu item to insert. It will be moved into an internal vector. |
| MenuNoItemError | An attempt was made to insert nothing. |
| MenuBoundsError | The insertion location is beyond the bounds of the menu. |
Definition at line 132 of file MenuAccess.hpp.
|
inline |
Inserts a new item into the menu.
| index | The location where the item will go. |
| mi | The menu item to insert. |
| MenuNoItemError | An attempt was made to insert nothing. |
| MenuBoundsError | The insertion location is beyond the bounds of the menu. |
Definition at line 143 of file MenuAccess.hpp.
|
inline |
Returns the MenuItem object at the given position.
| index | The position of the menu item to return. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 104 of file MenuAccess.hpp.
Referenced by changeEnabledState(), changeToggle(), changeVisibility(), label(), toggle(), and value().
|
inline |
Returns a menu item's currently set label.
| index | The index of the menu item to query. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 269 of file MenuAccess.hpp.
|
inline |
Changes a menu item's label text.
| index | The index of the menu item to modify. |
| label | The new label to use. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 278 of file MenuAccess.hpp.
|
inline |
Removes an item from the menu.
| mi | The menu item to remove. |
| MenuNoItemError | An attempt was made to remove nothing. |
| MenuItemDoesNotExist | The MenuItem is not in the menu. |
Definition at line 152 of file MenuAccess.hpp.
|
inline |
Removes an item from the menu.
| index | The position of the menu item to remove. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 160 of file MenuAccess.hpp.
|
inlinenoexcept |
Gives up access to the menu.
Definition at line 63 of file MenuAccess.hpp.
Referenced by ~MenuAccess().
|
inline |
Sets the toggle state of an item on the menu.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
| MenuItemNotAToggle | The MenuItem is not a toggle. |
Definition at line 261 of file MenuAccess.hpp.
|
inline |
Shows an item on the menu that was hidden.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 187 of file MenuAccess.hpp.
|
inline |
Returns the number of items in the menu.
Definition at line 84 of file MenuAccess.hpp.
|
inline |
Returns the title of the menu.
Definition at line 71 of file MenuAccess.hpp.
|
inline |
Change the title of the menu.
| newTitle | The new title for the menu. |
Definition at line 78 of file MenuAccess.hpp.
|
inline |
Toggles the toggle state of an item on the menu.
| index | The index of the menu item to modify. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
| MenuItemNotAToggle | The MenuItem is not a toggle. |
Definition at line 226 of file MenuAccess.hpp.
|
inline |
Returns a menu item's currently set value.
The value is optional, so an empty string is a normal valid result.
| index | The index of the menu item to query. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 287 of file MenuAccess.hpp.
|
inline |
Changes a menu item's optional value.
| index | The index of the menu item to modify. |
| value | The new value to store. |
| MenuBoundsError | The index is beyond the bounds of this menu. |
Definition at line 296 of file MenuAccess.hpp.
|
private |
The menu to operate upon.
Definition at line 36 of file MenuAccess.hpp.