ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev++.h
(Generate patch)

Comparing libev/ev++.h (file contents):
Revision 1.18 by root, Tue Dec 11 03:18:33 2007 UTC vs.
Revision 1.19 by root, Fri Dec 14 17:47:52 2007 UTC

26 { 26 {
27 this->data = data; 27 this->data = data;
28 ev_set_cb (static_cast<ev_watcher *>(this), cb); 28 ev_set_cb (static_cast<ev_watcher *>(this), cb);
29 } 29 }
30 30
31 // method callback
31 template<class K, void (K::*method)(watcher &w, int)> 32 template<class K, void (K::*method)(watcher &w, int)>
32 void set (K *object) 33 void set (K *object)
33 { 34 {
34 set_ (object, method_thunk<K, method>); 35 set_ (object, method_thunk<K, method>);
35 } 36 }
39 { 40 {
40 K *obj = static_cast<K *>(w->data); 41 K *obj = static_cast<K *>(w->data);
41 (obj->*method) (*static_cast<watcher *>(w), revents); 42 (obj->*method) (*static_cast<watcher *>(w), revents);
42 } 43 }
43 44
45 // const method callback
44 template<class K, void (K::*method)(watcher &w, int) const> 46 template<class K, void (K::*method)(watcher &w, int) const>
45 void set (const K *object) 47 void set (const K *object)
46 { 48 {
47 set_ (object, const_method_thunk<K, method>); 49 set_ (object, const_method_thunk<K, method>);
48 } 50 }
52 { 54 {
53 K *obj = static_cast<K *>(w->data); 55 K *obj = static_cast<K *>(w->data);
54 (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents); 56 (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents);
55 } 57 }
56 58
59 // function callback
57 template<void (*function)(watcher &w, int)> 60 template<void (*function)(watcher &w, int)>
58 void set (void *data = 0) 61 void set (void *data = 0)
59 { 62 {
60 set_ (data, function_thunk<function>); 63 set_ (data, function_thunk<function>);
61 } 64 }
62 65
63 template<void (*function)(watcher &w, int)> 66 template<void (*function)(watcher &w, int)>
64 static void function_thunk (EV_P_ ev_watcher *w, int revents) 67 static void function_thunk (EV_P_ ev_watcher *w, int revents)
65 { 68 {
66 function (*static_cast<watcher *>(w), revents); 69 function (*static_cast<watcher *>(w), revents);
70 }
71
72 // simple callback
73 template<class K, void (K::*method)()>
74 void set (K *object)
75 {
76 set_ (object, method_noargs_thunk<K, method>);
77 }
78
79 template<class K, void (K::*method)()>
80 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
81 {
82 K *obj = static_cast<K *>(w->data);
83 (obj->*method) ();
67 } 84 }
68 85
69 void operator ()(int events = EV_UNDEF) 86 void operator ()(int events = EV_UNDEF)
70 { 87 {
71 return ev_cb (static_cast<ev_watcher *>(this)) 88 return ev_cb (static_cast<ev_watcher *>(this))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines