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