Free memory with dbus_free instead of free. Account for NULL signatures.
[dbus-cxx-async.git] / include / dbus-c++ / eventloop-integration.h
blobc98221b9297a884f96c6e817dfc897d6266aaaac
1 /*
3 * D-Bus++ - C++ bindings for D-Bus
5 * Copyright (C) 2005-2009 Paolo Durante <shackan@gmail.com>
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.
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.
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
25 #ifndef __DBUSXX_EVENTLOOP_INTEGRATION_H
26 #define __DBUSXX_EVENTLOOP_INTEGRATION_H
28 #include "api.h"
29 #include "dispatcher.h"
30 #include "util.h"
31 #include "eventloop.h"
33 namespace DBus {
35 /*
36 * Glue between the event loop and the DBus library
39 class DefaultDispatcher;
41 class DBUSXXAPI DefaultTimeout : public Timeout, public SimpleTimeout
43 DefaultTimeout(Timeout::Internal *, DefaultDispatcher *);
45 void toggle();
47 friend class DefaultDispatcher;
50 class DBUSXXAPI DefaultWatch : public Watch, public SimpleWatch
52 DefaultWatch(Watch::Internal *, DefaultDispatcher *);
54 void toggle();
56 friend class DefaultDispatcher;
59 class DBUSXXAPI DefaultDispatcher
60 : public Dispatcher, public SimpleMainLoop, public CallbackTarget
62 public:
64 static DefaultDispatcher instance;
66 DefaultDispatcher(int32_t pollTimeout = 500 /* msec*/)
67 : Dispatcher()
68 , SimpleMainLoop(pollTimeout)
69 , CallbackTarget()
70 , _running(false)
73 ~DefaultDispatcher()
76 bool running() { return _running; }
78 virtual void enter();
80 virtual void leave();
82 virtual void start_iteration();
83 virtual void do_iteration();
85 virtual Timeout *add_timeout(Timeout::Internal *);
87 virtual void rem_timeout(Timeout *);
89 virtual Watch *add_watch(Watch::Internal *);
91 virtual void rem_watch(Watch *);
93 void watch_ready(SimpleWatch &);
95 void timeout_expired(SimpleTimeout &);
97 private:
99 volatile bool _running;
102 } /* namespace DBus */
104 #endif//__DBUSXX_EVENTLOOP_INTEGRATION_H