GridComputing
Job Management in Grid Computing
Main Page
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
menu.h
Go to the documentation of this file.
1
#ifndef MENU_H_
2
#define MENU_H_
3
4
#include "
utils.h
"
5
#include "
bytebuffer.h
"
6
7
#include <string>
8
#include <vector>
9
#include <algorithm>
10
11
class
Menu
;
12
14
class
ParentNULL
:
public
std::runtime_error
15
{
16
public
:
17
ParentNULL
() : runtime_error(
""
) { }
18
};
19
21
24
class
IMenu
25
{
26
public
:
27
IMenu
(
const
std::string& label,
Menu
* parent = NULL);
28
virtual
~IMenu
() { }
29
virtual
uint32
Print
()
const
= 0;
30
31
const
std::string&
GetLabel
()
const
{
return
_label
; }
32
Menu
*
GetParent
()
const
{
return
_parent
; }
33
void
SetParent
(
Menu
* val) {
_parent
= val; }
34
35
protected
:
36
Menu
*
_parent
;
37
std::string
_label
;
38
};
39
41
44
class
Menu
:
public
IMenu
45
{
46
public
:
47
Menu
(
const
std::string& label,
Menu
* parent =
nullptr
) :
IMenu
(label, parent) { }
48
~Menu
() {
for
(
auto
elem:
_subMenus
)
delete
elem.second; }
49
50
uint32
Print
()
const override
;
51
52
IMenu
*
AddMenu
(
char
indexer,
const
std::string& label);
53
IMenu
*
AddMenuItem
(
char
indexer,
const
std::string& label,
uint32
val);
54
IMenu
*
operator[]
(
char
indexer);
55
IMenu
*
operator[]
(
char
indexer)
const
;
56
IMenu
*
GetLastSubMenu
() {
return
(
_subMenus
.end() - 1)->second; }
57
58
static
Menu
*
Load
(
ByteBuffer
& bb);
59
60
private
:
62
class
Item
:
public
IMenu
63
{
64
public
:
66
Item
(
const
std::string& label,
uint32
val,
Menu
* parent = NULL) :
IMenu
(label, parent),
_value
(val) { }
67
uint32
Print
()
const override
{
return
_value
; }
68
69
private
:
70
uint32
_value
;
71
};
72
73
std::vector<std::pair<char, IMenu*>>
_subMenus
;
74
};
75
76
#endif // MENU_H_
src
menu.h
Generated on Sun Dec 30 2012 14:13:37 for GridComputing by
1.8.2