DUDS
Distributed Update of Data from Something
MenuOutputAccess.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2019 Jeff Jackowski
9  */
11 
12 namespace duds { namespace ui { namespace menu {
13 
15  MenuOutput *mov,
16  std::size_t newRange
17 ) : outview(mov) {
18  if (outview) {
19  viewmenu = outview->menu().get();
20  outview->lock(newRange);
21  seliter = outview->items.cend();
22  } else {
23  viewmenu = nullptr;
24  }
25 }
26 
27 void MenuOutputAccess::retire() noexcept {
28  if (viewmenu) {
29  outview->unlock();
30  outview = nullptr;
31  viewmenu = nullptr;
32  }
33 }
34 
35 } } }
MenuVisibleList::const_iterator seliter
An iterator to the selected item.
void retire() noexcept
Relinquishes access to the outview's data.
MenuOutputAccess(MenuOutput *mov, std::size_t newRange=-1)
Creates a new MenuOutputAccess object that will provide information on the visible items from the giv...
MenuVisibleList items
The currently visible menu items.
Definition: MenuOutput.hpp:58
Menu * viewmenu
The menu used by the view.
void unlock()
Informs the MenuView that it has one fewer MenuOutput objects acting upon it, and releases the shared...
Definition: MenuOutput.cpp:56
MenuOutput * outview
The output view being accessed.
void lock(std::size_t newRange)
Handles several tasks to lock and prepare menu data.
Definition: MenuOutput.cpp:39
Compiles a list of visible menu items based on the selected item of a MenuView.
Definition: MenuOutput.hpp:45
const std::shared_ptr< Menu > & menu() const
Returns the Menu used by this output view.
Definition: MenuOutput.cpp:32