Panda3D
panda
src
putil
buttonRegistry.h
Go to the documentation of this file.
1
/**
2
* PANDA 3D SOFTWARE
3
* Copyright (c) Carnegie Mellon University. All rights reserved.
4
*
5
* All use of this software is subject to the terms of the revised BSD
6
* license. You should have received a copy of this license along
7
* with this source code in a file named "LICENSE."
8
*
9
* @file buttonRegistry.h
10
* @author drose
11
* @date 2000-03-01
12
*/
13
14
#ifndef BUTTONREGISTRY_H
15
#define BUTTONREGISTRY_H
16
17
#include "
pandabase.h
"
18
19
#include "
buttonHandle.h
"
20
21
#include "
pvector.h
"
22
#include "
pmap.h
"
23
24
/**
25
* The ButtonRegistry class maintains all the assigned ButtonHandles in a
26
* given system. There should be only one ButtonRegistry class during the
27
* lifetime of the application.
28
*/
29
class
EXPCL_PANDA_PUTIL
ButtonRegistry
{
30
protected
:
31
class
EXPCL_PANDA_PUTIL RegistryNode {
32
public
:
33
INLINE RegistryNode(
ButtonHandle
handle,
ButtonHandle
alias,
34
const
std::string &name);
35
36
ButtonHandle
_handle;
37
ButtonHandle
_alias;
38
std::string _name;
39
};
40
41
public
:
42
bool
register_button(
ButtonHandle
&button_handle,
const
std::string &name,
43
ButtonHandle
alias = ButtonHandle::none(),
44
char
ascii_equivalent =
'\0'
);
45
46
PUBLISHED:
47
ButtonHandle
get_button(
const
std::string &name);
48
ButtonHandle
find_button(
const
std::string &name);
49
ButtonHandle
find_ascii_button(
char
ascii_equivalent)
const
;
50
51
void
write(std::ostream &out)
const
;
52
53
// ptr() returns the pointer to the global ButtonRegistry object.
54
INLINE
static
ButtonRegistry
*ptr();
55
56
public
:
57
INLINE std::string get_name(
ButtonHandle
button)
const
;
58
INLINE
ButtonHandle
get_alias(
ButtonHandle
button)
const
;
59
60
private
:
61
// The ButtonRegistry class should never be constructed by user code. There
62
// is only one in the universe, and it constructs itself!
63
ButtonRegistry
();
64
65
static
void
init_global_pointer();
66
67
RegistryNode *look_up(
ButtonHandle
button)
const
;
68
69
typedef
pvector<RegistryNode *>
HandleRegistry
;
70
HandleRegistry
_handle_registry;
71
72
typedef
pmap<std::string, RegistryNode *>
NameRegistry
;
73
NameRegistry
_name_registry;
74
75
static
ButtonRegistry
*_global_pointer;
76
};
77
78
#include "
buttonRegistry.I
"
79
80
#endif
buttonRegistry.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector< RegistryNode * >
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap< std::string, RegistryNode * >
ButtonHandle
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition:
buttonHandle.h:26
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
buttonHandle.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ButtonRegistry
The ButtonRegistry class maintains all the assigned ButtonHandles in a given system.
Definition:
buttonRegistry.h:29
Generated on Sat Jan 11 2020 15:15:32 for Panda3D by
1.8.17