00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef BUTTONREGISTRY_H
00020 #define BUTTONREGISTRY_H
00021
00022 #include <pandabase.h>
00023
00024 #include "buttonHandle.h"
00025
00026 #include "pvector.h"
00027 #include "pmap.h"
00028 #include <string>
00029
00030
00031
00032
00033
00034
00035
00036
00037 class EXPCL_PANDA ButtonRegistry {
00038 protected:
00039 class EXPCL_PANDA RegistryNode {
00040 public:
00041 INLINE RegistryNode(ButtonHandle handle, const string &name);
00042
00043 ButtonHandle _handle;
00044 string _name;
00045 };
00046
00047 public:
00048 bool register_button(ButtonHandle &button_handle, const string &name,
00049 char ascii_equivalent = '\0');
00050
00051 PUBLISHED:
00052 ButtonHandle get_button(const string &name);
00053 ButtonHandle find_ascii_button(char ascii_equivalent) const;
00054
00055
00056 INLINE static ButtonRegistry *ptr();
00057
00058 public:
00059 INLINE string get_name(ButtonHandle button) const;
00060
00061 void write(ostream &out) const;
00062
00063 private:
00064
00065
00066 ButtonRegistry();
00067
00068 static void init_global_pointer();
00069
00070 RegistryNode *look_up(ButtonHandle button) const;
00071
00072 typedef pvector<RegistryNode *> HandleRegistry;
00073 HandleRegistry _handle_registry;
00074
00075 typedef pmap<string, RegistryNode *> NameRegistry;
00076 NameRegistry _name_registry;
00077
00078 static ButtonRegistry *_global_pointer;
00079 };
00080
00081 #include "buttonRegistry.I"
00082
00083 #endif