[NUI] Reduce code duplication - refactor dispose codes (#1010)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / FloatSignal.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     internal class FloatSignal : Disposable
22     {
23         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
24         protected bool swigCMemOwn;
25
26         internal FloatSignal(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(FloatSignal obj)
33         {
34             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35         }
36
37         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         protected override void Dispose(DisposeTypes type)
40         {
41             if (disposed)
42             {
43                 return;
44             }
45
46             //Release your own unmanaged resources here.
47             //You should not access any managed member here except static instance.
48             //because the execution order of Finalizes is non-deterministic.
49
50             if (swigCPtr.Handle != global::System.IntPtr.Zero)
51             {
52                 if (swigCMemOwn)
53                 {
54                     swigCMemOwn = false;
55                     Interop.FloatSignal.delete_FloatSignal(swigCPtr);
56                 }
57                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
58             }
59
60             base.Dispose(type);
61         }
62
63
64         public bool Empty()
65         {
66             bool ret = Interop.FloatSignal.FloatSignal_Empty(swigCPtr);
67             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68             return ret;
69         }
70
71         public uint GetConnectionCount()
72         {
73             uint ret = Interop.FloatSignal.FloatSignal_GetConnectionCount(swigCPtr);
74             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
75             return ret;
76         }
77
78         public void Connect(System.Delegate func)
79         {
80             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
81             {
82                 Interop.FloatSignal.FloatSignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
83                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84             }
85         }
86
87         public void Disconnect(System.Delegate func)
88         {
89             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
90             {
91                 Interop.FloatSignal.FloatSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
92                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93             }
94         }
95
96         public void Emit(float arg)
97         {
98             Interop.FloatSignal.FloatSignal_Emit(swigCPtr, arg);
99             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100         }
101
102         public FloatSignal() : this(Interop.FloatSignal.new_FloatSignal(), true)
103         {
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105         }
106     }
107 }