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