Pol  Revision:cb584c9
menu.h
Go to the documentation of this file.
1 
7 #ifndef __MENU_H
8 #define __MENU_H
9 
10 #ifndef __CLIB_RAWTYPES_H
11 #include "../clib/rawtypes.h"
12 #endif
13 #include <cstddef>
14 #include <vector>
15 
16 #include "../clib/weakptr.h"
17 
18 namespace Pol
19 {
20 namespace Core
21 {
22 // FIXME these are horribly wasteful. Probably should be using <string> or something.
23 // also, kinda bad for each MenuItem to have a submenu_name, when most won't be submenus...sigh.
24 
25 class MenuItem
26 {
27 public:
28  MenuItem();
29 
30  // memberwise copy is okay for these:
31  // MenuItem( const MenuItem& );
32  // MenuItem& operator=( const MenuItem& );
33 
37  char title[80];
38  char submenu_name[80];
39  unsigned short submenu_id;
40 
41 private: // not implemented
42 };
43 
44 class Menu
45 {
46 public:
47  Menu();
48 
49  // Those are needed to update the weak_ptr_owner
50  Menu( const Menu& );
51  Menu& operator=( const Menu& );
52 
53  unsigned short menu_id;
54  char name[80];
55  char title[80];
56 
57  std::vector<MenuItem> menuitems_;
58  size_t estimateSize() const;
59 
60  static void read_menus();
61  static Menu* find_menu( const char* name );
62  static Menu* find_menu( unsigned short menu_id );
63 
64  weak_ptr<Menu> getWeakPtr() const { return weakptr; }
65 
66 private:
68 };
69 }
70 }
71 #endif
unsigned short submenu_id
Definition: menu.h:39
char title[80]
Definition: menu.h:37
std::vector< MenuItem > menuitems_
Definition: menu.h:57
unsigned short u16
Definition: rawtypes.h:26
unsigned int u32
Definition: rawtypes.h:27
weak_ptr_owner< Menu > weakptr
Definition: menu.h:67
unsigned short menu_id
Definition: menu.h:53
std::string name
Definition: osmod.cpp:943
char submenu_name[80]
Definition: menu.h:38
Definition: berror.cpp:12
weak_ptr< Menu > getWeakPtr() const
Definition: menu.h:64