2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Reflection;
22 using Tizen.NUI.BaseComponents;
23 internal class ItemFactory : global::System.IDisposable
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 protected bool swigCMemOwn;
28 internal ItemFactory(global::System.IntPtr cPtr, bool cMemoryOwn)
30 swigCMemOwn = cMemoryOwn;
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ItemFactory obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 //A Flag to check who called Dispose(). (By User or DisposeQueue)
40 private bool isDisposeQueued = false;
41 //A Flat to check if it is already disposed.
42 protected bool disposed = false;
49 isDisposeQueued = true;
50 DisposeQueue.Instance.Add(this);
56 //Throw excpetion if Dispose() is called in separate thread.
57 if (!Window.IsInstalled())
59 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
64 Dispose(DisposeTypes.Implicit);
68 Dispose(DisposeTypes.Explicit);
69 System.GC.SuppressFinalize(this);
73 protected virtual void Dispose(DisposeTypes type)
80 if (type == DisposeTypes.Explicit)
83 //Release your own managed resources here.
84 //You should release all of your own disposable objects here.
88 //Release your own unmanaged resources here.
89 //You should not access any managed member here except static instance.
90 //because the execution order of Finalizes is non-deterministic.
92 if (swigCPtr.Handle != global::System.IntPtr.Zero)
97 Interop.ItemFactory.delete_ItemFactory(swigCPtr);
99 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
105 public virtual uint GetNumberOfItems()
107 uint ret = Interop.ItemFactory.ItemFactory_GetNumberOfItems(swigCPtr);
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 public virtual View NewItem(uint itemId)
114 View ret = new View(Interop.ItemFactory.ItemFactory_NewItem(swigCPtr, itemId), true);
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 public virtual void ItemReleased(uint itemId, View view)
121 if (SwigDerivedClassHasMethod("ItemReleased", swigMethodTypes2)) Interop.ItemFactory.ItemFactory_ItemReleasedSwigExplicitItemFactory(swigCPtr, itemId, View.getCPtr(view)); else Interop.ItemFactory.ItemFactory_ItemReleased(swigCPtr, itemId, View.getCPtr(view));
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 public ItemFactory() : this(Interop.ItemFactory.new_ItemFactory(), true)
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128 SwigDirectorConnect();
131 private void SwigDirectorConnect()
133 if (SwigDerivedClassHasMethod("GetNumberOfItems", swigMethodTypes0))
134 swigDelegate0 = new SwigDelegateItemFactory_0(SwigDirectorGetNumberOfItems);
135 if (SwigDerivedClassHasMethod("NewItem", swigMethodTypes1))
136 swigDelegate1 = new SwigDelegateItemFactory_1(SwigDirectorNewItem);
137 if (SwigDerivedClassHasMethod("ItemReleased", swigMethodTypes2))
138 swigDelegate2 = new SwigDelegateItemFactory_2(SwigDirectorItemReleased);
139 Interop.ItemFactory.ItemFactory_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2);
142 private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)
144 global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, methodTypes);
145 bool hasDerivedMethod = this.GetType().GetTypeInfo().IsSubclassOf(typeof(ItemFactory));
146 NUILog.Debug("hasDerivedMethod=" + hasDerivedMethod);
147 return hasDerivedMethod && (methodInfo != null);
150 private uint SwigDirectorGetNumberOfItems()
152 return GetNumberOfItems();
155 private global::System.IntPtr SwigDirectorNewItem(uint itemId)
157 return View.getCPtr(NewItem(itemId)).Handle;
160 private void SwigDirectorItemReleased(uint itemId, global::System.IntPtr actor)
162 ItemReleased(itemId, new View(actor, true));
165 /// <since_tizen> 3 </since_tizen>
166 public delegate uint SwigDelegateItemFactory_0();
167 /// <since_tizen> 3 </since_tizen>
168 public delegate global::System.IntPtr SwigDelegateItemFactory_1(uint itemId);
169 /// <since_tizen> 3 </since_tizen>
170 public delegate void SwigDelegateItemFactory_2(uint itemId, global::System.IntPtr actor);
172 private SwigDelegateItemFactory_0 swigDelegate0;
173 private SwigDelegateItemFactory_1 swigDelegate1;
174 private SwigDelegateItemFactory_2 swigDelegate2;
176 private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { };
177 private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] { typeof(uint) };
178 private static global::System.Type[] swigMethodTypes2 = new global::System.Type[] { typeof(uint), typeof(View) };