2 * Copyright(c) 2021 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.Collections;
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
24 internal class TouchPointContainer : Disposable, IEnumerable, IEnumerable<TouchPoint>
26 internal TouchPointContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
30 protected override void ReleaseSwigCPtr(HandleRef swigCPtr)
32 Interop.TouchPointContainer.DeleteTouchPointContainer(swigCPtr);
35 public TouchPointContainer(ICollection c) : this()
38 throw new global::System.ArgumentNullException(nameof(c));
39 foreach (TouchPoint element in c)
45 public bool IsFixedSize
53 public bool IsReadOnly
61 public TouchPoint this[int index]
65 return getitem(index);
69 setitem(index, value);
77 return (int)capacity();
82 throw new global::System.ArgumentOutOfRangeException("Capacity");
95 public bool IsSynchronized
103 public void CopyTo(TouchPoint[] array)
105 CopyTo(0, array, 0, this.Count);
108 public void CopyTo(TouchPoint[] array, int arrayIndex)
110 CopyTo(0, array, arrayIndex, this.Count);
113 public void CopyTo(int index, TouchPoint[] array, int arrayIndex, int count)
116 throw new global::System.ArgumentNullException(nameof(array));
118 throw new global::System.ArgumentOutOfRangeException(nameof(index), "Value is less than zero");
120 throw new global::System.ArgumentOutOfRangeException(nameof(arrayIndex), "Value is less than zero");
122 throw new global::System.ArgumentOutOfRangeException(nameof(count), "Value is less than zero");
124 throw new global::System.ArgumentException("Multi dimensional array.", nameof(array));
125 if (index + count > this.Count || arrayIndex + count > array.Length)
126 throw new global::System.ArgumentException("Number of elements to copy is too large.");
127 for (int i = 0; i < count; i++)
128 array.SetValue(getitemcopy(index + i), arrayIndex + i);
131 IEnumerator<TouchPoint> IEnumerable<TouchPoint>.GetEnumerator()
133 return new TouchPointContainerEnumerator(this);
136 IEnumerator IEnumerable.GetEnumerator()
138 return new TouchPointContainerEnumerator(this);
141 public TouchPointContainerEnumerator GetEnumerator()
143 return new TouchPointContainerEnumerator(this);
146 // The type-safe enumerator.
147 /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
148 /// whenever the collection is modified. This has been done for changes in the size of the
149 /// collection, but not when one of the elements of the collection is modified as it is a bit
150 /// tricky to detect unmanaged code that modifies the collection under our feet.
151 public sealed class TouchPointContainerEnumerator : IEnumerator, IEnumerator<TouchPoint>
153 private TouchPointContainer collectionRef;
154 private int currentIndex;
155 private object currentObject;
156 private int currentSize;
158 public TouchPointContainerEnumerator(TouchPointContainer collection)
160 collectionRef = collection;
162 currentObject = null;
163 currentSize = collectionRef.Count;
166 // Type-safe iterator Current
167 public TouchPoint Current
171 if (currentIndex == -1)
172 throw new global::System.InvalidOperationException("Enumeration not started.");
173 if (currentIndex > currentSize - 1)
174 throw new global::System.InvalidOperationException("Enumeration finished.");
175 if (currentObject == null)
176 throw new global::System.InvalidOperationException("Collection modified.");
177 return (TouchPoint)currentObject;
181 // Type-unsafe IEnumerator.Current
182 object global::System.Collections.IEnumerator.Current
190 public bool MoveNext()
192 int size = collectionRef.Count;
193 bool moveOkay = (currentIndex + 1 < size) && (size == currentSize);
197 currentObject = collectionRef[currentIndex];
201 currentObject = null;
209 currentObject = null;
210 if (collectionRef.Count != currentSize)
212 throw new global::System.InvalidOperationException("Collection modified.");
216 public void Dispose()
219 currentObject = null;
225 Interop.TouchPointContainer.Clear(SwigCPtr);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 public void Add(TouchPoint x)
231 Interop.TouchPointContainer.Add(SwigCPtr, TouchPoint.getCPtr(x));
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 uint ret = Interop.TouchPointContainer.size(SwigCPtr);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 private uint capacity()
244 uint ret = Interop.TouchPointContainer.capacity(SwigCPtr);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 private void reserve(uint n)
251 Interop.TouchPointContainer.reserve(SwigCPtr, n);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 public TouchPointContainer() : this(Interop.TouchPointContainer.NewTouchPointContainer(), true)
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260 public TouchPointContainer(TouchPointContainer other) : this(Interop.TouchPointContainer.NewTouchPointContainer(TouchPointContainer.getCPtr(other)), true)
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 public TouchPointContainer(int capacity) : this(Interop.TouchPointContainer.NewTouchPointContainer(capacity), true)
267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270 private TouchPoint getitemcopy(int index)
272 TouchPoint ret = new TouchPoint(Interop.TouchPointContainer.getitemcopy(SwigCPtr, index), true);
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 private TouchPoint getitem(int index)
279 TouchPoint ret = new TouchPoint(Interop.TouchPointContainer.getitem(SwigCPtr, index), false);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 private void setitem(int index, TouchPoint val)
286 Interop.TouchPointContainer.setitem(SwigCPtr, index, TouchPoint.getCPtr(val));
287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 public void AddRange(TouchPointContainer values)
292 Interop.TouchPointContainer.AddRange(SwigCPtr, TouchPointContainer.getCPtr(values));
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 public TouchPointContainer GetRange(int index, int count)
298 global::System.IntPtr cPtr = Interop.TouchPointContainer.GetRange(SwigCPtr, index, count);
299 TouchPointContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new TouchPointContainer(cPtr, true);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 public void Insert(int index, TouchPoint x)
306 Interop.TouchPointContainer.Insert(SwigCPtr, index, TouchPoint.getCPtr(x));
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 public void InsertRange(int index, TouchPointContainer values)
312 Interop.TouchPointContainer.InsertRange(SwigCPtr, index, TouchPointContainer.getCPtr(values));
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316 public void RemoveAt(int index)
318 Interop.TouchPointContainer.RemoveAt(SwigCPtr, index);
319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322 public void RemoveRange(int index, int count)
324 Interop.TouchPointContainer.RemoveRange(SwigCPtr, index, count);
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328 public static TouchPointContainer Repeat(TouchPoint value, int count)
330 global::System.IntPtr cPtr = Interop.TouchPointContainer.Repeat(TouchPoint.getCPtr(value), count);
331 TouchPointContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new TouchPointContainer(cPtr, true);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 public void Reverse()
338 Interop.TouchPointContainer.Reverse(SwigCPtr);
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342 public void Reverse(int index, int count)
344 Interop.TouchPointContainer.Reverse(SwigCPtr, index, count);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348 public void SetRange(int index, TouchPointContainer values)
350 Interop.TouchPointContainer.SetRange(SwigCPtr, index, TouchPointContainer.getCPtr(values));
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();