Release 4.0.0-preview1-00301
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / AdaptorSignalType.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     /// <summary>
21     /// public class AdaptorSignalType : global::System.IDisposable
22     /// </summary>
23     /// <since_tizen> 3 </since_tizen>
24     public class AdaptorSignalType : global::System.IDisposable
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27         /// <summary>
28         /// swigCMemOwn
29         /// </summary>
30         /// <since_tizen> 3 </since_tizen>
31         protected bool swigCMemOwn;
32
33         internal AdaptorSignalType(global::System.IntPtr cPtr, bool cMemoryOwn)
34         {
35             swigCMemOwn = cMemoryOwn;
36             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37         }
38
39         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AdaptorSignalType obj)
40         {
41             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42         }
43
44         /// <summary>
45         /// Dispose
46         /// </summary>
47         /// <since_tizen> 3 </since_tizen>
48         ~AdaptorSignalType()
49         {
50             Dispose();
51         }
52
53         /// <summary>
54         /// Dispose
55         /// </summary>
56         /// <since_tizen> 3 </since_tizen>
57         public virtual void Dispose()
58         {
59             lock (this)
60             {
61                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62                 {
63                     if (swigCMemOwn)
64                     {
65                         swigCMemOwn = false;
66                         NDalicManualPINVOKE.delete_AdaptorSignalType(swigCPtr);
67                     }
68                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
69                 }
70                 global::System.GC.SuppressFinalize(this);
71             }
72         }
73
74         /// <summary>
75         /// Queries whether there are any connected slots.
76         /// </summary>
77         /// <returns>True if there are any slots connected to the signal</returns>
78         /// <since_tizen> 3 </since_tizen>
79         public bool Empty()
80         {
81             bool ret = NDalicManualPINVOKE.AdaptorSignalType_Empty(swigCPtr);
82             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83             return ret;
84         }
85
86         /// <summary>
87         /// Queries the number of slots.
88         /// </summary>
89         /// <returns>The number of slots connected to this signal</returns>
90         /// <since_tizen> 3 </since_tizen>
91         public uint GetConnectionCount()
92         {
93             uint ret = NDalicManualPINVOKE.AdaptorSignalType_GetConnectionCount(swigCPtr);
94             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95             return ret;
96         }
97
98         /// <summary>
99         /// Connects a function.
100         /// </summary>
101         /// <param name="func">The function to connect</param>
102         /// <since_tizen> 3 </since_tizen>
103         public void Connect(System.Delegate func)
104         {
105             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
106             {
107                 NDalicManualPINVOKE.AdaptorSignalType_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
108                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109             }
110         }
111
112         /// <summary>
113         /// Disconnects a function.
114         /// </summary>
115         /// <param name="func">The function to disconnect</param>
116         /// <since_tizen> 3 </since_tizen>
117         public void Disconnect(System.Delegate func)
118         {
119             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
120             {
121                 NDalicManualPINVOKE.AdaptorSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
122                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123             }
124         }
125
126         /// <summary>
127         /// Emits the signal.
128         /// </summary>
129         /// <param name="arg">The first value to pass to callbacks</param>
130         /// <since_tizen> 3 </since_tizen>
131         public void Emit(Adaptor arg)
132         {
133             NDalicManualPINVOKE.AdaptorSignalType_Emit(swigCPtr, Adaptor.getCPtr(arg));
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135         }
136
137         /// <summary>
138         /// The contructor.
139         /// </summary>
140         /// <since_tizen> 3 </since_tizen>
141         public AdaptorSignalType() : this(NDalicManualPINVOKE.new_AdaptorSignalType(), true)
142         {
143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144         }
145
146     }
147
148 }