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