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>Class used to create data models from Eina containers.
11 /// Each container supplied represents a series of property values, each item being the property value for a child object.
13 /// The data in the given containers are copied and stored internally.
15 /// Several containers can be supplied and the number of allocated children is based on the container of the largest size.</summary>
16 [Efl.ContainerModel.NativeMethods]
17 public class ContainerModel : Efl.CompositeModel, Efl.Eo.IWrapper
19 ///<summary>Pointer to the native class description.</summary>
20 public override System.IntPtr NativeClass
24 if (((object)this).GetType() == typeof(ContainerModel))
26 return GetEflClassStatic();
30 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
35 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
36 efl_container_model_class_get();
37 /// <summary>Initializes a new instance of the <see cref="ContainerModel"/> class.</summary>
38 /// <param name="parent">Parent instance.</param>
39 /// <param name="model">Model that is/will be See <see cref="Efl.Ui.IView.SetModel"/></param>
40 /// <param name="index">Position of this object in the parent model. See <see cref="Efl.CompositeModel.SetIndex"/></param>
41 public ContainerModel(Efl.Object parent
42 , Efl.IModel model, uint? index = null) : base(efl_container_model_class_get(), typeof(ContainerModel), parent)
44 if (Efl.Eo.Globals.ParamHelperCheck(model))
46 SetModel(Efl.Eo.Globals.GetParamHelper(model));
49 if (Efl.Eo.Globals.ParamHelperCheck(index))
51 SetIndex(Efl.Eo.Globals.GetParamHelper(index));
54 FinishInstantiation();
57 /// <summary>Initializes a new instance of the <see cref="ContainerModel"/> class.
58 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
59 /// <param name="raw">The native pointer to be wrapped.</param>
60 protected ContainerModel(System.IntPtr raw) : base(raw)
64 /// <summary>Initializes a new instance of the <see cref="ContainerModel"/> class.
65 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
66 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
67 /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
68 /// <param name="parent">The Efl.Object parent of this instance.</param>
69 protected ContainerModel(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)
73 /// <summary>Verifies if the given object is equal to this one.</summary>
74 /// <param name="instance">The object to compare to.</param>
75 /// <returns>True if both objects point to the same native object.</returns>
76 public override bool Equals(object instance)
78 var other = instance as Efl.Object;
83 return this.NativeHandle == other.NativeHandle;
86 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
87 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
88 public override int GetHashCode()
90 return this.NativeHandle.ToInt32();
93 /// <summary>Turns the native pointer into a string representation.</summary>
94 /// <returns>A string with the type and the native pointer for this object.</returns>
95 public override String ToString()
97 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
100 /// <summary>Gets the type of the given property.</summary>
101 /// <param name="name">Property name</param>
102 /// <returns>Property type</returns>
103 virtual public Eina.ValueType GetChildPropertyValueType(System.String name) {
104 var _ret_var = Efl.ContainerModel.NativeMethods.efl_container_model_child_property_value_type_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle),name);
105 Eina.Error.RaiseIfUnhandledException();
108 /// <summary>Adds the given property to child objects and supply the values.
109 /// Each item will represent the value of the given property in the respective child within the data model.
111 /// New children objects are allocated as necessary.
113 /// Value type is required for compatibility with the <see cref="Efl.IModel"/> API.</summary>
114 /// <param name="name">Property name</param>
115 /// <param name="type">Property type</param>
116 /// <param name="values">Values to be added</param>
117 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
118 virtual public bool AddChildProperty(System.String name, Eina.ValueType type, Eina.Iterator<System.IntPtr> values) {
119 var _in_values = values.Handle;
121 var _ret_var = Efl.ContainerModel.NativeMethods.efl_container_model_child_property_add_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle),name, type, _in_values);
122 Eina.Error.RaiseIfUnhandledException();
125 private static IntPtr GetEflClassStatic()
127 return Efl.ContainerModel.efl_container_model_class_get();
129 /// <summary>Wrapper for native methods and virtual method delegates.
130 /// For internal use by generated code only.</summary>
131 public new class NativeMethods : Efl.CompositeModel.NativeMethods
133 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Ecore);
134 /// <summary>Gets the list of Eo operations to override.</summary>
135 /// <returns>The list of Eo operations to be overload.</returns>
136 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
138 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
139 var methods = Efl.Eo.Globals.GetUserMethods(type);
141 if (efl_container_model_child_property_value_type_get_static_delegate == null)
143 efl_container_model_child_property_value_type_get_static_delegate = new efl_container_model_child_property_value_type_get_delegate(child_property_value_type_get);
146 if (methods.FirstOrDefault(m => m.Name == "GetChildPropertyValueType") != null)
148 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_container_model_child_property_value_type_get"), func = Marshal.GetFunctionPointerForDelegate(efl_container_model_child_property_value_type_get_static_delegate) });
151 if (efl_container_model_child_property_add_static_delegate == null)
153 efl_container_model_child_property_add_static_delegate = new efl_container_model_child_property_add_delegate(child_property_add);
156 if (methods.FirstOrDefault(m => m.Name == "AddChildProperty") != null)
158 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_container_model_child_property_add"), func = Marshal.GetFunctionPointerForDelegate(efl_container_model_child_property_add_static_delegate) });
161 descs.AddRange(base.GetEoOps(type));
164 /// <summary>Returns the Eo class for the native methods of this class.</summary>
165 /// <returns>The native class pointer.</returns>
166 public override IntPtr GetEflClass()
168 return Efl.ContainerModel.efl_container_model_class_get();
171 #pragma warning disable CA1707, SA1300, SA1600
174 private delegate Eina.ValueType efl_container_model_child_property_value_type_get_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name);
177 public delegate Eina.ValueType efl_container_model_child_property_value_type_get_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name);
179 public static Efl.Eo.FunctionWrapper<efl_container_model_child_property_value_type_get_api_delegate> efl_container_model_child_property_value_type_get_ptr = new Efl.Eo.FunctionWrapper<efl_container_model_child_property_value_type_get_api_delegate>(Module, "efl_container_model_child_property_value_type_get");
181 private static Eina.ValueType child_property_value_type_get(System.IntPtr obj, System.IntPtr pd, System.String name)
183 Eina.Log.Debug("function efl_container_model_child_property_value_type_get was called");
184 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
187 Eina.ValueType _ret_var = default(Eina.ValueType);
190 _ret_var = ((ContainerModel)wrapper).GetChildPropertyValueType(name);
194 Eina.Log.Warning($"Callback error: {e.ToString()}");
195 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
203 return efl_container_model_child_property_value_type_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), name);
207 private static efl_container_model_child_property_value_type_get_delegate efl_container_model_child_property_value_type_get_static_delegate;
209 [return: MarshalAs(UnmanagedType.U1)]
210 private delegate bool efl_container_model_child_property_add_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name, Eina.ValueType type, System.IntPtr values);
212 [return: MarshalAs(UnmanagedType.U1)]
213 public delegate bool efl_container_model_child_property_add_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name, Eina.ValueType type, System.IntPtr values);
215 public static Efl.Eo.FunctionWrapper<efl_container_model_child_property_add_api_delegate> efl_container_model_child_property_add_ptr = new Efl.Eo.FunctionWrapper<efl_container_model_child_property_add_api_delegate>(Module, "efl_container_model_child_property_add");
217 private static bool child_property_add(System.IntPtr obj, System.IntPtr pd, System.String name, Eina.ValueType type, System.IntPtr values)
219 Eina.Log.Debug("function efl_container_model_child_property_add was called");
220 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
223 var _in_values = new Eina.Iterator<System.IntPtr>(values, true, false);
224 bool _ret_var = default(bool);
227 _ret_var = ((ContainerModel)wrapper).AddChildProperty(name, type, _in_values);
231 Eina.Log.Warning($"Callback error: {e.ToString()}");
232 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
240 return efl_container_model_child_property_add_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), name, type, values);
244 private static efl_container_model_child_property_add_delegate efl_container_model_child_property_add_static_delegate;
246 #pragma warning restore CA1707, SA1300, SA1600