Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Any.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     internal class Any : global::System.IDisposable
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23         protected bool swigCMemOwn;
24
25         internal Any(global::System.IntPtr cPtr, bool cMemoryOwn)
26         {
27             swigCMemOwn = cMemoryOwn;
28             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
29         }
30
31         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Any obj)
32         {
33             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
34         }
35
36         //A Flag to check who called Dispose(). (By User or DisposeQueue)
37         private bool isDisposeQueued = false;
38         //A Flat to check if it is already disposed.
39         protected bool disposed = false;
40
41         ~Any()
42         {
43             if (!isDisposeQueued)
44             {
45                 isDisposeQueued = true;
46                 DisposeQueue.Instance.Add(this);
47             }
48         }
49
50         public void Dispose()
51         {
52             //Throw excpetion if Dispose() is called in separate thread.
53             if (!Window.IsInstalled())
54             {
55                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
56             }
57
58             if (isDisposeQueued)
59             {
60                 Dispose(DisposeTypes.Implicit);
61             }
62             else
63             {
64                 Dispose(DisposeTypes.Explicit);
65                 System.GC.SuppressFinalize(this);
66             }
67         }
68
69         protected virtual void Dispose(DisposeTypes type)
70         {
71             if (disposed)
72             {
73                 return;
74             }
75
76             if (type == DisposeTypes.Explicit)
77             {
78                 //Called by User
79                 //Release your own managed resources here.
80                 //You should release all of your own disposable objects here.
81
82             }
83
84             //Release your own unmanaged resources here.
85             //You should not access any managed member here except static instance.
86             //because the execution order of Finalizes is non-deterministic.
87
88             if (swigCPtr.Handle != global::System.IntPtr.Zero)
89             {
90                 if (swigCMemOwn)
91                 {
92                     swigCMemOwn = false;
93                     NDalicPINVOKE.delete_Any(swigCPtr);
94                 }
95                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
96             }
97
98             disposed = true;
99         }
100
101
102         public Any() : this(NDalicPINVOKE.new_Any__SWIG_0(), true)
103         {
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105         }
106
107         public static void AssertAlways(string assertMessage)
108         {
109             NDalicPINVOKE.Any_AssertAlways(assertMessage);
110             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111         }
112
113         public Any(Any any) : this(NDalicPINVOKE.new_Any__SWIG_2(Any.getCPtr(any)), true)
114         {
115             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116         }
117
118         public Any Assign(Any any)
119         {
120             Any ret = new Any(NDalicPINVOKE.Any_Assign(swigCPtr, Any.getCPtr(any)), false);
121             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122             return ret;
123         }
124
125         public SWIGTYPE_p_std__type_info GetType()
126         {
127             SWIGTYPE_p_std__type_info ret = new SWIGTYPE_p_std__type_info(NDalicPINVOKE.Any_GetType(swigCPtr), false);
128             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129             return ret;
130         }
131
132         public bool Empty()
133         {
134             bool ret = NDalicPINVOKE.Any_Empty(swigCPtr);
135             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136             return ret;
137         }
138
139         public class AnyContainerBase : global::System.IDisposable
140         {
141             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
142             protected bool swigCMemOwn;
143
144             internal AnyContainerBase(global::System.IntPtr cPtr, bool cMemoryOwn)
145             {
146                 swigCMemOwn = cMemoryOwn;
147                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
148             }
149
150             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AnyContainerBase obj)
151             {
152                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
153             }
154
155             //A Flag to check who called Dispose(). (By User or DisposeQueue)
156             private bool isDisposeQueued = false;
157             //A Flat to check if it is already disposed.
158             protected bool disposed = false;
159
160             ~AnyContainerBase()
161             {
162                 if (!isDisposeQueued)
163                 {
164                     isDisposeQueued = true;
165                     DisposeQueue.Instance.Add(this);
166                 }
167             }
168
169             public void Dispose()
170             {
171                 //Throw excpetion if Dispose() is called in separate thread.
172                 if (!Window.IsInstalled())
173                 {
174                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
175                 }
176
177                 if (isDisposeQueued)
178                 {
179                     Dispose(DisposeTypes.Implicit);
180                 }
181                 else
182                 {
183                     Dispose(DisposeTypes.Explicit);
184                     System.GC.SuppressFinalize(this);
185                 }
186             }
187
188             protected virtual void Dispose(DisposeTypes type)
189             {
190                 if (disposed)
191                 {
192                     return;
193                 }
194
195                 if (type == DisposeTypes.Explicit)
196                 {
197                     //Called by User
198                     //Release your own managed resources here.
199                     //You should release all of your own disposable objects here.
200
201                 }
202
203                 //Release your own unmanaged resources here.
204                 //You should not access any managed member here except static instance.
205                 //because the execution order of Finalizes is non-deterministic.
206
207                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
208                 {
209                     if (swigCMemOwn)
210                     {
211                         swigCMemOwn = false;
212                         NDalicPINVOKE.delete_Any_AnyContainerBase(swigCPtr);
213                     }
214                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
215                 }
216
217                 disposed = true;
218             }
219
220             public AnyContainerBase(SWIGTYPE_p_std__type_info type, SWIGTYPE_p_f_r_q_const__Dali__Any__AnyContainerBase__p_Dali__Any__AnyContainerBase cloneFunc, SWIGTYPE_p_f_p_q_const__Dali__Any__AnyContainerBase__void deleteFunc) : this(NDalicPINVOKE.new_Any_AnyContainerBase(SWIGTYPE_p_std__type_info.getCPtr(type), SWIGTYPE_p_f_r_q_const__Dali__Any__AnyContainerBase__p_Dali__Any__AnyContainerBase.getCPtr(cloneFunc), SWIGTYPE_p_f_p_q_const__Dali__Any__AnyContainerBase__void.getCPtr(deleteFunc)), true)
221             {
222                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223             }
224
225             public SWIGTYPE_p_std__type_info GetType()
226             {
227                 SWIGTYPE_p_std__type_info ret = new SWIGTYPE_p_std__type_info(NDalicPINVOKE.Any_AnyContainerBase_GetType(swigCPtr), false);
228                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229                 return ret;
230             }
231
232             public SWIGTYPE_p_std__type_info mType
233             {
234                 get
235                 {
236                     SWIGTYPE_p_std__type_info ret = new SWIGTYPE_p_std__type_info(NDalicPINVOKE.Any_AnyContainerBase_mType_get(swigCPtr), false);
237                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238                     return ret;
239                 }
240             }
241
242             public SWIGTYPE_p_f_r_q_const__Dali__Any__AnyContainerBase__p_Dali__Any__AnyContainerBase mCloneFunc
243             {
244                 set
245                 {
246                     NDalicPINVOKE.Any_AnyContainerBase_mCloneFunc_set(swigCPtr, SWIGTYPE_p_f_r_q_const__Dali__Any__AnyContainerBase__p_Dali__Any__AnyContainerBase.getCPtr(value));
247                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248                 }
249                 get
250                 {
251                     global::System.IntPtr cPtr = NDalicPINVOKE.Any_AnyContainerBase_mCloneFunc_get(swigCPtr);
252                     SWIGTYPE_p_f_r_q_const__Dali__Any__AnyContainerBase__p_Dali__Any__AnyContainerBase ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_r_q_const__Dali__Any__AnyContainerBase__p_Dali__Any__AnyContainerBase(cPtr, false);
253                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254                     return ret;
255                 }
256             }
257
258             public SWIGTYPE_p_f_p_q_const__Dali__Any__AnyContainerBase__void mDeleteFunc
259             {
260                 set
261                 {
262                     NDalicPINVOKE.Any_AnyContainerBase_mDeleteFunc_set(swigCPtr, SWIGTYPE_p_f_p_q_const__Dali__Any__AnyContainerBase__void.getCPtr(value));
263                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264                 }
265                 get
266                 {
267                     global::System.IntPtr cPtr = NDalicPINVOKE.Any_AnyContainerBase_mDeleteFunc_get(swigCPtr);
268                     SWIGTYPE_p_f_p_q_const__Dali__Any__AnyContainerBase__void ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_q_const__Dali__Any__AnyContainerBase__void(cPtr, false);
269                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270                     return ret;
271                 }
272             }
273
274         }
275
276         public Any.AnyContainerBase mContainer
277         {
278             set
279             {
280                 NDalicPINVOKE.Any_mContainer_set(swigCPtr, Any.AnyContainerBase.getCPtr(value));
281                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282             }
283             get
284             {
285                 global::System.IntPtr cPtr = NDalicPINVOKE.Any_mContainer_get(swigCPtr);
286                 Any.AnyContainerBase ret = (cPtr == global::System.IntPtr.Zero) ? null : new Any.AnyContainerBase(cPtr, false);
287                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288                 return ret;
289             }
290         }
291
292     }
293
294 }