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  * Conversion parameters:
26  * inFile  = GAsyncResult.html
27  * outPack = gio
28  * outFile = AsyncResultT
29  * strct   = GAsyncResult
30  * realStrct=
31  * ctorStrct=
32  * clss    = AsyncResultT
33  * interf  = AsyncResultIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_async_result_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gobject.ObjectG
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * structWrap:
51  * 	- GObject* -> ObjectG
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gio.AsyncResultT;
58 
59 public  import gtkc.giotypes;
60 
61 public import gtkc.gio;
62 public import glib.ConstructionException;
63 public import gobject.ObjectG;
64 
65 public import gobject.ObjectG;
66 public import glib.ErrorG;
67 public import glib.GException;
68 
69 
70 
71 /**
72  * Provides a base class for implementing asynchronous function results.
73  *
74  * Asynchronous operations are broken up into two separate operations
75  * which are chained together by a GAsyncReadyCallback. To begin
76  * an asynchronous operation, provide a GAsyncReadyCallback to the
77  * asynchronous function. This callback will be triggered when the
78  * operation has completed, and will be passed a GAsyncResult instance
79  * filled with the details of the operation's success or failure, the
80  * object the asynchronous function was started for and any error codes
81  * returned. The asynchronous callback function is then expected to call
82  * the corresponding "_finish()" function, passing the object the
83  * function was called for, the GAsyncResult instance, and (optionally)
84  * an error to grab any error conditions that may have occurred.
85  *
86  * The "_finish()" function for an operation takes the generic result
87  * (of type GAsyncResult) and returns the specific result that the
88  * operation in question yields (e.g. a GFileEnumerator for a
89  * "enumerate children" operation). If the result or error status of the
90  * operation is not needed, there is no need to call the "_finish()"
91  * function; GIO will take care of cleaning up the result and error
92  * information after the GAsyncReadyCallback returns. You can pass
93  * NULL for the GAsyncReadyCallback if you don't need to take any
94  * action at all after the operation completes. Applications may also
95  * take a reference to the GAsyncResult and call "_finish()" later;
96  * however, the "_finish()" function may be called at most once.
97  *
98  * Example of a typical asynchronous operation flow:
99  *
100  * $(DDOC_COMMENT example)
101  *
102  * The callback for an asynchronous operation is called only once, and is
103  * always called, even in the case of a cancelled operation. On cancellation
104  * the result is a G_IO_ERROR_CANCELLED error.
105  *
106  *  Many I/O-related asynchronous
107  * operations have a priority parameter, which is used in certain
108  * cases to determine the order in which operations are executed. They
109  * are not used to determine system-wide I/O
110  * scheduling. Priorities are integers, with lower numbers indicating
111  * higher priority. It is recommended to choose priorities between
112  * G_PRIORITY_LOW and G_PRIORITY_HIGH, with G_PRIORITY_DEFAULT as a
113  * default.
114  */
115 public template AsyncResultT(TStruct)
116 {
117 	
118 	/** the main Gtk struct */
119 	protected GAsyncResult* gAsyncResult;
120 	
121 	
122 	/** Get the main Gtk struct */
123 	public GAsyncResult* getAsyncResultTStruct()
124 	{
125 		return cast(GAsyncResult*)getStruct();
126 	}
127 	
128 	
129 	/**
130 	 */
131 	
132 	/**
133 	 * Gets the user data from a GAsyncResult.
134 	 * Returns: the user data for res. [transfer full]
135 	 */
136 	public void* getUserData()
137 	{
138 		// gpointer g_async_result_get_user_data (GAsyncResult *res);
139 		return g_async_result_get_user_data(getAsyncResultTStruct());
140 	}
141 	
142 	/**
143 	 * Gets the source object from a GAsyncResult.
144 	 * Returns: a new reference to the source object for the res, or NULL if there is none. [transfer full]
145 	 */
146 	public ObjectG getSourceObject()
147 	{
148 		// GObject * g_async_result_get_source_object (GAsyncResult *res);
149 		auto p = g_async_result_get_source_object(getAsyncResultTStruct());
150 		
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 		
156 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
157 	}
158 	
159 	/**
160 	 * Checks if res has the given source_tag (generally a function
161 	 * pointer indicating the function res was created by).
162 	 * Since 2.34
163 	 * Params:
164 	 * sourceTag = an application-defined tag
165 	 * Returns: TRUE if res has the indicated source_tag, FALSE if not.
166 	 */
167 	public int isTagged(void* sourceTag)
168 	{
169 		// gboolean g_async_result_is_tagged (GAsyncResult *res,  gpointer source_tag);
170 		return g_async_result_is_tagged(getAsyncResultTStruct(), sourceTag);
171 	}
172 	
173 	/**
174 	 * If res is a GSimpleAsyncResult, this is equivalent to
175 	 * g_simple_async_result_propagate_error(). Otherwise it returns
176 	 * FALSE.
177 	 * This can be used for legacy error handling in async
178 	 * _finish() wrapper functions that traditionally
179 	 * handled GSimpleAsyncResult error returns themselves rather than
180 	 * calling into the virtual method. This should not be used in new
181 	 * code; GAsyncResult errors that are set by virtual methods should
182 	 * also be extracted by virtual methods, to enable subclasses to chain
183 	 * up correctly.
184 	 * Since 2.34
185 	 * Returns: TRUE if error is has been filled in with an error from res, FALSE if not.
186 	 */
187 	public int legacyPropagateError()
188 	{
189 		// gboolean g_async_result_legacy_propagate_error  (GAsyncResult *res,  GError **error);
190 		GError* err = null;
191 		
192 		auto p = g_async_result_legacy_propagate_error(getAsyncResultTStruct(), &err);
193 		
194 		if (err !is null)
195 		{
196 			throw new GException( new ErrorG(err) );
197 		}
198 		
199 		return p;
200 	}
201 }