1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD 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 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.AsyncResultIF; 26 27 private import glib.ErrorG; 28 private import glib.GException; 29 private import gobject.ObjectG; 30 private import gtkc.gio; 31 public import gtkc.giotypes; 32 33 34 /** 35 * Provides a base class for implementing asynchronous function results. 36 * 37 * Asynchronous operations are broken up into two separate operations 38 * which are chained together by a #GAsyncReadyCallback. To begin 39 * an asynchronous operation, provide a #GAsyncReadyCallback to the 40 * asynchronous function. This callback will be triggered when the 41 * operation has completed, and will be passed a #GAsyncResult instance 42 * filled with the details of the operation's success or failure, the 43 * object the asynchronous function was started for and any error codes 44 * returned. The asynchronous callback function is then expected to call 45 * the corresponding "_finish()" function, passing the object the 46 * function was called for, the #GAsyncResult instance, and (optionally) 47 * an @error to grab any error conditions that may have occurred. 48 * 49 * The "_finish()" function for an operation takes the generic result 50 * (of type #GAsyncResult) and returns the specific result that the 51 * operation in question yields (e.g. a #GFileEnumerator for a 52 * "enumerate children" operation). If the result or error status of the 53 * operation is not needed, there is no need to call the "_finish()" 54 * function; GIO will take care of cleaning up the result and error 55 * information after the #GAsyncReadyCallback returns. You can pass 56 * %NULL for the #GAsyncReadyCallback if you don't need to take any 57 * action at all after the operation completes. Applications may also 58 * take a reference to the #GAsyncResult and call "_finish()" later; 59 * however, the "_finish()" function may be called at most once. 60 * 61 * Example of a typical asynchronous operation flow: 62 * |[<!-- language="C" --> 63 * void _theoretical_frobnitz_async (Theoretical *t, 64 * GCancellable *c, 65 * GAsyncReadyCallback cb, 66 * gpointer u); 67 * 68 * gboolean _theoretical_frobnitz_finish (Theoretical *t, 69 * GAsyncResult *res, 70 * GError **e); 71 * 72 * static void 73 * frobnitz_result_func (GObject *source_object, 74 * GAsyncResult *res, 75 * gpointer user_data) 76 * { 77 * gboolean success = FALSE; 78 * 79 * success = _theoretical_frobnitz_finish (source_object, res, NULL); 80 * 81 * if (success) 82 * g_printf ("Hurray!\n"); 83 * else 84 * g_printf ("Uh oh!\n"); 85 * 86 * ... 87 * 88 * } 89 * 90 * int main (int argc, void *argv[]) 91 * { 92 * ... 93 * 94 * _theoretical_frobnitz_async (theoretical_data, 95 * NULL, 96 * frobnitz_result_func, 97 * NULL); 98 * 99 * ... 100 * } 101 * ]| 102 * 103 * The callback for an asynchronous operation is called only once, and is 104 * always called, even in the case of a cancelled operation. On cancellation 105 * the result is a %G_IO_ERROR_CANCELLED error. 106 * 107 * ## I/O Priority # {#io-priority} 108 * 109 * Many I/O-related asynchronous operations have a priority parameter, 110 * which is used in certain cases to determine the order in which 111 * operations are executed. They are not used to determine system-wide 112 * I/O scheduling. Priorities are integers, with lower numbers indicating 113 * higher priority. It is recommended to choose priorities between 114 * %G_PRIORITY_LOW and %G_PRIORITY_HIGH, with %G_PRIORITY_DEFAULT 115 * as a default. 116 */ 117 public interface AsyncResultIF{ 118 /** Get the main Gtk struct */ 119 public GAsyncResult* getAsyncResultStruct(); 120 121 /** the main Gtk struct as a void* */ 122 protected void* getStruct(); 123 124 125 /** 126 * Gets the source object from a #GAsyncResult. 127 * 128 * Return: a new reference to the source object for the @res, 129 * or %NULL if there is none. 130 */ 131 public ObjectG getSourceObject(); 132 133 /** 134 * Gets the user data from a #GAsyncResult. 135 * 136 * Return: the user data for @res. 137 */ 138 public void* getUserData(); 139 140 /** 141 * Checks if @res has the given @source_tag (generally a function 142 * pointer indicating the function @res was created by). 143 * 144 * Params: 145 * sourceTag = an application-defined tag 146 * 147 * Return: %TRUE if @res has the indicated @source_tag, %FALSE if 148 * not. 149 * 150 * Since: 2.34 151 */ 152 public bool isTagged(void* sourceTag); 153 154 /** 155 * If @res is a #GSimpleAsyncResult, this is equivalent to 156 * g_simple_async_result_propagate_error(). Otherwise it returns 157 * %FALSE. 158 * 159 * This can be used for legacy error handling in async *_finish() 160 * wrapper functions that traditionally handled #GSimpleAsyncResult 161 * error returns themselves rather than calling into the virtual method. 162 * This should not be used in new code; #GAsyncResult errors that are 163 * set by virtual methods should also be extracted by virtual methods, 164 * to enable subclasses to chain up correctly. 165 * 166 * Return: %TRUE if @error is has been filled in with an error from 167 * @res, %FALSE if not. 168 * 169 * Since: 2.34 170 * 171 * Throws: GException on failure. 172 */ 173 public bool legacyPropagateError(); 174 }