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