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>
38 typedef struct DBusSocketSet DBusSocketSet;
40 typedef struct DBusSocketSetClass DBusSocketSetClass;
41 struct DBusSocketSetClass {
42 void (*free) (DBusSocketSet *self);
43 dbus_bool_t (*add) (DBusSocketSet *self,
47 void (*remove) (DBusSocketSet *self,
49 void (*enable) (DBusSocketSet *self,
52 void (*disable) (DBusSocketSet *self,
54 int (*poll) (DBusSocketSet *self,
55 DBusSocketEvent *revents,
60 struct DBusSocketSet {
61 DBusSocketSetClass *cls;
64 DBusSocketSet *_dbus_socket_set_new (int size_hint);
67 _dbus_socket_set_free (DBusSocketSet *self)
69 (self->cls->free) (self);
72 static inline dbus_bool_t
73 _dbus_socket_set_add (DBusSocketSet *self,
78 return (self->cls->add) (self, fd, flags, enabled);
82 _dbus_socket_set_remove (DBusSocketSet *self,
85 (self->cls->remove) (self, fd);
89 _dbus_socket_set_enable (DBusSocketSet *self,
93 (self->cls->enable) (self, fd, flags);
97 _dbus_socket_set_disable (DBusSocketSet *self,
100 (self->cls->disable) (self, fd);
105 _dbus_socket_set_poll (DBusSocketSet *self,
106 DBusSocketEvent *revents,
110 return (self->cls->poll) (self, revents, max_events, timeout_ms);
113 /* concrete implementations, not necessarily built on all platforms */
115 extern DBusSocketSetClass _dbus_socket_set_poll_class;
116 extern DBusSocketSetClass _dbus_socket_set_epoll_class;
118 DBusSocketSet *_dbus_socket_set_poll_new (int size_hint);
119 DBusSocketSet *_dbus_socket_set_epoll_new (void);
121 #endif /* !DOXYGEN_SHOULD_SKIP_THIS */
122 #endif /* multiple-inclusion guard */