1a9cdbf26d3e55c4aa77078da40d27c05564d61c
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Common / Uint16Pair.cs
1 /*
2  * Copyright(c) 2021 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 using global::System;
19 using global::System.Runtime.InteropServices;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// Simple class for passing around pairs of small unsigned integers.<br />
25     /// Use this for integer dimensions and points with limited range such as image
26     /// sizes and pixel coordinates where a pair of floating point numbers is
27     /// inefficient and illogical (i.e.the data is inherently integer).<br />
28     /// One of these can be passed in a single 32 bit integer register on
29     /// common architectures.<br />
30     /// </summary>
31     internal class Uint16Pair : Disposable
32     {
33
34         internal Uint16Pair(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
35         {
36         }
37
38         protected override void ReleaseSwigCPtr(HandleRef swigCPtr)
39         {
40             if (swigCPtr.Handle == IntPtr.Zero)
41             {
42                 //Log.Fatal("NUI", "Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
43                 //Log.Fatal("NUI", "Error! just return here! this can cause unknown error or crash in next step");
44                 //return false;
45                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
46             }
47             Interop.Uint16Pair.DeleteUint16Pair(swigCPtr);
48         }
49
50         /// <summary>
51         /// Less than comparison operator for storing in collections (not geometrically meaningful).
52         /// </summary>
53         /// <param name="arg1">A reference for comparison.</param>
54         /// <param name="arg2">A reference for comparison</param>
55         /// <return>True if arg1 less than arg2</return>
56         public static bool operator <(Uint16Pair arg1, Uint16Pair arg2)
57         {
58             return arg1.LessThan(arg2);
59         }
60
61         /// <summary>
62         /// More than comparison operator for storing in collections (not geometrically meaningful).
63         /// </summary>
64         /// <param name="arg1">A reference for comparison.</param>
65         /// <param name="arg2">A reference for comparison</param>
66         /// <return>True if arg1 > arg2</return>
67         public static bool operator >(Uint16Pair arg1, Uint16Pair arg2)
68         {
69             return arg1.GreaterThan(arg2);
70         }
71
72         /// <summary>
73         /// Default constructor for the(0, 0) tuple.
74         /// </summary>
75         public Uint16Pair() : this(Interop.Uint16Pair.NewUint16Pair(), true)
76         {
77             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78         }
79
80         /// <summary>
81         /// Default constructor for the(0, 0) tuple.
82         /// </summary>
83         /// <param name="width">The width or X dimension of the tuple. Make sure it is less than 65536.</param>
84         /// <param name="height">The height or Y dimension of the tuple.Make sure it is less than 65536.</param>
85         public Uint16Pair(uint width, uint height) : this(Interop.Uint16Pair.NewUint16Pair(width, height), true)
86         {
87             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88         }
89
90         /// <summary>
91         /// Constructor taking separate x and y (width and height) parameters.
92         /// </summary>
93         /// <param name="rhs">A reference to assign.</param>
94         public Uint16Pair(Uint16Pair rhs) : this(Interop.Uint16Pair.NewUint16Pair(Uint16Pair.getCPtr(rhs)), true)
95         {
96             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97         }
98
99         /// <summary>
100         /// Sets the width.
101         /// </summary>
102         /// <param name="width">The x dimension to be stored in this 2-tuple.</param>
103         public void SetWidth(ushort width)
104         {
105             if (SwigCPtr.Handle == IntPtr.Zero)
106             {
107                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
108             }
109             Interop.Uint16Pair.SetWidth(SwigCPtr, width);
110             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111         }
112
113         /// <summary>
114         /// Get the width.
115         /// </summary>
116         /// <return>
117         /// The x dimension stored in this 2-tuple.
118         /// </return>
119         public ushort GetWidth()
120         {
121             if (SwigCPtr.Handle == IntPtr.Zero)
122             {
123                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
124             }
125             ushort ret = Interop.Uint16Pair.GetWidth(SwigCPtr);
126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127             return ret;
128         }
129
130         /// <summary>
131         /// Sets the height.
132         /// </summary>
133         /// <param name="height">The y dimension to be stored in this 2-tuple.</param>
134         public void SetHeight(ushort height)
135         {
136             if (SwigCPtr.Handle == IntPtr.Zero)
137             {
138                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
139             }
140             Interop.Uint16Pair.SetHeight(SwigCPtr, height);
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142         }
143
144         /// <summary>
145         /// Get the height.
146         /// </summary>
147         /// <return>
148         /// The y dimension stored in this 2-tuple.
149         /// </return>
150         public ushort GetHeight()
151         {
152             if (SwigCPtr.Handle == IntPtr.Zero)
153             {
154                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
155             }
156             ushort ret = Interop.Uint16Pair.GetHeight(SwigCPtr);
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158             return ret;
159         }
160
161         /// <summary>
162         /// Sets the x dimension.
163         /// </summary>
164         /// <param name="x">The x dimension to be stored in this 2-tuple.</param>
165         public void SetX(ushort x)
166         {
167             if (SwigCPtr.Handle == IntPtr.Zero)
168             {
169                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
170             }
171             Interop.Uint16Pair.SetX(SwigCPtr, x);
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173         }
174
175         /// <summary>
176         /// Get the x dimension.
177         /// </summary>
178         /// <return>
179         /// The x dimension stored in this 2-tuple.
180         /// </return>
181         public ushort GetX()
182         {
183             if (SwigCPtr.Handle == IntPtr.Zero)
184             {
185                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
186             }
187             ushort ret = Interop.Uint16Pair.GetX(SwigCPtr);
188             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189             return ret;
190         }
191
192         /// <summary>
193         /// Sets the y dimension.
194         /// </summary>
195         /// <param name="y">The y dimension to be stored in this 2-tuple.</param>
196         public void SetY(ushort y)
197         {
198             if (SwigCPtr.Handle == IntPtr.Zero)
199             {
200                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
201             }
202             Interop.Uint16Pair.SetY(SwigCPtr, y);
203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204         }
205
206         /// <summary>
207         /// Get the y dimension.
208         /// </summary>
209         /// <return>
210         /// The y dimension stored in this 2-tuple.
211         /// </return>
212         public ushort GetY()
213         {
214             if (SwigCPtr.Handle == IntPtr.Zero)
215             {
216                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
217             }
218             ushort ret = Interop.Uint16Pair.GetY(SwigCPtr);
219             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220             return ret;
221         }
222
223         /// <summary>
224         /// Constructor taking separate x and y (width and height) parameters.
225         /// </summary>
226         /// <param name="rhs">A reference to assign.</param>
227         /// <return>The created object.</return>
228         public Uint16Pair Assign(Uint16Pair rhs)
229         {
230             if (SwigCPtr.Handle == IntPtr.Zero)
231             {
232                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
233             }
234             Uint16Pair ret = new Uint16Pair(Interop.Uint16Pair.Assign(SwigCPtr, Uint16Pair.getCPtr(rhs)), false);
235             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236             return ret;
237         }
238
239         private bool EqualTo(Uint16Pair rhs)
240         {
241             if (SwigCPtr.Handle == IntPtr.Zero)
242             {
243                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
244             }
245             bool ret = Interop.Uint16Pair.EqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
246             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247             return ret;
248         }
249
250         private bool NotEqualTo(Uint16Pair rhs)
251         {
252             if (SwigCPtr.Handle == IntPtr.Zero)
253             {
254                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
255             }
256             bool ret = Interop.Uint16Pair.NotEqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
257             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258             return ret;
259         }
260
261         private bool LessThan(Uint16Pair rhs)
262         {
263             if (SwigCPtr.Handle == IntPtr.Zero)
264             {
265                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
266             }
267             bool ret = Interop.Uint16Pair.LessThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
268             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269             return ret;
270         }
271
272         private bool GreaterThan(Uint16Pair rhs)
273         {
274             if (SwigCPtr.Handle == IntPtr.Zero)
275             {
276                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
277             }
278             bool ret = Interop.Uint16Pair.GreaterThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280             return ret;
281         }
282
283     }
284 }