[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ItemFactory.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System.ComponentModel;
19 using System.Reflection;
20 using Tizen.NUI.BaseComponents;
21
22 namespace Tizen.NUI
23 {
24     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class ItemFactory : Disposable
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         /// <summary>swigCMemOwn.</summary>
31         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
32         protected bool swigCMemOwn;
33
34         internal ItemFactory(global::System.IntPtr cPtr, bool cMemoryOwn)
35         {
36             swigCMemOwn = cMemoryOwn;
37             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38         }
39
40         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ItemFactory obj)
41         {
42             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43         }
44
45         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
46         [EditorBrowsable(EditorBrowsableState.Never)]
47         protected override void Dispose(DisposeTypes type)
48         {
49             if (disposed)
50             {
51                 return;
52             }
53
54             //Release your own unmanaged resources here.
55             //You should not access any managed member here except static instance.
56             //because the execution order of Finalizes is non-deterministic.
57
58             if (swigCPtr.Handle != global::System.IntPtr.Zero)
59             {
60                 if (swigCMemOwn)
61                 {
62                     swigCMemOwn = false;
63                     Interop.ItemFactory.delete_ItemFactory(swigCPtr);
64                 }
65                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
66             }
67
68             base.Dispose(type);
69         }
70
71         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public virtual uint GetNumberOfItems()
74         {
75             uint ret = Interop.ItemFactory.ItemFactory_GetNumberOfItems(swigCPtr);
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77             return ret;
78         }
79
80         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public virtual View NewItem(uint itemId)
83         {
84             View ret = new View(Interop.ItemFactory.ItemFactory_NewItem(swigCPtr, itemId), true);
85             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             return ret;
87         }
88
89         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
90         [EditorBrowsable(EditorBrowsableState.Never)]
91         public virtual void ItemReleased(uint itemId, View view)
92         {
93             if (SwigDerivedClassHasMethod("ItemReleased", swigMethodTypes2)) Interop.ItemFactory.ItemFactory_ItemReleasedSwigExplicitItemFactory(swigCPtr, itemId, View.getCPtr(view)); else Interop.ItemFactory.ItemFactory_ItemReleased(swigCPtr, itemId, View.getCPtr(view));
94             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95         }
96
97         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
98         [EditorBrowsable(EditorBrowsableState.Never)]
99         public ItemFactory() : this(Interop.ItemFactory.new_ItemFactory(), true)
100         {
101             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102             SwigDirectorConnect();
103         }
104
105         private void SwigDirectorConnect()
106         {
107             if (SwigDerivedClassHasMethod("GetNumberOfItems", swigMethodTypes0))
108                 swigDelegate0 = new SwigDelegateItemFactory_0(SwigDirectorGetNumberOfItems);
109             if (SwigDerivedClassHasMethod("NewItem", swigMethodTypes1))
110                 swigDelegate1 = new SwigDelegateItemFactory_1(SwigDirectorNewItem);
111             if (SwigDerivedClassHasMethod("ItemReleased", swigMethodTypes2))
112                 swigDelegate2 = new SwigDelegateItemFactory_2(SwigDirectorItemReleased);
113             Interop.ItemFactory.ItemFactory_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2);
114         }
115
116         private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)
117         {
118             global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, methodTypes);
119             bool hasDerivedMethod = this.GetType().GetTypeInfo().IsSubclassOf(typeof(ItemFactory));
120             NUILog.Debug("hasDerivedMethod=" + hasDerivedMethod);
121             return hasDerivedMethod && (methodInfo != null);
122         }
123
124         private uint SwigDirectorGetNumberOfItems()
125         {
126             return GetNumberOfItems();
127         }
128
129         private global::System.IntPtr SwigDirectorNewItem(uint itemId)
130         {
131             return View.getCPtr(NewItem(itemId)).Handle;
132         }
133
134         private void SwigDirectorItemReleased(uint itemId, global::System.IntPtr actor)
135         {
136             ItemReleased(itemId, new View(actor, true));
137         }
138
139         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         public delegate uint SwigDelegateItemFactory_0();
142
143         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public delegate global::System.IntPtr SwigDelegateItemFactory_1(uint itemId);
146
147         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
148         [EditorBrowsable(EditorBrowsableState.Never)]
149         public delegate void SwigDelegateItemFactory_2(uint itemId, global::System.IntPtr actor);
150
151         private SwigDelegateItemFactory_0 swigDelegate0;
152         private SwigDelegateItemFactory_1 swigDelegate1;
153         private SwigDelegateItemFactory_2 swigDelegate2;
154
155         private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { };
156         private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] { typeof(uint) };
157         private static global::System.Type[] swigMethodTypes2 = new global::System.Type[] { typeof(uint), typeof(View) };
158     }
159 }