1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2009 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Alexander Larsson <[email protected]>
19 */
20
21#ifndef __G_ASYNC_INITABLE_H__
22#define __G_ASYNC_INITABLE_H__
23
24#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25#error "Only <gio/gio.h> can be included directly."
26#endif
27
28#include <gio/giotypes.h>
29#include <gio/ginitable.h>
30
31G_BEGIN_DECLS
32
33#define G_TYPE_ASYNC_INITABLE (g_async_initable_get_type ())
34#define G_ASYNC_INITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ASYNC_INITABLE, GAsyncInitable))
35#define G_IS_ASYNC_INITABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ASYNC_INITABLE))
36#define G_ASYNC_INITABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ASYNC_INITABLE, GAsyncInitableIface))
37#define G_TYPE_IS_ASYNC_INITABLE(type) (g_type_is_a ((type), G_TYPE_ASYNC_INITABLE))
38
39/**
40 * GAsyncInitable:
41 *
42 * Interface for asynchronously initializable objects.
43 *
44 * Since: 2.22
45 **/
46typedef struct _GAsyncInitableIface GAsyncInitableIface;
47
48/**
49 * GAsyncInitableIface:
50 * @g_iface: The parent interface.
51 * @init_async: Starts initialization of the object.
52 * @init_finish: Finishes initialization of the object.
53 *
54 * Provides an interface for asynchronous initializing object such that
55 * initialization may fail.
56 *
57 * Since: 2.22
58 **/
59struct _GAsyncInitableIface
60{
61 GTypeInterface g_iface;
62
63 /* Virtual Table */
64
65 void (* init_async) (GAsyncInitable *initable,
66 int io_priority,
67 GCancellable *cancellable,
68 GAsyncReadyCallback callback,
69 gpointer user_data);
70 gboolean (* init_finish) (GAsyncInitable *initable,
71 GAsyncResult *res,
72 GError **error);
73};
74
75GLIB_AVAILABLE_IN_ALL
76GType g_async_initable_get_type (void) G_GNUC_CONST;
77
78
79GLIB_AVAILABLE_IN_ALL
80void g_async_initable_init_async (GAsyncInitable *initable,
81 int io_priority,
82 GCancellable *cancellable,
83 GAsyncReadyCallback callback,
84 gpointer user_data);
85GLIB_AVAILABLE_IN_ALL
86gboolean g_async_initable_init_finish (GAsyncInitable *initable,
87 GAsyncResult *res,
88 GError **error);
89
90GLIB_AVAILABLE_IN_ALL
91void g_async_initable_new_async (GType object_type,
92 int io_priority,
93 GCancellable *cancellable,
94 GAsyncReadyCallback callback,
95 gpointer user_data,
96 const gchar *first_property_name,
97 ...);
98GLIB_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties and g_async_initable_init_async)
99void g_async_initable_newv_async (GType object_type,
100 guint n_parameters,
101 GParameter *parameters,
102 int io_priority,
103 GCancellable *cancellable,
104 GAsyncReadyCallback callback,
105 gpointer user_data);
106GLIB_AVAILABLE_IN_ALL
107void g_async_initable_new_valist_async (GType object_type,
108 const gchar *first_property_name,
109 va_list var_args,
110 int io_priority,
111 GCancellable *cancellable,
112 GAsyncReadyCallback callback,
113 gpointer user_data);
114GLIB_AVAILABLE_IN_ALL
115GObject *g_async_initable_new_finish (GAsyncInitable *initable,
116 GAsyncResult *res,
117 GError **error);
118
119
120
121G_END_DECLS
122
123
124#endif /* __G_ASYNC_INITABLE_H__ */
125