b7e64b6fe685efd973fbd44d19aef986ec3a0c47
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / LanguageChangedSignalType.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 using System;
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// Please do not use! this will be deprecated
25     /// </summary>
26     [EditorBrowsable(EditorBrowsableState.Never)]
27     public class LanguageChangedSignalType : global::System.IDisposable
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30         /// <summary>
31         /// LanguageChangedSignalType
32         /// </summary>
33         protected bool swigCMemOwn;
34
35         internal LanguageChangedSignalType(global::System.IntPtr cPtr, bool cMemoryOwn)
36         {
37             swigCMemOwn = cMemoryOwn;
38             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
39         }
40
41         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LanguageChangedSignalType obj)
42         {
43             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
44         }
45
46         //A Flag to check who called Dispose(). (By User or DisposeQueue)
47         private bool isDisposeQueued = false;
48         /// <summary>
49         /// A Flat to check if it is already disposed.
50         /// </summary>
51         /// <since_tizen> 3 </since_tizen>
52         protected bool disposed = false;
53
54         /// <summary>
55         /// Dispose
56         /// </summary>
57         ~LanguageChangedSignalType()
58         {
59             if (!isDisposeQueued)
60             {
61                 isDisposeQueued = true;
62                 DisposeQueue.Instance.Add(this);
63             }
64         }
65
66         /// <summary>
67         /// Dispose
68         /// </summary>
69         public void Dispose()
70         {
71             //Throw excpetion if Dispose() is called in separate thread.
72             if (!Window.IsInstalled())
73             {
74                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
75             }
76
77             if (isDisposeQueued)
78             {
79                 Dispose(DisposeTypes.Implicit);
80             }
81             else
82             {
83                 Dispose(DisposeTypes.Explicit);
84                 System.GC.SuppressFinalize(this);
85             }
86         }
87
88         /// <summary>
89         /// Dispose
90         /// </summary>
91         protected virtual void Dispose(DisposeTypes type)
92         {
93             if (disposed)
94             {
95                 return;
96             }
97
98             if (type == DisposeTypes.Explicit)
99             {
100                 //Called by User
101                 //Release your own managed resources here.
102                 //You should release all of your own disposable objects here.
103
104             }
105
106             //Release your own unmanaged resources here.
107             //You should not access any managed member here except static instance.
108             //because the execution order of Finalizes is non-deterministic.
109
110             if (swigCPtr.Handle != global::System.IntPtr.Zero)
111             {
112                 if (swigCMemOwn)
113                 {
114                     swigCMemOwn = false;
115                     NDalicManualPINVOKE.delete_LanguageChangedSignalType(swigCPtr);
116                 }
117                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
118             }
119
120             disposed = true;
121         }
122
123         /// <summary>
124         /// Queries whether there are any connected slots.
125         /// </summary>
126         /// <returns>True if there are any slots connected to the signal</returns>
127         public bool Empty()
128         {
129             bool ret = NDalicManualPINVOKE.LanguageChangedSignalType_Empty(swigCPtr);
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131             return ret;
132         }
133
134         /// <summary>
135         /// Queries the number of slots.
136         /// </summary>
137         /// <returns>The number of slots connected to this signal</returns>
138         public uint GetConnectionCount()
139         {
140             uint ret = NDalicManualPINVOKE.LanguageChangedSignalType_GetConnectionCount(swigCPtr);
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142             return ret;
143         }
144
145         /// <summary>
146         /// Connects a member function.
147         /// </summary>
148         /// <param name="func">The member function to connect</param>
149         public void Connect(System.Delegate func)
150         {
151             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
152             {
153                 NDalicManualPINVOKE.LanguageChangedSignalType_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
154                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155             }
156         }
157
158         /// <summary>
159         /// Disconnects a function.
160         /// </summary>
161         /// <param name="func">The function to disconnect</param>
162         public void Disconnect(System.Delegate func)
163         {
164             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
165             {
166                 NDalicManualPINVOKE.LanguageChangedSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
167                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168             }
169         }
170
171         /// <summary>
172         /// Emits the signal.
173         /// </summary>
174         public void Emit(int arg)
175         {
176             NDalicManualPINVOKE.LanguageChangedSignalType_Emit(swigCPtr, arg);
177             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178         }
179
180         /// <summary>
181         /// The contructor.
182         /// </summary>
183         public LanguageChangedSignalType() : this(NDalicManualPINVOKE.new_LanguageChangedSignalType(), true)
184         {
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186         }
187
188     }
189
190 }