"Fossies" - the Fresh Open Source Software Archive 
Member "glibmm-2.76.0/untracked/gio/giomm/asyncinitable.h" (12 Mar 2023, 8277 Bytes) of package /linux/misc/glibmm-2.76.0.tar.xz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "asyncinitable.h" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
2.74.1_vs_2.76.0.
1 // Generated by gmmproc 2.76.0 -- DO NOT MODIFY!
2 #ifndef _GIOMM_ASYNCINITABLE_H
3 #define _GIOMM_ASYNCINITABLE_H
4
5
6 #include <glibmm/ustring.h>
7 #include <sigc++/sigc++.h>
8
9 /* Copyright (C) 2010 The giomm Development Team
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 #include <glibmm/interface.h>
26 #include <glibmm/priorities.h>
27 #include <giomm/asyncresult.h>
28
29
30 #ifndef DOXYGEN_SHOULD_SKIP_THIS
31 typedef struct _GAsyncInitableIface GAsyncInitableIface;
32 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 using GAsyncInitable = struct _GAsyncInitable;
36 using GAsyncInitableClass = struct _GAsyncInitableClass;
37 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
38
39
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41 namespace Gio
42 { class GIOMM_API AsyncInitable_Class; } // namespace Gio
43 #endif // DOXYGEN_SHOULD_SKIP_THIS
44
45 namespace Gio
46 {
47
48 class GIOMM_API Cancellable;
49
50 /** AsyncInitable - Asynchronously failable object initialization interface.
51 * This is the asynchronous version of Initable; it behaves the same in all
52 * ways except that initialization is asynchronous. For more details see the
53 * descriptions on Initable.
54 *
55 * A class may implement both the Initable and AsyncInitable interfaces.
56 *
57 * Users of objects implementing this are not intended to use the interface
58 * method directly; instead it will be used automatically in various ways. For
59 * C applications you generally just call g_async_initable_new_async()
60 * directly, or indirectly via a foo_thing_new_async() wrapper. This will call
61 * g_async_initable_init_async() under the cover, calling back with nullptr and a
62 * set GError on failure.
63 */
64
65 class GIOMM_API AsyncInitable : public Glib::Interface
66 {
67
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69
70 public:
71 using CppObjectType = AsyncInitable;
72 using CppClassType = AsyncInitable_Class;
73 using BaseObjectType = GAsyncInitable;
74 using BaseClassType = GAsyncInitableIface;
75
76 // noncopyable
77 AsyncInitable(const AsyncInitable&) = delete;
78 AsyncInitable& operator=(const AsyncInitable&) = delete;
79
80 private:
81 friend class AsyncInitable_Class;
82 static CppClassType asyncinitable_class_;
83
84 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
85 protected:
86 /**
87 * You should derive from this class to use it.
88 */
89 AsyncInitable();
90
91 #ifndef DOXYGEN_SHOULD_SKIP_THIS
92 /** Called by constructors of derived classes. Provide the result of
93 * the Class init() function to ensure that it is properly
94 * initialized.
95 *
96 * @param interface_class The Class object for the derived type.
97 */
98 explicit AsyncInitable(const Glib::Interface_Class& interface_class);
99
100 public:
101 // This is public so that C++ wrapper instances can be
102 // created for C instances of unwrapped types.
103 // For instance, if an unexpected C type implements the C interface.
104 explicit AsyncInitable(GAsyncInitable* castitem);
105
106 protected:
107 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
108
109 public:
110
111 AsyncInitable(AsyncInitable&& src) noexcept;
112 AsyncInitable& operator=(AsyncInitable&& src) noexcept;
113
114 ~AsyncInitable() noexcept override;
115
116 static void add_interface(GType gtype_implementer);
117
118 /** Get the GType for this class, for use with the underlying GObject type system.
119 */
120 static GType get_type() G_GNUC_CONST;
121
122 #ifndef DOXYGEN_SHOULD_SKIP_THIS
123 static GType get_base_type() G_GNUC_CONST;
124 #endif
125
126 ///Provides access to the underlying C GObject.
127 GAsyncInitable* gobj() { return reinterpret_cast<GAsyncInitable*>(gobject_); }
128
129 ///Provides access to the underlying C GObject.
130 const GAsyncInitable* gobj() const { return reinterpret_cast<GAsyncInitable*>(gobject_); }
131
132 private:
133
134
135 protected:
136 /** Starts asynchronous initialization of the object implementing the
137 * interface. This must be done before any real use of the object after
138 * initial construction. If the object also implements Initable you can
139 * optionally call Gio::Initable::init() instead.
140 *
141 * When the initialization is finished, @a slot will be called. You can
142 * then call init_finish() to get the result of the initialization.
143 *
144 * Implementations may also support cancellation. Initialization can be
145 * cancelled by triggering the @a cancellable object from another thread. If
146 * the operation was cancelled, the error Gio::IO_ERROR_CANCELLED will be
147 * returned. If the object doesn't support cancellable initialization, the
148 * error Gio::IO_ERROR_NOT_SUPPORTED will be returned.
149 *
150 * If this function is not called, or returns with an error, then all
151 * operations on the object should fail, generally returning the error
152 * Gio::IO_ERROR_NOT_INITIALIZED.
153 *
154 * Implementations of this method must be idempotent: i.e. multiple calls to
155 * this function with the same argument should return the same results. Only
156 * the first call initializes the object; further calls return the result of
157 * the first call. This is so that it's safe to implement the singleton
158 * pattern in the GObject constructor function.
159 *
160 * For classes that also support the Initable interface, the default
161 * implementation of this method will run the Gio::Initable::init() method
162 * in a thread, so if you want to support asynchronous initialization via
163 * threads, just implement the AsyncInitable interface without overriding
164 * any interface methods.
165 *
166 * @param io_priority The I/O priority of the operation.
167 * @param cancellable Cancellable object to make cancellation possible.
168 * @param slot a SlotAsyncReady to call when the request is satisfied.
169 *
170 * @newin{2,28}
171 */
172 void init_async(const SlotAsyncReady& slot,
173 const Glib::RefPtr<Cancellable>& cancellable,
174 int io_priority = Glib::PRIORITY_DEFAULT);
175
176
177 /// Non-cancellable version of init_async().
178 void init_async(const SlotAsyncReady& slot,
179 int io_priority = Glib::PRIORITY_DEFAULT);
180
181
182 /** Finishes asynchronous initialization and returns the result.
183 * See g_async_initable_init_async().
184 *
185 * @newin{2,22}
186 *
187 * @param res A AsyncResult.
188 * @return <tt>true</tt> if successful. If an error has occurred, this function
189 * will return <tt>false</tt> and set @a error appropriately if present.
190 *
191 * @throws Glib::Error
192 */
193 bool init_finish(const Glib::RefPtr<AsyncResult>& res);
194
195
196 /** Finishes the async construction for the various g_async_initable_new
197 * calls, returning the created object or <tt>nullptr</tt> on error.
198 *
199 * @newin{2,22}
200 *
201 * @param res The AsyncResult from the callback.
202 * @return A newly created Object,
203 * or <tt>nullptr</tt> on error. Free with Glib::object_unref().
204 *
205 * @throws Glib::Error
206 */
207 Glib::RefPtr<Glib::Object> create_finish(const Glib::RefPtr<AsyncResult>& res);
208
209 virtual void init_async_vfunc(const SlotAsyncReady& slot,
210 const Glib::RefPtr<Cancellable>& cancellable,
211 int io_priority = Glib::PRIORITY_DEFAULT);
212
213 /** @throw Glib::Errror.
214 */
215 virtual bool init_finish_vfunc(const Glib::RefPtr<AsyncResult>& res);
216
217 protected:
218
219
220 public:
221
222 public:
223 //C++ methods used to invoke GTK+ virtual functions:
224
225 protected:
226 //GTK+ Virtual Functions (override these to change behaviour):
227
228 //Default Signal Handlers::
229
230
231 };
232
233 } // namespace Gio
234
235
236 namespace Glib
237 {
238 /** A Glib::wrap() method for this object.
239 *
240 * @param object The C instance.
241 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
242 * @result A C++ instance that wraps this C instance.
243 *
244 * @relates Gio::AsyncInitable
245 */
246 GIOMM_API
247 Glib::RefPtr<Gio::AsyncInitable> wrap(GAsyncInitable* object, bool take_copy = false);
248
249 } // namespace Glib
250
251
252 #endif /* _GIOMM_ASYNCINITABLE_H */
253