Make some apis as inhouse, will be internal later (#699)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PropertyNotifySignal.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.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21
22     ///<summary>
23     /// Signal connection class for PropertyNotification
24     ///</summary>
25     /// <since_tizen> 4 </since_tizen>
26     /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class PropertyNotifySignal : global::System.IDisposable
29     {
30         /// <summary>
31         /// swigCMemOwn
32         /// </summary>
33         /// <since_tizen> 4 </since_tizen>
34         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
35         [EditorBrowsable(EditorBrowsableState.Never)]
36         protected bool swigCMemOwn;
37         /// <summary>
38         /// A Flat to check if it is already disposed.
39         /// </summary>
40         /// <since_tizen> 4 </since_tizen>
41         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         protected bool disposed = false;
44
45         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
46
47         //A Flag to check who called Dispose(). (By User or DisposeQueue)
48         private bool isDisposeQueued = false;
49
50         /// <summary>
51         /// The constructor.
52         /// </summary>
53         /// <since_tizen> 4 </since_tizen>
54         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
55         [EditorBrowsable(EditorBrowsableState.Never)]
56         public PropertyNotifySignal() : this(NDalicPINVOKE.new_PropertyNotifySignal(), true)
57         {
58             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59         }
60
61         internal PropertyNotifySignal(global::System.IntPtr cPtr, bool cMemoryOwn)
62         {
63             swigCMemOwn = cMemoryOwn;
64             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
65         }
66
67         /// <summary>
68         /// Dispose
69         /// </summary>
70         /// <since_tizen> 3 </since_tizen>
71         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         ~PropertyNotifySignal()
74         {
75             if (!isDisposeQueued)
76             {
77                 isDisposeQueued = true;
78                 DisposeQueue.Instance.Add(this);
79             }
80         }
81
82         /// <summary>
83         /// Dispose
84         /// </summary>
85         /// <since_tizen> 4 </since_tizen>
86         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
87         [EditorBrowsable(EditorBrowsableState.Never)]
88         public void Dispose()
89         {
90             //Throw excpetion if Dispose() is called in separate thread.
91             if (!Window.IsInstalled())
92             {
93                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
94             }
95
96             if (isDisposeQueued)
97             {
98                 Dispose(DisposeTypes.Implicit);
99             }
100             else
101             {
102                 Dispose(DisposeTypes.Explicit);
103                 System.GC.SuppressFinalize(this);
104             }
105         }
106
107         /// <summary>
108         /// Queries whether there are any connected slots.
109         /// </summary>
110         /// <returns>True if there are any slots connected to the signal.</returns>
111         /// <since_tizen> 4 </since_tizen>
112         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
113         [EditorBrowsable(EditorBrowsableState.Never)]
114         public bool Empty()
115         {
116             bool ret = NDalicPINVOKE.PropertyNotifySignal_Empty(swigCPtr);
117             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118             return ret;
119         }
120
121         /// <summary>
122         /// Queries the number of slots.
123         /// </summary>
124         /// <returns>The number of slots connected to this signal</returns>
125         /// <since_tizen> 4 </since_tizen>
126         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
127         [EditorBrowsable(EditorBrowsableState.Never)]
128         public uint GetConnectionCount()
129         {
130             uint ret = NDalicPINVOKE.PropertyNotifySignal_GetConnectionCount(swigCPtr);
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132             return ret;
133         }
134
135         /// <summary>
136         /// Connects a function.
137         /// </summary>
138         /// <param name="func">The function to connect</param>
139         /// <since_tizen> 4 </since_tizen>
140         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
141         [EditorBrowsable(EditorBrowsableState.Never)]
142         public void Connect(System.Delegate func)
143         {
144             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
145             {
146                 NDalicPINVOKE.PropertyNotifySignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
147                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148             }
149         }
150
151         /// <summary>
152         /// Disconnects a function.
153         /// </summary>
154         /// <param name="func">The function to disconnect.</param>
155         /// <since_tizen> 4 </since_tizen>
156         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
157         [EditorBrowsable(EditorBrowsableState.Never)]
158         public void Disconnect(System.Delegate func)
159         {
160             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
161             {
162                 NDalicPINVOKE.PropertyNotifySignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
163                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164             }
165         }
166
167         /// <summary>
168         /// Emits a signal with 1 parameter.
169         /// </summary>
170         /// <param name="arg">The first value to pass to callbacks.</param>
171         /// <since_tizen> 4 </since_tizen>
172         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
173         [EditorBrowsable(EditorBrowsableState.Never)]
174         public void Emit(PropertyNotification arg)
175         {
176             NDalicPINVOKE.PropertyNotifySignal_Emit(swigCPtr, PropertyNotification.getCPtr(arg));
177             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178         }
179
180         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotifySignal obj)
181         {
182             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
183         }
184
185         /// <summary>
186         /// Dispose
187         /// </summary>
188         /// <param name="type">The dispose type.</param>
189         /// <since_tizen> 4 </since_tizen>
190         /// This will be changed internal API after ACR done. Before ACR, need to be hidden as inhouse API.
191         [EditorBrowsable(EditorBrowsableState.Never)]
192         protected virtual void Dispose(DisposeTypes type)
193         {
194             if (disposed)
195             {
196                 return;
197             }
198
199             if (type == DisposeTypes.Explicit)
200             {
201                 //Called by User
202                 //Release your own managed resources here.
203                 //You should release all of your own disposable objects here.
204
205             }
206
207             //Release your own unmanaged resources here.
208             //You should not access any managed member here except static instance.
209             //because the execution order of Finalizes is non-deterministic.
210
211             if (swigCPtr.Handle != global::System.IntPtr.Zero)
212             {
213                 if (swigCMemOwn)
214                 {
215                     swigCMemOwn = false;
216                     NDalicPINVOKE.delete_PropertyNotifySignal(swigCPtr);
217                 }
218                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
219             }
220
221             disposed = true;
222         }
223
224     }
225
226 }