2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
23 internal class ImfEventSignalType : global::System.IDisposable
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 /// <since_tizen> 3 </since_tizen>
30 protected bool swigCMemOwn;
32 internal ImfEventSignalType(global::System.IntPtr cPtr, bool cMemoryOwn)
34 swigCMemOwn = cMemoryOwn;
35 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfEventSignalType obj)
40 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43 //A Flag to check who called Dispose(). (By User or DisposeQueue)
44 private bool isDisposeQueued = false;
46 /// A Flat to check if it is already disposed.
48 /// <since_tizen> 3 </since_tizen>
49 protected bool disposed = false;
54 /// <since_tizen> 3 </since_tizen>
59 isDisposeQueued = true;
60 DisposeQueue.Instance.Add(this);
67 /// <since_tizen> 3 </since_tizen>
70 //Throw excpetion if Dispose() is called in separate thread.
71 if (!Window.IsInstalled())
73 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
78 Dispose(DisposeTypes.Implicit);
82 Dispose(DisposeTypes.Explicit);
83 System.GC.SuppressFinalize(this);
90 /// <since_tizen> 3 </since_tizen>
91 protected virtual void Dispose(DisposeTypes type)
98 if (type == DisposeTypes.Explicit)
101 //Release your own managed resources here.
102 //You should release all of your own disposable objects here.
106 //Release your own unmanaged resources here.
107 //You should not access any managed member here except static instance.
108 //because the execution order of Finalizes is non-deterministic.
110 if (swigCPtr.Handle != global::System.IntPtr.Zero)
115 NDalicManualPINVOKE.delete_ImfEventSignalType(swigCPtr);
117 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
124 /// Queries whether there are any connected slots.
126 /// <returns>True if there are any slots connected to the signal</returns>
127 /// <since_tizen> 3 </since_tizen>
130 bool ret = NDalicManualPINVOKE.ImfEventSignalType_Empty(swigCPtr);
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 /// Queries the number of slots.
138 /// <returns>The number of slots connected to this signal</returns>
139 /// <since_tizen> 3 </since_tizen>
140 public uint GetConnectionCount()
142 uint ret = NDalicManualPINVOKE.ImfEventSignalType_GetConnectionCount(swigCPtr);
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 /// Connects a function.
150 /// <param name="func">The function to connect</param>
151 /// <since_tizen> 3 </since_tizen>
152 public void Connect(System.Delegate func)
154 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
156 NDalicManualPINVOKE.ImfEventSignalType_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// Disconnects a function.
164 /// <param name="func">The function to disconnect</param>
165 /// <since_tizen> 3 </since_tizen>
166 public void Disconnect(System.Delegate func)
168 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
170 NDalicManualPINVOKE.ImfEventSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 /// Emits the signal.
178 /// <param name="arg1">The first value to pass to callbacks</param>
179 /// <param name="arg2">The second value to pass to callbacks</param>
180 /// <returns>The value returned by the last callback, or a default constructed value if no callbacks are connected</returns>
181 /// <since_tizen> 4 </since_tizen>
182 public ImfManager.ImfCallbackData Emit(ImfManager arg1, ImfManager.ImfEventData arg2)
184 ImfManager.ImfCallbackData ret = new ImfManager.ImfCallbackData(NDalicManualPINVOKE.ImfEventSignalType_Emit(swigCPtr, ImfManager.getCPtr(arg1), ImfManager.ImfEventData.getCPtr(arg2)), true);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 /// <since_tizen> 3 </since_tizen>
193 public ImfEventSignalType() : this(NDalicManualPINVOKE.new_ImfEventSignalType(), true)
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();