1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 * dbus-socket-set.h - used to bolt file descriptors onto a bus
5 * Copyright © 2011 Nokia Corporation
7 * Licensed under the Academic Free License version 2.1
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 #ifndef DBUS_SOCKET_SET_H
27 #define DBUS_SOCKET_SET_H
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
31 #include <dbus/dbus.h>
32 #include <dbus/dbus-sysdeps.h>
39 typedef struct DBusSocketSet DBusSocketSet;
41 typedef struct DBusSocketSetClass DBusSocketSetClass;
42 struct DBusSocketSetClass {
43 void (*free) (DBusSocketSet *self);
44 dbus_bool_t (*add) (DBusSocketSet *self,
48 void (*remove) (DBusSocketSet *self,
50 void (*enable) (DBusSocketSet *self,
53 void (*disable) (DBusSocketSet *self,
55 int (*poll) (DBusSocketSet *self,
56 DBusSocketEvent *revents,
61 struct DBusSocketSet {
62 DBusSocketSetClass *cls;
65 DBusSocketSet *_dbus_socket_set_new (int size_hint);
68 _dbus_socket_set_free (DBusSocketSet *self)
70 (self->cls->free) (self);
73 static inline dbus_bool_t
74 _dbus_socket_set_add (DBusSocketSet *self,
79 return (self->cls->add) (self, fd, flags, enabled);
83 _dbus_socket_set_remove (DBusSocketSet *self,
86 (self->cls->remove) (self, fd);
90 _dbus_socket_set_enable (DBusSocketSet *self,
94 (self->cls->enable) (self, fd, flags);
98 _dbus_socket_set_disable (DBusSocketSet *self,
101 (self->cls->disable) (self, fd);
106 _dbus_socket_set_poll (DBusSocketSet *self,
107 DBusSocketEvent *revents,
111 return (self->cls->poll) (self, revents, max_events, timeout_ms);
114 /* concrete implementations, not necessarily built on all platforms */
116 extern DBusSocketSetClass _dbus_socket_set_poll_class;
117 extern DBusSocketSetClass _dbus_socket_set_epoll_class;
119 DBusSocketSet *_dbus_socket_set_poll_new (int size_hint);
120 DBusSocketSet *_dbus_socket_set_epoll_new (void);
122 #endif /* !DOXYGEN_SHOULD_SKIP_THIS */
123 #endif /* multiple-inclusion guard */