eventloop-integration.h
Go to the documentation of this file.
1 /*
2  *
3  * D-Bus++ - C++ bindings for D-Bus
4  *
5  * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  */
23 
24 
25 #ifndef __DBUSXX_EVENTLOOP_INTEGRATION_H
26 #define __DBUSXX_EVENTLOOP_INTEGRATION_H
27 
28 #include <errno.h>
29 #include <unistd.h>
30 #include "api.h"
31 #include "dispatcher.h"
32 #include "util.h"
33 #include "eventloop.h"
34 
35 namespace DBus
36 {
37 
38 /*
39  * Glue between the event loop and the DBus library
40  */
41 
42 class BusDispatcher;
43 class Pipe;
44 
45 class DXXAPI BusTimeout : public Timeout, public DefaultTimeout
46 {
47  BusTimeout(Timeout::Internal *, BusDispatcher *);
48 
49  void toggle();
50 
51  friend class BusDispatcher;
52 };
53 
54 class DXXAPI BusWatch : public Watch, public DefaultWatch
55 {
56  BusWatch(Watch::Internal *, BusDispatcher *);
57 
58  void toggle();
59 
60  friend class BusDispatcher;
61 };
62 
64 {
65 public:
66  BusDispatcher();
67 
69 
70  virtual void enter();
71 
72  virtual void leave();
73 
74  virtual Pipe *add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data);
75 
76  virtual void del_pipe(Pipe *pipe);
77 
78  virtual void do_iteration();
79 
80  virtual Timeout *add_timeout(Timeout::Internal *);
81 
82  virtual void rem_timeout(Timeout *);
83 
84  virtual Watch *add_watch(Watch::Internal *);
85 
86  virtual void rem_watch(Watch *);
87 
88  void watch_ready(DefaultWatch &);
89 
90  void timeout_expired(DefaultTimeout &);
91 
92 private:
93  bool _running;
94  int _pipe[2];
95  std::list <Pipe *> pipe_list;
96 };
97 
98 } /* namespace DBus */
99 
100 #endif//__DBUSXX_EVENTLOOP_INTEGRATION_H