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 "api.h"
30 #include "dispatcher.h"
31 #include "util.h"
32 #include "eventloop.h"
33 
34 namespace DBus
35 {
36 
37 /*
38  * Glue between the event loop and the DBus library
39  */
40 
41 class BusDispatcher;
42 class Pipe;
43 
44 class DXXAPI BusTimeout : public Timeout, public DefaultTimeout
45 {
46  BusTimeout(Timeout::Internal *, BusDispatcher *);
47 
48  void toggle();
49 
50  friend class BusDispatcher;
51 };
52 
53 class DXXAPI BusWatch : public Watch, public DefaultWatch
54 {
55  BusWatch(Watch::Internal *, BusDispatcher *);
56 
57  void toggle();
58 
59  friend class BusDispatcher;
60 };
61 
63 {
64 public:
65  BusDispatcher();
66 
68 
69  virtual void enter();
70 
71  virtual void leave();
72 
73  virtual Pipe *add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data);
74 
75  virtual void del_pipe(Pipe *pipe);
76 
77  virtual void do_iteration();
78 
79  virtual void run();
80 
81  bool is_running();
82 
83  virtual Timeout *add_timeout(Timeout::Internal *);
84 
85  virtual void rem_timeout(Timeout *);
86 
87  virtual Watch *add_watch(Watch::Internal *);
88 
89  virtual void rem_watch(Watch *);
90 
91  void watch_ready(DefaultWatch &);
92 
93  void timeout_expired(DefaultTimeout &);
94 
95 private:
96  bool _running;
97  int _pipe[2];
98  std::list <Pipe *> pipe_list;
99 };
100 
101 } /* namespace DBus */
102 
103 #endif//__DBUSXX_EVENTLOOP_INTEGRATION_H
#define DXXAPI
Definition: api.h:36
std::list< Pipe * > pipe_list