python object refcount debugging code second try
[vuplus_dvbapp] / lib / actions / action.h
1 #ifndef __lib_driver_action_h
2 #define __lib_driver_action_h
3
4 #include <lib/base/object.h>
5
6                 /* avoid warnigs :) */
7 #include <features.h>
8 #undef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 200112L
10 #include <lib/python/python.h>
11 #include <string>
12 #include <map>
13
14 class eWidget;
15
16 class eActionMap: public iObject
17 {
18 DECLARE_REF(eActionMap);
19 #ifdef SWIG
20         eActionMap();
21         ~eActionMap();
22 #endif
23 public:
24 #ifndef SWIG
25         eActionMap();
26         ~eActionMap();
27         void bindAction(const std::string &context, int priority, int id, eWidget *widget);
28         void unbindAction(eWidget *widget, int id);
29 #endif
30
31         void bindAction(const std::string &context, int priority, SWIG_PYOBJECT(ePyObject) function);
32         void unbindAction(const std::string &context, SWIG_PYOBJECT(ePyObject) function);
33         
34         void bindKey(const std::string &device, int key, int flags, const std::string &context, const std::string &action);
35         
36         void keyPressed(const std::string &device, int key, int flags);
37         
38         static RESULT getInstance(ePtr<eActionMap> &ptr);
39 #ifndef SWIG
40 private:
41         static eActionMap *instance;
42         struct eActionBinding
43         {
44 //              eActionContext *m_context;
45                 std::string m_context; // FIXME
46                 
47                 ePyObject m_fnc;
48                 
49                 eWidget *m_widget;
50                 int m_id;
51         };
52         
53         std::multimap<int, eActionBinding> m_bindings;
54
55         friend struct compare_string_keybind_native;
56         struct eNativeKeyBinding
57         {
58                 std::string m_device;
59                 int m_key;
60                 int m_flags;
61                 
62 //              eActionContext *m_context;
63                 int m_action;
64         };
65         
66         std::multimap<std::string, eNativeKeyBinding> m_native_keys;
67         
68         friend struct compare_string_keybind_python;
69         struct ePythonKeyBinding
70         {
71                 std::string m_device;
72                 int m_key;
73                 int m_flags;
74                 
75                 std::string m_action;
76         };
77         
78         std::multimap<std::string, ePythonKeyBinding> m_python_keys;
79 #endif
80 };
81
82 #endif