2 * Copyright 2015 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 * Authors: Philip Withnall <philip.withnall@collabora.co.uk>
20 #ifndef __G_DATAGRAM_BASED_H__
21 #define __G_DATAGRAM_BASED_H__
23 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
27 #include <gio/giotypes.h>
31 #define G_TYPE_DATAGRAM_BASED (g_datagram_based_get_type ())
32 #define G_DATAGRAM_BASED(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
33 G_TYPE_DATAGRAM_BASED, GDatagramBased))
34 #define G_IS_DATAGRAM_BASED(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
35 G_TYPE_DATAGRAM_BASED))
36 #define G_DATAGRAM_BASED_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
37 G_TYPE_DATAGRAM_BASED, \
38 GDatagramBasedInterface))
39 #define G_TYPE_IS_DATAGRAM_BASED(type) (g_type_is_a ((type), \
40 G_TYPE_DATAGRAM_BASED))
45 * Interface for socket-like objects with datagram semantics.
49 typedef struct _GDatagramBasedInterface GDatagramBasedInterface
;
52 * GDatagramBasedInterface:
53 * @g_iface: The parent interface.
54 * @receive_messages: Virtual method for g_datagram_based_receive_messages().
55 * @send_messages: Virtual method for g_datagram_based_send_messages().
56 * @create_source: Virtual method for g_datagram_based_create_source().
57 * @condition_check: Virtual method for g_datagram_based_condition_check().
58 * @condition_wait: Virtual method for
59 * g_datagram_based_condition_wait().
61 * Provides an interface for socket-like objects which have datagram semantics,
62 * following the Berkeley sockets API. The interface methods are thin wrappers
63 * around the corresponding virtual methods, and no pre-processing of inputs is
64 * implemented — so implementations of this API must handle all functionality
65 * documented in the interface methods.
69 struct _GDatagramBasedInterface
71 GTypeInterface g_iface
;
74 gint (*receive_messages
) (GDatagramBased
*datagram_based
,
75 GInputMessage
*messages
,
79 GCancellable
*cancellable
,
81 gint (*send_messages
) (GDatagramBased
*datagram_based
,
82 GOutputMessage
*messages
,
86 GCancellable
*cancellable
,
89 GSource
*(*create_source
) (GDatagramBased
*datagram_based
,
90 GIOCondition condition
,
91 GCancellable
*cancellable
);
92 GIOCondition (*condition_check
) (GDatagramBased
*datagram_based
,
93 GIOCondition condition
);
94 gboolean (*condition_wait
) (GDatagramBased
*datagram_based
,
95 GIOCondition condition
,
97 GCancellable
*cancellable
,
101 GLIB_AVAILABLE_IN_2_48
103 g_datagram_based_get_type (void);
105 GLIB_AVAILABLE_IN_2_48
107 g_datagram_based_receive_messages (GDatagramBased
*datagram_based
,
108 GInputMessage
*messages
,
112 GCancellable
*cancellable
,
115 GLIB_AVAILABLE_IN_2_48
117 g_datagram_based_send_messages (GDatagramBased
*datagram_based
,
118 GOutputMessage
*messages
,
122 GCancellable
*cancellable
,
125 GLIB_AVAILABLE_IN_2_48
127 g_datagram_based_create_source (GDatagramBased
*datagram_based
,
128 GIOCondition condition
,
129 GCancellable
*cancellable
);
130 GLIB_AVAILABLE_IN_2_48
132 g_datagram_based_condition_check (GDatagramBased
*datagram_based
,
133 GIOCondition condition
);
134 GLIB_AVAILABLE_IN_2_48
136 g_datagram_based_condition_wait (GDatagramBased
*datagram_based
,
137 GIOCondition condition
,
139 GCancellable
*cancellable
,
144 #endif /* __G_DATAGRAM_BASED_H__ */