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 model for all composite class which provide a unified API to set source of data.
11 /// This class also provide an <see cref="Efl.IModel.GetProperty"/> "<c>child</c>.index" that match the value of <see cref="Efl.CompositeModel.Index"/>.</summary>
12 [Efl.CompositeModel.NativeMethods]
13 public class CompositeModel : Efl.LoopModel, Efl.Eo.IWrapper,Efl.Ui.IView
15 ///<summary>Pointer to the native class description.</summary>
16 public override System.IntPtr NativeClass
20 if (((object)this).GetType() == typeof(CompositeModel))
22 return GetEflClassStatic();
26 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
31 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
32 efl_composite_model_class_get();
33 /// <summary>Initializes a new instance of the <see cref="CompositeModel"/> class.</summary>
34 /// <param name="parent">Parent instance.</param>
35 /// <param name="model">Model that is/will be See <see cref="Efl.Ui.IView.SetModel"/></param>
36 /// <param name="index">Position of this object in the parent model. See <see cref="Efl.CompositeModel.SetIndex"/></param>
37 public CompositeModel(Efl.Object parent
38 , Efl.IModel model, uint? index = null) : base(efl_composite_model_class_get(), typeof(CompositeModel), parent)
40 if (Efl.Eo.Globals.ParamHelperCheck(model))
42 SetModel(Efl.Eo.Globals.GetParamHelper(model));
45 if (Efl.Eo.Globals.ParamHelperCheck(index))
47 SetIndex(Efl.Eo.Globals.GetParamHelper(index));
50 FinishInstantiation();
53 /// <summary>Initializes a new instance of the <see cref="CompositeModel"/> class.
54 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
55 /// <param name="raw">The native pointer to be wrapped.</param>
56 protected CompositeModel(System.IntPtr raw) : base(raw)
60 /// <summary>Initializes a new instance of the <see cref="CompositeModel"/> class.
61 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
62 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
63 /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
64 /// <param name="parent">The Efl.Object parent of this instance.</param>
65 protected CompositeModel(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)
69 /// <summary>Verifies if the given object is equal to this one.</summary>
70 /// <param name="instance">The object to compare to.</param>
71 /// <returns>True if both objects point to the same native object.</returns>
72 public override bool Equals(object instance)
74 var other = instance as Efl.Object;
79 return this.NativeHandle == other.NativeHandle;
82 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
83 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
84 public override int GetHashCode()
86 return this.NativeHandle.ToInt32();
89 /// <summary>Turns the native pointer into a string representation.</summary>
90 /// <returns>A string with the type and the native pointer for this object.</returns>
91 public override String ToString()
93 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
96 /// <summary>Get the index. It will only work after the object has been finalized.</summary>
97 /// <returns>Index of the object in the parent model. The index is uniq and start from zero.</returns>
98 virtual public uint GetIndex() {
99 var _ret_var = Efl.CompositeModel.NativeMethods.efl_composite_model_index_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
100 Eina.Error.RaiseIfUnhandledException();
103 /// <summary>Set the index. It can only be set before the object is finalized, but after the Model it compose is set and only if that Model does not provide an index already.</summary>
104 /// <param name="index">Index of the object in the parent model. The index is uniq and start from zero.</param>
105 virtual public void SetIndex(uint index) {
106 Efl.CompositeModel.NativeMethods.efl_composite_model_index_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle),index);
107 Eina.Error.RaiseIfUnhandledException();
109 /// <summary>Model that is/will be</summary>
110 /// <returns>Efl model</returns>
111 virtual public Efl.IModel GetModel() {
112 var _ret_var = Efl.Ui.IViewConcrete.NativeMethods.efl_ui_view_model_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
113 Eina.Error.RaiseIfUnhandledException();
116 /// <summary>Model that is/will be</summary>
117 /// <param name="model">Efl model</param>
118 virtual public void SetModel(Efl.IModel model) {
119 Efl.Ui.IViewConcrete.NativeMethods.efl_ui_view_model_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle),model);
120 Eina.Error.RaiseIfUnhandledException();
122 /// <summary>Position of this object in the parent model.</summary>
123 /// <value>Index of the object in the parent model. The index is uniq and start from zero.</value>
125 get { return GetIndex(); }
126 set { SetIndex(value); }
128 /// <summary>Model that is/will be</summary>
129 /// <value>Efl model</value>
130 public Efl.IModel Model {
131 get { return GetModel(); }
132 set { SetModel(value); }
134 private static IntPtr GetEflClassStatic()
136 return Efl.CompositeModel.efl_composite_model_class_get();
138 /// <summary>Wrapper for native methods and virtual method delegates.
139 /// For internal use by generated code only.</summary>
140 public new class NativeMethods : Efl.LoopModel.NativeMethods
142 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Ecore);
143 /// <summary>Gets the list of Eo operations to override.</summary>
144 /// <returns>The list of Eo operations to be overload.</returns>
145 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
147 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
148 var methods = Efl.Eo.Globals.GetUserMethods(type);
150 if (efl_composite_model_index_get_static_delegate == null)
152 efl_composite_model_index_get_static_delegate = new efl_composite_model_index_get_delegate(index_get);
155 if (methods.FirstOrDefault(m => m.Name == "GetIndex") != null)
157 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_composite_model_index_get"), func = Marshal.GetFunctionPointerForDelegate(efl_composite_model_index_get_static_delegate) });
160 if (efl_composite_model_index_set_static_delegate == null)
162 efl_composite_model_index_set_static_delegate = new efl_composite_model_index_set_delegate(index_set);
165 if (methods.FirstOrDefault(m => m.Name == "SetIndex") != null)
167 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_composite_model_index_set"), func = Marshal.GetFunctionPointerForDelegate(efl_composite_model_index_set_static_delegate) });
170 if (efl_ui_view_model_get_static_delegate == null)
172 efl_ui_view_model_get_static_delegate = new efl_ui_view_model_get_delegate(model_get);
175 if (methods.FirstOrDefault(m => m.Name == "GetModel") != null)
177 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_view_model_get"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_view_model_get_static_delegate) });
180 if (efl_ui_view_model_set_static_delegate == null)
182 efl_ui_view_model_set_static_delegate = new efl_ui_view_model_set_delegate(model_set);
185 if (methods.FirstOrDefault(m => m.Name == "SetModel") != null)
187 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_view_model_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_view_model_set_static_delegate) });
190 descs.AddRange(base.GetEoOps(type));
193 /// <summary>Returns the Eo class for the native methods of this class.</summary>
194 /// <returns>The native class pointer.</returns>
195 public override IntPtr GetEflClass()
197 return Efl.CompositeModel.efl_composite_model_class_get();
200 #pragma warning disable CA1707, SA1300, SA1600
203 private delegate uint efl_composite_model_index_get_delegate(System.IntPtr obj, System.IntPtr pd);
206 public delegate uint efl_composite_model_index_get_api_delegate(System.IntPtr obj);
208 public static Efl.Eo.FunctionWrapper<efl_composite_model_index_get_api_delegate> efl_composite_model_index_get_ptr = new Efl.Eo.FunctionWrapper<efl_composite_model_index_get_api_delegate>(Module, "efl_composite_model_index_get");
210 private static uint index_get(System.IntPtr obj, System.IntPtr pd)
212 Eina.Log.Debug("function efl_composite_model_index_get was called");
213 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
216 uint _ret_var = default(uint);
219 _ret_var = ((CompositeModel)wrapper).GetIndex();
223 Eina.Log.Warning($"Callback error: {e.ToString()}");
224 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
232 return efl_composite_model_index_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
236 private static efl_composite_model_index_get_delegate efl_composite_model_index_get_static_delegate;
239 private delegate void efl_composite_model_index_set_delegate(System.IntPtr obj, System.IntPtr pd, uint index);
242 public delegate void efl_composite_model_index_set_api_delegate(System.IntPtr obj, uint index);
244 public static Efl.Eo.FunctionWrapper<efl_composite_model_index_set_api_delegate> efl_composite_model_index_set_ptr = new Efl.Eo.FunctionWrapper<efl_composite_model_index_set_api_delegate>(Module, "efl_composite_model_index_set");
246 private static void index_set(System.IntPtr obj, System.IntPtr pd, uint index)
248 Eina.Log.Debug("function efl_composite_model_index_set was called");
249 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
255 ((CompositeModel)wrapper).SetIndex(index);
259 Eina.Log.Warning($"Callback error: {e.ToString()}");
260 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
267 efl_composite_model_index_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), index);
271 private static efl_composite_model_index_set_delegate efl_composite_model_index_set_static_delegate;
273 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
274 private delegate Efl.IModel efl_ui_view_model_get_delegate(System.IntPtr obj, System.IntPtr pd);
276 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
277 public delegate Efl.IModel efl_ui_view_model_get_api_delegate(System.IntPtr obj);
279 public static Efl.Eo.FunctionWrapper<efl_ui_view_model_get_api_delegate> efl_ui_view_model_get_ptr = new Efl.Eo.FunctionWrapper<efl_ui_view_model_get_api_delegate>(Module, "efl_ui_view_model_get");
281 private static Efl.IModel model_get(System.IntPtr obj, System.IntPtr pd)
283 Eina.Log.Debug("function efl_ui_view_model_get was called");
284 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
287 Efl.IModel _ret_var = default(Efl.IModel);
290 _ret_var = ((CompositeModel)wrapper).GetModel();
294 Eina.Log.Warning($"Callback error: {e.ToString()}");
295 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
303 return efl_ui_view_model_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
307 private static efl_ui_view_model_get_delegate efl_ui_view_model_get_static_delegate;
310 private delegate void efl_ui_view_model_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.IModel model);
313 public delegate void efl_ui_view_model_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.IModel model);
315 public static Efl.Eo.FunctionWrapper<efl_ui_view_model_set_api_delegate> efl_ui_view_model_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_view_model_set_api_delegate>(Module, "efl_ui_view_model_set");
317 private static void model_set(System.IntPtr obj, System.IntPtr pd, Efl.IModel model)
319 Eina.Log.Debug("function efl_ui_view_model_set was called");
320 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
326 ((CompositeModel)wrapper).SetModel(model);
330 Eina.Log.Warning($"Callback error: {e.ToString()}");
331 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
338 efl_ui_view_model_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), model);
342 private static efl_ui_view_model_set_delegate efl_ui_view_model_set_static_delegate;
344 #pragma warning restore CA1707, SA1300, SA1600