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_H
26 #define __DBUSXX_EVENTLOOP_H
38 * these Simple *classes implement a very simple event loop which
39 * is used here as the default main loop, if you want to hook
40 * a different one use the Bus *classes in eventloop-integration.h
41 * or the Glib::Bus *classes as a reference
46 class DBUSXXAPI SimpleTimeout
50 SimpleTimeout(int interval
, bool repeat
, SimpleMainLoop
*);
52 virtual ~SimpleTimeout();
54 bool enabled(){ return _enabled
; }
55 void enabled(bool e
){ _enabled
= e
; }
57 int interval(){ return _interval
; }
58 void interval(int i
){ _interval
= i
; }
60 bool repeat(){ return _repeat
; }
61 void repeat(bool r
){ _repeat
= r
; }
63 void *data(){ return _data
; }
64 void data(void *d
){ _data
= d
; }
66 Slot
<void, SimpleTimeout
&> expired
;
79 SimpleMainLoop
*_disp
;
81 friend class SimpleMainLoop
;
84 typedef std::list
< SimpleTimeout
*> SimpleTimeouts
;
86 class DBUSXXAPI SimpleWatch
90 SimpleWatch(int fd
, int flags
, SimpleMainLoop
*);
92 virtual ~SimpleWatch();
94 bool enabled(){ return _enabled
; }
95 void enabled(bool e
){ _enabled
= e
; }
97 int descriptor(){ return _fd
; }
99 int flags(){ return _flags
; }
100 void flags(int f
){ _flags
= f
; }
102 int state(){ return _state
; }
104 void *data(){ return _data
; }
105 void data(void *d
){ _data
= d
; }
107 Slot
<void, SimpleWatch
&> ready
;
119 SimpleMainLoop
*_disp
;
121 friend class SimpleMainLoop
;
124 typedef std::list
< SimpleWatch
*> SimpleWatches
;
126 class DBUSXXAPI SimpleMutex
140 pthread_mutex_t _mutex
;
143 class DBUSXXAPI SimpleMainLoop
147 SimpleMainLoop(int32_t pollTimeout
);
149 virtual ~SimpleMainLoop();
151 virtual void dispatch();
155 SimpleMutex _mutex_t
;
156 SimpleTimeouts _timeouts
;
158 SimpleMutex _mutex_w
;
159 SimpleWatches _watches
;
160 int32_t _pollTimeout
;
162 friend class SimpleTimeout
;
163 friend class SimpleWatch
;
166 } /* namespace DBus */
168 #endif//__DBUSXX_EVENTLOOP_H