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