1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>EFL's abstraction for a task (process).
11 /// (Since EFL 1.22)</summary>
12 [Efl.Task.NativeMethods]
13 [Efl.Eo.BindingEntity]
14 public abstract class Task : Efl.LoopConsumer
16 ///<summary>Pointer to the native class description.</summary>
17 public override System.IntPtr NativeClass
21 if (((object)this).GetType() == typeof(Task))
23 return GetEflClassStatic();
27 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
32 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
34 /// <summary>Initializes a new instance of the <see cref="Task"/> class.</summary>
35 /// <param name="parent">Parent instance.</param>
36 public Task(Efl.Object parent= null
37 ) : base(efl_task_class_get(), parent)
39 FinishInstantiation();
42 /// <summary>Constructor to be used when objects are expected to be constructed from native code.</summary>
43 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
44 protected Task(ConstructingHandle ch) : base(ch)
48 /// <summary>Initializes a new instance of the <see cref="Task"/> class.
49 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
50 /// <param name="wh">The native pointer to be wrapped.</param>
51 protected Task(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
55 [Efl.Eo.PrivateNativeClass]
56 private class TaskRealized : Task
58 private TaskRealized(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
62 /// <summary>Initializes a new instance of the <see cref="Task"/> class.
63 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
64 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
65 /// <param name="parent">The Efl.Object parent of this instance.</param>
66 protected Task(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)
70 /// <summary>The priority of this task.
71 /// (Since EFL 1.22)</summary>
72 /// <returns>Desired priority.</returns>
73 virtual public Efl.TaskPriority GetPriority() {
74 var _ret_var = Efl.Task.NativeMethods.efl_task_priority_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
75 Eina.Error.RaiseIfUnhandledException();
78 /// <summary>The priority of this task.
79 /// (Since EFL 1.22)</summary>
80 /// <param name="priority">Desired priority.</param>
81 virtual public void SetPriority(Efl.TaskPriority priority) {
82 Efl.Task.NativeMethods.efl_task_priority_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),priority);
83 Eina.Error.RaiseIfUnhandledException();
85 /// <summary>The final exit code of this task. This is the code that will be produced upon task completion.
86 /// (Since EFL 1.22)</summary>
87 /// <returns>The exit code.</returns>
88 virtual public int GetExitCode() {
89 var _ret_var = Efl.Task.NativeMethods.efl_task_exit_code_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
90 Eina.Error.RaiseIfUnhandledException();
93 /// <summary>Flags to further customize task's behavior.
94 /// (Since EFL 1.22)</summary>
95 /// <returns>Desired task flags.</returns>
96 virtual public Efl.TaskFlags GetFlags() {
97 var _ret_var = Efl.Task.NativeMethods.efl_task_flags_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
98 Eina.Error.RaiseIfUnhandledException();
101 /// <summary>Flags to further customize task's behavior.
102 /// (Since EFL 1.22)</summary>
103 /// <param name="flags">Desired task flags.</param>
104 virtual public void SetFlags(Efl.TaskFlags flags) {
105 Efl.Task.NativeMethods.efl_task_flags_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),flags);
106 Eina.Error.RaiseIfUnhandledException();
108 /// <summary>Actually run the task.
109 /// (Since EFL 1.22)</summary>
110 /// <returns>A future triggered when task exits and is passed int exit code.</returns>
111 virtual public Eina.Future Run() {
112 var _ret_var = Efl.Task.NativeMethods.efl_task_run_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
113 Eina.Error.RaiseIfUnhandledException();
116 /// <summary>Request the task end (may send a signal or interrupt signal resulting in a terminate event being tiggered in the target task loop).
117 /// (Since EFL 1.22)</summary>
118 virtual public void End() {
119 Efl.Task.NativeMethods.efl_task_end_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
120 Eina.Error.RaiseIfUnhandledException();
122 /// <summary>Async wrapper for <see cref="Run" />.</summary>
123 /// <param name="token">Token to notify the async operation of external request to cancel.</param>
124 /// <returns>An async task wrapping the result of the operation.</returns>
125 public System.Threading.Tasks.Task<Eina.Value> RunAsync( System.Threading.CancellationToken token = default(System.Threading.CancellationToken))
127 Eina.Future future = Run();
128 return Efl.Eo.Globals.WrapAsync(future, token);
131 /// <summary>The priority of this task.
132 /// (Since EFL 1.22)</summary>
133 /// <value>Desired priority.</value>
134 public Efl.TaskPriority Priority {
135 get { return GetPriority(); }
136 set { SetPriority(value); }
138 /// <summary>The final exit code of this task. This is the code that will be produced upon task completion.
139 /// (Since EFL 1.22)</summary>
140 /// <value>The exit code.</value>
141 public int ExitCode {
142 get { return GetExitCode(); }
144 /// <summary>Flags to further customize task's behavior.
145 /// (Since EFL 1.22)</summary>
146 /// <value>Desired task flags.</value>
147 public Efl.TaskFlags Flags {
148 get { return GetFlags(); }
149 set { SetFlags(value); }
151 private static IntPtr GetEflClassStatic()
153 return Efl.Task.efl_task_class_get();
155 /// <summary>Wrapper for native methods and virtual method delegates.
156 /// For internal use by generated code only.</summary>
157 public new class NativeMethods : Efl.LoopConsumer.NativeMethods
159 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Ecore);
160 /// <summary>Gets the list of Eo operations to override.</summary>
161 /// <returns>The list of Eo operations to be overload.</returns>
162 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
164 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
165 var methods = Efl.Eo.Globals.GetUserMethods(type);
167 if (efl_task_priority_get_static_delegate == null)
169 efl_task_priority_get_static_delegate = new efl_task_priority_get_delegate(priority_get);
172 if (methods.FirstOrDefault(m => m.Name == "GetPriority") != null)
174 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_priority_get"), func = Marshal.GetFunctionPointerForDelegate(efl_task_priority_get_static_delegate) });
177 if (efl_task_priority_set_static_delegate == null)
179 efl_task_priority_set_static_delegate = new efl_task_priority_set_delegate(priority_set);
182 if (methods.FirstOrDefault(m => m.Name == "SetPriority") != null)
184 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_priority_set"), func = Marshal.GetFunctionPointerForDelegate(efl_task_priority_set_static_delegate) });
187 if (efl_task_exit_code_get_static_delegate == null)
189 efl_task_exit_code_get_static_delegate = new efl_task_exit_code_get_delegate(exit_code_get);
192 if (methods.FirstOrDefault(m => m.Name == "GetExitCode") != null)
194 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_exit_code_get"), func = Marshal.GetFunctionPointerForDelegate(efl_task_exit_code_get_static_delegate) });
197 if (efl_task_flags_get_static_delegate == null)
199 efl_task_flags_get_static_delegate = new efl_task_flags_get_delegate(flags_get);
202 if (methods.FirstOrDefault(m => m.Name == "GetFlags") != null)
204 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_flags_get"), func = Marshal.GetFunctionPointerForDelegate(efl_task_flags_get_static_delegate) });
207 if (efl_task_flags_set_static_delegate == null)
209 efl_task_flags_set_static_delegate = new efl_task_flags_set_delegate(flags_set);
212 if (methods.FirstOrDefault(m => m.Name == "SetFlags") != null)
214 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_flags_set"), func = Marshal.GetFunctionPointerForDelegate(efl_task_flags_set_static_delegate) });
217 if (efl_task_run_static_delegate == null)
219 efl_task_run_static_delegate = new efl_task_run_delegate(run);
222 if (methods.FirstOrDefault(m => m.Name == "Run") != null)
224 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_run"), func = Marshal.GetFunctionPointerForDelegate(efl_task_run_static_delegate) });
227 if (efl_task_end_static_delegate == null)
229 efl_task_end_static_delegate = new efl_task_end_delegate(end);
232 if (methods.FirstOrDefault(m => m.Name == "End") != null)
234 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_task_end"), func = Marshal.GetFunctionPointerForDelegate(efl_task_end_static_delegate) });
237 descs.AddRange(base.GetEoOps(type));
240 /// <summary>Returns the Eo class for the native methods of this class.</summary>
241 /// <returns>The native class pointer.</returns>
242 public override IntPtr GetEflClass()
244 return Efl.Task.efl_task_class_get();
247 #pragma warning disable CA1707, CS1591, SA1300, SA1600
250 private delegate Efl.TaskPriority efl_task_priority_get_delegate(System.IntPtr obj, System.IntPtr pd);
253 public delegate Efl.TaskPriority efl_task_priority_get_api_delegate(System.IntPtr obj);
255 public static Efl.Eo.FunctionWrapper<efl_task_priority_get_api_delegate> efl_task_priority_get_ptr = new Efl.Eo.FunctionWrapper<efl_task_priority_get_api_delegate>(Module, "efl_task_priority_get");
257 private static Efl.TaskPriority priority_get(System.IntPtr obj, System.IntPtr pd)
259 Eina.Log.Debug("function efl_task_priority_get was called");
260 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
263 Efl.TaskPriority _ret_var = default(Efl.TaskPriority);
266 _ret_var = ((Task)ws.Target).GetPriority();
270 Eina.Log.Warning($"Callback error: {e.ToString()}");
271 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
279 return efl_task_priority_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
283 private static efl_task_priority_get_delegate efl_task_priority_get_static_delegate;
286 private delegate void efl_task_priority_set_delegate(System.IntPtr obj, System.IntPtr pd, Efl.TaskPriority priority);
289 public delegate void efl_task_priority_set_api_delegate(System.IntPtr obj, Efl.TaskPriority priority);
291 public static Efl.Eo.FunctionWrapper<efl_task_priority_set_api_delegate> efl_task_priority_set_ptr = new Efl.Eo.FunctionWrapper<efl_task_priority_set_api_delegate>(Module, "efl_task_priority_set");
293 private static void priority_set(System.IntPtr obj, System.IntPtr pd, Efl.TaskPriority priority)
295 Eina.Log.Debug("function efl_task_priority_set was called");
296 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
302 ((Task)ws.Target).SetPriority(priority);
306 Eina.Log.Warning($"Callback error: {e.ToString()}");
307 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
314 efl_task_priority_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), priority);
318 private static efl_task_priority_set_delegate efl_task_priority_set_static_delegate;
321 private delegate int efl_task_exit_code_get_delegate(System.IntPtr obj, System.IntPtr pd);
324 public delegate int efl_task_exit_code_get_api_delegate(System.IntPtr obj);
326 public static Efl.Eo.FunctionWrapper<efl_task_exit_code_get_api_delegate> efl_task_exit_code_get_ptr = new Efl.Eo.FunctionWrapper<efl_task_exit_code_get_api_delegate>(Module, "efl_task_exit_code_get");
328 private static int exit_code_get(System.IntPtr obj, System.IntPtr pd)
330 Eina.Log.Debug("function efl_task_exit_code_get was called");
331 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
334 int _ret_var = default(int);
337 _ret_var = ((Task)ws.Target).GetExitCode();
341 Eina.Log.Warning($"Callback error: {e.ToString()}");
342 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
350 return efl_task_exit_code_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
354 private static efl_task_exit_code_get_delegate efl_task_exit_code_get_static_delegate;
357 private delegate Efl.TaskFlags efl_task_flags_get_delegate(System.IntPtr obj, System.IntPtr pd);
360 public delegate Efl.TaskFlags efl_task_flags_get_api_delegate(System.IntPtr obj);
362 public static Efl.Eo.FunctionWrapper<efl_task_flags_get_api_delegate> efl_task_flags_get_ptr = new Efl.Eo.FunctionWrapper<efl_task_flags_get_api_delegate>(Module, "efl_task_flags_get");
364 private static Efl.TaskFlags flags_get(System.IntPtr obj, System.IntPtr pd)
366 Eina.Log.Debug("function efl_task_flags_get was called");
367 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
370 Efl.TaskFlags _ret_var = default(Efl.TaskFlags);
373 _ret_var = ((Task)ws.Target).GetFlags();
377 Eina.Log.Warning($"Callback error: {e.ToString()}");
378 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
386 return efl_task_flags_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
390 private static efl_task_flags_get_delegate efl_task_flags_get_static_delegate;
393 private delegate void efl_task_flags_set_delegate(System.IntPtr obj, System.IntPtr pd, Efl.TaskFlags flags);
396 public delegate void efl_task_flags_set_api_delegate(System.IntPtr obj, Efl.TaskFlags flags);
398 public static Efl.Eo.FunctionWrapper<efl_task_flags_set_api_delegate> efl_task_flags_set_ptr = new Efl.Eo.FunctionWrapper<efl_task_flags_set_api_delegate>(Module, "efl_task_flags_set");
400 private static void flags_set(System.IntPtr obj, System.IntPtr pd, Efl.TaskFlags flags)
402 Eina.Log.Debug("function efl_task_flags_set was called");
403 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
409 ((Task)ws.Target).SetFlags(flags);
413 Eina.Log.Warning($"Callback error: {e.ToString()}");
414 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
421 efl_task_flags_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), flags);
425 private static efl_task_flags_set_delegate efl_task_flags_set_static_delegate;
427 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]
428 private delegate Eina.Future efl_task_run_delegate(System.IntPtr obj, System.IntPtr pd);
430 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]
431 public delegate Eina.Future efl_task_run_api_delegate(System.IntPtr obj);
433 public static Efl.Eo.FunctionWrapper<efl_task_run_api_delegate> efl_task_run_ptr = new Efl.Eo.FunctionWrapper<efl_task_run_api_delegate>(Module, "efl_task_run");
435 private static Eina.Future run(System.IntPtr obj, System.IntPtr pd)
437 Eina.Log.Debug("function efl_task_run was called");
438 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
441 Eina.Future _ret_var = default( Eina.Future);
444 _ret_var = ((Task)ws.Target).Run();
448 Eina.Log.Warning($"Callback error: {e.ToString()}");
449 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
457 return efl_task_run_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
461 private static efl_task_run_delegate efl_task_run_static_delegate;
464 private delegate void efl_task_end_delegate(System.IntPtr obj, System.IntPtr pd);
467 public delegate void efl_task_end_api_delegate(System.IntPtr obj);
469 public static Efl.Eo.FunctionWrapper<efl_task_end_api_delegate> efl_task_end_ptr = new Efl.Eo.FunctionWrapper<efl_task_end_api_delegate>(Module, "efl_task_end");
471 private static void end(System.IntPtr obj, System.IntPtr pd)
473 Eina.Log.Debug("function efl_task_end was called");
474 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
480 ((Task)ws.Target).End();
484 Eina.Log.Warning($"Callback error: {e.ToString()}");
485 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
492 efl_task_end_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
496 private static efl_task_end_delegate efl_task_end_static_delegate;
498 #pragma warning restore CA1707, CS1591, SA1300, SA1600
506 /// <summary>How much processor time will this task get compared to other tasks running on the same processor.
507 /// (Since EFL 1.22)</summary>
508 [Efl.Eo.BindingEntity]
509 public enum TaskPriority
511 /// <summary>Neither above nor below average priority. This is the default.</summary>
513 /// <summary>Far below average priority.</summary>
515 /// <summary>Below average priority.</summary>
517 /// <summary>Above average priority.</summary>
519 /// <summary>Far above average priority.</summary>
527 /// <summary>Flags to further customize task's behavior.
528 /// (Since EFL 1.22)</summary>
529 [Efl.Eo.BindingEntity]
530 public enum TaskFlags
532 /// <summary>No special flags.</summary>
534 /// <summary>Task will require console input.</summary>
536 /// <summary>Task will require console output.</summary>
538 /// <summary>Task will not produce an exit code upon termination.</summary>