Apply Dispose pattern to NUI.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ControlKeySignal.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 3.0.9
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10
11 using Tizen.NUI.BaseComponents;
12
13 namespace Tizen.NUI
14 {
15
16     internal class ControlKeySignal : global::System.IDisposable
17     {
18         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
19         protected bool swigCMemOwn;
20
21         internal ControlKeySignal(global::System.IntPtr cPtr, bool cMemoryOwn)
22         {
23             swigCMemOwn = cMemoryOwn;
24             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
25         }
26
27         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ControlKeySignal obj)
28         {
29             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
30         }
31
32         //A Flag to check who called Dispose(). (By User or DisposeQueue)
33         private bool isDisposeQueued = false;
34         //A Flat to check if it is already disposed.
35         protected bool disposed = false;
36
37
38         ~ControlKeySignal()
39         {
40             if (!isDisposeQueued)
41             {
42                 isDisposeQueued = true;
43                 DisposeQueue.Instance.Add(this);
44             }
45         }
46
47         public void Dispose()
48         {
49             //Throw excpetion if Dispose() is called in separate thread.
50             if (!Window.IsInstalled())
51             {
52                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
53             }
54
55             if (isDisposeQueued)
56             {
57                 Dispose(DisposeTypes.Implicit);
58             }
59             else
60             {
61                 Dispose(DisposeTypes.Explicit);
62                 System.GC.SuppressFinalize(this);
63             }
64         }
65
66         protected virtual void Dispose(DisposeTypes type)
67         {
68             if (disposed)
69             {
70                 return;
71             }
72
73             if (type == DisposeTypes.Explicit)
74             {
75                 //Called by User
76                 //Release your own managed resources here.
77                 //You should release all of your own disposable objects here.
78
79             }
80
81             //Release your own unmanaged resources here.
82             //You should not access any managed member here except static instance.
83             //because the execution order of Finalizes is non-deterministic.
84
85             if (swigCPtr.Handle != global::System.IntPtr.Zero)
86             {
87                 if (swigCMemOwn)
88                 {
89                     swigCMemOwn = false;
90                     NDalicPINVOKE.delete_ControlKeySignal(swigCPtr);
91                 }
92                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
93             }
94
95             disposed = true;
96         }
97
98
99         public bool Empty()
100         {
101             bool ret = NDalicPINVOKE.ControlKeySignal_Empty(swigCPtr);
102             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103             return ret;
104         }
105
106         public uint GetConnectionCount()
107         {
108             uint ret = NDalicPINVOKE.ControlKeySignal_GetConnectionCount(swigCPtr);
109             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110             return ret;
111         }
112
113         public void Connect(System.Delegate func)
114         {
115             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
116             {
117                 NDalicPINVOKE.ControlKeySignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
118                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119             }
120         }
121
122         public void Disconnect(System.Delegate func)
123         {
124             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
125             {
126                 NDalicPINVOKE.ControlKeySignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
127                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128             }
129         }
130
131         public bool Emit(View arg1, Key arg2)
132         {
133             bool ret = NDalicPINVOKE.ControlKeySignal_Emit(swigCPtr, View.getCPtr(arg1), Key.getCPtr(arg2));
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135             return ret;
136         }
137
138         public ControlKeySignal() : this(NDalicPINVOKE.new_ControlKeySignal(), true)
139         {
140             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141         }
142
143     }
144
145 }