1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
7 namespace Efl { namespace Ui {
8 /// <summary>Efl Ui Factory that provides object caching.
9 /// This factory handles caching of one type of object that must be an <see cref="Efl.Gfx.Entity"/> with an <see cref="Efl.Ui.View"/> interface defined. This factory will rely on its parent class <see cref="Efl.Ui.WidgetFactory"/> for creating the subset of class that match <see cref="Efl.Ui.Widget"/> interface. The factory will automatically empties the cache when the application goes into pause.
11 /// Creating objects is costly and time consuming, keeping a few on hand for when you next will need them helps a lot. This is what this factory caching infrastructure provides. It will create the object from the class defined on it and set the parent and the model as needed for all created items. The View has to release the Item using the release function of the Factory interface for all of this to work properly.
13 /// The cache might decide to flush itself when the application event pause is triggered.</summary>
14 [CachingFactoryNativeInherit]
15 public class CachingFactory : Efl.Ui.WidgetFactory, Efl.Eo.IWrapper
17 public new static System.IntPtr klass = System.IntPtr.Zero;
18 public new static Efl.Ui.CachingFactoryNativeInherit nativeInherit = new Efl.Ui.CachingFactoryNativeInherit();
19 ///<summary>Pointer to the native class description.</summary>
20 public override System.IntPtr NativeClass {
22 if (((object)this).GetType() == typeof (CachingFactory))
23 return Efl.Ui.CachingFactoryNativeInherit.GetEflClassStatic();
25 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
28 [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)] internal static extern System.IntPtr
29 efl_ui_caching_factory_class_get();
30 ///<summary>Creates a new instance.</summary>
31 ///<param name="parent">Parent instance.</param>
32 ///<param name="itemClass">Define the class of the item returned by this factory. See <see cref="Efl.Ui.WidgetFactory.SetItemClass"/></param>
33 public CachingFactory(Efl.Object parent
34 , Type itemClass = null) :
35 base(efl_ui_caching_factory_class_get(), typeof(CachingFactory), parent)
37 if (Efl.Eo.Globals.ParamHelperCheck(itemClass))
38 SetItemClass(Efl.Eo.Globals.GetParamHelper(itemClass));
39 FinishInstantiation();
41 ///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
42 public CachingFactory(System.IntPtr raw) : base(raw)
44 register_event_proxies();
46 ///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
47 protected CachingFactory(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}
48 ///<summary>Casts obj into an instance of this type.</summary>
49 public new static CachingFactory static_cast(Efl.Object obj)
52 throw new System.ArgumentNullException("obj");
53 return new CachingFactory(obj.NativeHandle);
55 ///<summary>Verifies if the given object is equal to this one.</summary>
56 public override bool Equals(object obj)
58 var other = obj as Efl.Object;
61 return this.NativeHandle == other.NativeHandle;
63 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
64 public override int GetHashCode()
66 return this.NativeHandle.ToInt32();
68 ///<summary>Turns the native pointer into a string representation.</summary>
69 public override String ToString()
71 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
73 protected override void register_event_proxies()
75 base.register_event_proxies();
77 /// <summary>Define the maxium size in Bytes that all the object waiting on standby in the cache take. They must provide the <see cref="Efl.Cached.Item"/> interface for an accurate accounting.</summary>
78 /// <returns>When set to zero, there is no limit on the amount of memory the cache will use.</returns>
79 virtual public uint GetMemoryLimit() {
80 var _ret_var = Efl.Ui.CachingFactoryNativeInherit.efl_ui_caching_factory_memory_limit_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
81 Eina.Error.RaiseIfUnhandledException();
84 /// <summary>Define the maxium size in Bytes that all the object waiting on standby in the cache take. They must provide the <see cref="Efl.Cached.Item"/> interface for an accurate accounting.</summary>
85 /// <param name="limit">When set to zero, there is no limit on the amount of memory the cache will use.</param>
86 /// <returns></returns>
87 virtual public void SetMemoryLimit( uint limit) {
88 Efl.Ui.CachingFactoryNativeInherit.efl_ui_caching_factory_memory_limit_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), limit);
89 Eina.Error.RaiseIfUnhandledException();
91 /// <summary>Define how many maximum number of items are waiting on standby in the cache.</summary>
92 /// <returns>When set to zero, there is no limit to the amount of items stored in the cache.</returns>
93 virtual public uint GetItemsLimit() {
94 var _ret_var = Efl.Ui.CachingFactoryNativeInherit.efl_ui_caching_factory_items_limit_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
95 Eina.Error.RaiseIfUnhandledException();
98 /// <summary>Define how many maximum number of items are waiting on standby in the cache.</summary>
99 /// <param name="limit">When set to zero, there is no limit to the amount of items stored in the cache.</param>
100 /// <returns></returns>
101 virtual public void SetItemsLimit( uint limit) {
102 Efl.Ui.CachingFactoryNativeInherit.efl_ui_caching_factory_items_limit_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), limit);
103 Eina.Error.RaiseIfUnhandledException();
105 /// <summary>Define the maxium size in Bytes that all the object waiting on standby in the cache take. They must provide the <see cref="Efl.Cached.Item"/> interface for an accurate accounting.</summary>
106 /// <value>When set to zero, there is no limit on the amount of memory the cache will use.</value>
107 public uint MemoryLimit {
108 get { return GetMemoryLimit(); }
109 set { SetMemoryLimit( value); }
111 /// <summary>Define how many maximum number of items are waiting on standby in the cache.</summary>
112 /// <value>When set to zero, there is no limit to the amount of items stored in the cache.</value>
113 public uint ItemsLimit {
114 get { return GetItemsLimit(); }
115 set { SetItemsLimit( value); }
117 private static new IntPtr GetEflClassStatic()
119 return Efl.Ui.CachingFactory.efl_ui_caching_factory_class_get();
122 public class CachingFactoryNativeInherit : Efl.Ui.WidgetFactoryNativeInherit{
123 public new static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Elementary);
124 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
126 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
127 if (efl_ui_caching_factory_memory_limit_get_static_delegate == null)
128 efl_ui_caching_factory_memory_limit_get_static_delegate = new efl_ui_caching_factory_memory_limit_get_delegate(memory_limit_get);
129 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_caching_factory_memory_limit_get"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_caching_factory_memory_limit_get_static_delegate)});
130 if (efl_ui_caching_factory_memory_limit_set_static_delegate == null)
131 efl_ui_caching_factory_memory_limit_set_static_delegate = new efl_ui_caching_factory_memory_limit_set_delegate(memory_limit_set);
132 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_caching_factory_memory_limit_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_caching_factory_memory_limit_set_static_delegate)});
133 if (efl_ui_caching_factory_items_limit_get_static_delegate == null)
134 efl_ui_caching_factory_items_limit_get_static_delegate = new efl_ui_caching_factory_items_limit_get_delegate(items_limit_get);
135 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_caching_factory_items_limit_get"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_caching_factory_items_limit_get_static_delegate)});
136 if (efl_ui_caching_factory_items_limit_set_static_delegate == null)
137 efl_ui_caching_factory_items_limit_set_static_delegate = new efl_ui_caching_factory_items_limit_set_delegate(items_limit_set);
138 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_ui_caching_factory_items_limit_set"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_caching_factory_items_limit_set_static_delegate)});
139 descs.AddRange(base.GetEoOps(type));
142 public override IntPtr GetEflClass()
144 return Efl.Ui.CachingFactory.efl_ui_caching_factory_class_get();
146 public static new IntPtr GetEflClassStatic()
148 return Efl.Ui.CachingFactory.efl_ui_caching_factory_class_get();
152 private delegate uint efl_ui_caching_factory_memory_limit_get_delegate(System.IntPtr obj, System.IntPtr pd);
155 public delegate uint efl_ui_caching_factory_memory_limit_get_api_delegate(System.IntPtr obj);
156 public static Efl.Eo.FunctionWrapper<efl_ui_caching_factory_memory_limit_get_api_delegate> efl_ui_caching_factory_memory_limit_get_ptr = new Efl.Eo.FunctionWrapper<efl_ui_caching_factory_memory_limit_get_api_delegate>(_Module, "efl_ui_caching_factory_memory_limit_get");
157 private static uint memory_limit_get(System.IntPtr obj, System.IntPtr pd)
159 Eina.Log.Debug("function efl_ui_caching_factory_memory_limit_get was called");
160 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
161 if(wrapper != null) {
162 uint _ret_var = default( uint);
164 _ret_var = ((CachingFactory)wrapper).GetMemoryLimit();
165 } catch (Exception e) {
166 Eina.Log.Warning($"Callback error: {e.ToString()}");
167 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
171 return efl_ui_caching_factory_memory_limit_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
174 private static efl_ui_caching_factory_memory_limit_get_delegate efl_ui_caching_factory_memory_limit_get_static_delegate;
177 private delegate void efl_ui_caching_factory_memory_limit_set_delegate(System.IntPtr obj, System.IntPtr pd, uint limit);
180 public delegate void efl_ui_caching_factory_memory_limit_set_api_delegate(System.IntPtr obj, uint limit);
181 public static Efl.Eo.FunctionWrapper<efl_ui_caching_factory_memory_limit_set_api_delegate> efl_ui_caching_factory_memory_limit_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_caching_factory_memory_limit_set_api_delegate>(_Module, "efl_ui_caching_factory_memory_limit_set");
182 private static void memory_limit_set(System.IntPtr obj, System.IntPtr pd, uint limit)
184 Eina.Log.Debug("function efl_ui_caching_factory_memory_limit_set was called");
185 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
186 if(wrapper != null) {
189 ((CachingFactory)wrapper).SetMemoryLimit( limit);
190 } catch (Exception e) {
191 Eina.Log.Warning($"Callback error: {e.ToString()}");
192 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
195 efl_ui_caching_factory_memory_limit_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), limit);
198 private static efl_ui_caching_factory_memory_limit_set_delegate efl_ui_caching_factory_memory_limit_set_static_delegate;
201 private delegate uint efl_ui_caching_factory_items_limit_get_delegate(System.IntPtr obj, System.IntPtr pd);
204 public delegate uint efl_ui_caching_factory_items_limit_get_api_delegate(System.IntPtr obj);
205 public static Efl.Eo.FunctionWrapper<efl_ui_caching_factory_items_limit_get_api_delegate> efl_ui_caching_factory_items_limit_get_ptr = new Efl.Eo.FunctionWrapper<efl_ui_caching_factory_items_limit_get_api_delegate>(_Module, "efl_ui_caching_factory_items_limit_get");
206 private static uint items_limit_get(System.IntPtr obj, System.IntPtr pd)
208 Eina.Log.Debug("function efl_ui_caching_factory_items_limit_get was called");
209 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
210 if(wrapper != null) {
211 uint _ret_var = default( uint);
213 _ret_var = ((CachingFactory)wrapper).GetItemsLimit();
214 } catch (Exception e) {
215 Eina.Log.Warning($"Callback error: {e.ToString()}");
216 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
220 return efl_ui_caching_factory_items_limit_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
223 private static efl_ui_caching_factory_items_limit_get_delegate efl_ui_caching_factory_items_limit_get_static_delegate;
226 private delegate void efl_ui_caching_factory_items_limit_set_delegate(System.IntPtr obj, System.IntPtr pd, uint limit);
229 public delegate void efl_ui_caching_factory_items_limit_set_api_delegate(System.IntPtr obj, uint limit);
230 public static Efl.Eo.FunctionWrapper<efl_ui_caching_factory_items_limit_set_api_delegate> efl_ui_caching_factory_items_limit_set_ptr = new Efl.Eo.FunctionWrapper<efl_ui_caching_factory_items_limit_set_api_delegate>(_Module, "efl_ui_caching_factory_items_limit_set");
231 private static void items_limit_set(System.IntPtr obj, System.IntPtr pd, uint limit)
233 Eina.Log.Debug("function efl_ui_caching_factory_items_limit_set was called");
234 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
235 if(wrapper != null) {
238 ((CachingFactory)wrapper).SetItemsLimit( limit);
239 } catch (Exception e) {
240 Eina.Log.Warning($"Callback error: {e.ToString()}");
241 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
244 efl_ui_caching_factory_items_limit_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), limit);
247 private static efl_ui_caching_factory_items_limit_set_delegate efl_ui_caching_factory_items_limit_set_static_delegate;