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

Comparing libev/ev++.h (file contents):
Revision 1.6 by root, Wed Nov 14 06:08:13 2007 UTC vs.
Revision 1.9 by root, Tue Nov 27 10:59:10 2007 UTC

1#ifndef EVPP_H__ 1#ifndef EVPP_H__
2#define EVPP_H__ 2#define EVPP_H__
3 3
4/* work in progress, don't use unless you know what you are doing */ 4#include "ev.h"
5 5
6namespace ev { 6namespace ev {
7 7
8 template<class watcher> 8 template<class watcher>
9 class callback 9 class callback
42 { 42 {
43 return prxy->call (obj, meth, *w, e); 43 return prxy->call (obj, meth, *w, e);
44 } 44 }
45 }; 45 };
46 46
47 #include "ev.h"
48
49 enum { 47 enum {
50 UNDEF = EV_UNDEF, 48 UNDEF = EV_UNDEF,
51 NONE = EV_NONE, 49 NONE = EV_NONE,
52 READ = EV_READ, 50 READ = EV_READ,
53 WRITE = EV_WRITE, 51 WRITE = EV_WRITE,
54 TIMEOUT = EV_TIMEOUT, 52 TIMEOUT = EV_TIMEOUT,
55 PERIODIC = EV_PERIODIC, 53 PERIODIC = EV_PERIODIC,
56 SIGNAL = EV_SIGNAL, 54 SIGNAL = EV_SIGNAL,
55 CHILD = EV_CHILD,
56 STAT = EV_STAT,
57 IDLE = EV_IDLE, 57 IDLE = EV_IDLE,
58 CHECK = EV_CHECK, 58 CHECK = EV_CHECK,
59 PREPARE = EV_PREPARE, 59 PREPARE = EV_PREPARE,
60 CHILD = EV_CHILD, 60 FORK = EV_FORK,
61 EMBED = EV_EMBED,
61 ERROR = EV_ERROR, 62 ERROR = EV_ERROR,
62 }; 63 };
63 64
64 typedef ev_tstamp tstamp; 65 typedef ev_tstamp tstamp;
65 66
193 { 194 {
194 ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); 195 ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
195 } 196 }
196 EV_END_WATCHER (timer, timer) 197 EV_END_WATCHER (timer, timer)
197 198
198 #if EV_PERIODICS 199 #if EV_PERIODIC_ENABLE
199 EV_BEGIN_WATCHER (periodic, periodic) 200 EV_BEGIN_WATCHER (periodic, periodic)
200 void set (ev_tstamp at, ev_tstamp interval = 0.) 201 void set (ev_tstamp at, ev_tstamp interval = 0.)
201 { 202 {
202 int active = is_active (); 203 int active = is_active ();
203 if (active) stop (); 204 if (active) stop ();
216 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); 217 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
217 } 218 }
218 EV_END_WATCHER (periodic, periodic) 219 EV_END_WATCHER (periodic, periodic)
219 #endif 220 #endif
220 221
221 EV_BEGIN_WATCHER (idle, idle)
222 EV_END_WATCHER (idle, idle)
223
224 EV_BEGIN_WATCHER (prepare, prepare)
225 EV_END_WATCHER (prepare, prepare)
226
227 EV_BEGIN_WATCHER (check, check)
228 EV_END_WATCHER (check, check)
229
230 EV_BEGIN_WATCHER (sig, signal) 222 EV_BEGIN_WATCHER (sig, signal)
231 void set (int signum) 223 void set (int signum)
232 { 224 {
233 int active = is_active (); 225 int active = is_active ();
234 if (active) stop (); 226 if (active) stop ();
257 set (pid); 249 set (pid);
258 start (); 250 start ();
259 } 251 }
260 EV_END_WATCHER (child, child) 252 EV_END_WATCHER (child, child)
261 253
254 #if EV_STAT_ENABLE
255 EV_BEGIN_WATCHER (stat, stat)
256 void set (const char *path, ev_tstamp interval = 0.)
257 {
258 int active = is_active ();
259 if (active) stop ();
260 ev_stat_set (static_cast<ev_stat *>(this), path, interval);
261 if (active) start ();
262 }
263
264 void start (const char *path, ev_tstamp interval = 0.)
265 {
266 set (path, interval);
267 start ();
268 }
269
270 void update ()
271 {
272 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
273 }
274 EV_END_WATCHER (stat, stat)
275 #endif
276
277 EV_BEGIN_WATCHER (idle, idle)
278 void set () { }
279 EV_END_WATCHER (idle, idle)
280
281 EV_BEGIN_WATCHER (prepare, prepare)
282 void set () { }
283 EV_END_WATCHER (prepare, prepare)
284
285 EV_BEGIN_WATCHER (check, check)
286 void set () { }
287 EV_END_WATCHER (check, check)
288
289 #if EV_EMBED_ENABLE
290 EV_BEGIN_WATCHER (embed, embed)
291 void set (struct ev_loop *loop)
292 {
293 int active = is_active ();
294 if (active) stop ();
295 ev_embed_set (static_cast<ev_embed *>(this), loop);
296 if (active) start ();
297 }
298
299 void start (struct ev_loop *embedded_loop)
300 {
301 set (embedded_loop);
302 start ();
303 }
304
305 void sweep ()
306 {
307 ev_embed_sweep (EV_A_ static_cast<ev_embed *>(this));
308 }
309 EV_END_WATCHER (embed, embed)
310 #endif
311
262 #undef EV_CONSTRUCT 312 #undef EV_CONSTRUCT
263 #undef EV_BEGIN_WATCHER 313 #undef EV_BEGIN_WATCHER
314 #undef EV_END_WATCHER
264} 315}
265 316
266#endif 317#endif
267 318

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines