[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ItemIdContainer.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 using System.ComponentModel;
19
20 namespace Tizen.NUI
21 {
22     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
23     [EditorBrowsable(EditorBrowsableState.Never)]
24     public class ItemIdContainer : Disposable, global::System.Collections.IEnumerable,
25         global::System.Collections.Generic.IList<uint>
26     {
27         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28
29         /// <summary>swigCMemOwn.</summary>
30         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
31         protected bool swigCMemOwn;
32
33         internal ItemIdContainer(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(ItemIdContainer obj)
40         {
41             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42         }
43
44         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
45         [EditorBrowsable(EditorBrowsableState.Never)]
46         protected override void Dispose(DisposeTypes type)
47         {
48             if (disposed)
49             {
50                 return;
51             }
52
53             //Release your own unmanaged resources here.
54             //You should not access any managed member here except static instance.
55             //because the execution order of Finalizes is non-deterministic.
56
57             if (swigCPtr.Handle != global::System.IntPtr.Zero)
58             {
59                 if (swigCMemOwn)
60                 {
61                     swigCMemOwn = false;
62                     Interop.ItemIdContainer.delete_ItemIdContainer(swigCPtr);
63                 }
64                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65             }
66
67             base.Dispose(type);
68         }
69
70         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
71         [EditorBrowsable(EditorBrowsableState.Never)]
72         public ItemIdContainer(global::System.Collections.ICollection c) : this()
73         {
74             if (c == null)
75                 throw new global::System.ArgumentNullException("c");
76             foreach (uint element in c)
77             {
78                 this.Add(element);
79             }
80         }
81
82         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
83         [EditorBrowsable(EditorBrowsableState.Never)]
84         public bool IsFixedSize
85         {
86             get
87             {
88                 return false;
89             }
90         }
91
92         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public bool IsReadOnly
95         {
96             get
97             {
98                 return false;
99             }
100         }
101
102         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
103         [EditorBrowsable(EditorBrowsableState.Never)]
104         public uint this[int index]
105         {
106             get
107             {
108                 return getitem(index);
109             }
110             set
111             {
112                 setitem(index, value);
113             }
114         }
115
116         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
117         [EditorBrowsable(EditorBrowsableState.Never)]
118         public int Capacity
119         {
120             get
121             {
122                 return (int)capacity();
123             }
124             set
125             {
126                 if (value < size())
127                     throw new global::System.ArgumentOutOfRangeException("Capacity");
128                 reserve((uint)value);
129             }
130         }
131
132         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
133         [EditorBrowsable(EditorBrowsableState.Never)]
134         public int Count
135         {
136             get
137             {
138                 return (int)size();
139             }
140         }
141
142         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public bool IsSynchronized
145         {
146             get
147             {
148                 return false;
149             }
150         }
151
152         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
153         [EditorBrowsable(EditorBrowsableState.Never)]
154         public void CopyTo(uint[] array)
155         {
156             CopyTo(0, array, 0, this.Count);
157         }
158
159         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
160         [EditorBrowsable(EditorBrowsableState.Never)]
161         public void CopyTo(uint[] array, int arrayIndex)
162         {
163             CopyTo(0, array, arrayIndex, this.Count);
164         }
165
166         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
167         [EditorBrowsable(EditorBrowsableState.Never)]
168         public void CopyTo(int index, uint[] array, int arrayIndex, int count)
169         {
170             if (array == null)
171                 throw new global::System.ArgumentNullException("array");
172             if (index < 0)
173                 throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
174             if (arrayIndex < 0)
175                 throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
176             if (count < 0)
177                 throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
178             if (array.Rank > 1)
179                 throw new global::System.ArgumentException("Multi dimensional array.", "array");
180             if (index + count > this.Count || arrayIndex + count > array.Length)
181                 throw new global::System.ArgumentException("Number of elements to copy is too large.");
182             for (int i = 0; i < count; i++)
183                 array.SetValue(getitemcopy(index + i), arrayIndex + i);
184         }
185
186         global::System.Collections.Generic.IEnumerator<uint> global::System.Collections.Generic.IEnumerable<uint>.GetEnumerator()
187         {
188             return new ItemIdContainerEnumerator(this);
189         }
190
191         global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
192         {
193             return new ItemIdContainerEnumerator(this);
194         }
195
196         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
197         [EditorBrowsable(EditorBrowsableState.Never)]
198         public ItemIdContainerEnumerator GetEnumerator()
199         {
200             return new ItemIdContainerEnumerator(this);
201         }
202
203         // The type-safe enumerator.
204         /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
205         /// whenever the collection is modified. This has been done for changes in the size of the
206         /// collection, but not when one of the elements of the collection is modified as it is a bit
207         /// tricky to detect unmanaged code that modifies the collection under our feet.
208         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
209         [EditorBrowsable(EditorBrowsableState.Never)]
210         public sealed class ItemIdContainerEnumerator : global::System.Collections.IEnumerator
211           , global::System.Collections.Generic.IEnumerator<uint>
212         {
213             private ItemIdContainer collectionRef;
214             private int currentIndex;
215             private object currentObject;
216             private int currentSize;
217
218             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
219             [EditorBrowsable(EditorBrowsableState.Never)]
220             public ItemIdContainerEnumerator(ItemIdContainer collection)
221             {
222                 collectionRef = collection;
223                 currentIndex = -1;
224                 currentObject = null;
225                 currentSize = collectionRef.Count;
226             }
227
228             // Type-safe iterator Current
229             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
230             [EditorBrowsable(EditorBrowsableState.Never)]
231             public uint Current
232             {
233                 get
234                 {
235                     if (currentIndex == -1)
236                         throw new global::System.InvalidOperationException("Enumeration not started.");
237                     if (currentIndex > currentSize - 1)
238                         throw new global::System.InvalidOperationException("Enumeration finished.");
239                     if (currentObject == null)
240                         throw new global::System.InvalidOperationException("Collection modified.");
241                     return (uint)currentObject;
242                 }
243             }
244
245             // Type-unsafe IEnumerator.Current
246             object global::System.Collections.IEnumerator.Current
247             {
248                 get
249                 {
250                     return Current;
251                 }
252             }
253
254             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
255             [EditorBrowsable(EditorBrowsableState.Never)]
256             public bool MoveNext()
257             {
258                 int size = collectionRef.Count;
259                 bool moveOkay = (currentIndex + 1 < size) && (size == currentSize);
260                 if (moveOkay)
261                 {
262                     currentIndex++;
263                     currentObject = collectionRef[currentIndex];
264                 }
265                 else
266                 {
267                     currentObject = null;
268                 }
269                 return moveOkay;
270             }
271
272             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
273             [EditorBrowsable(EditorBrowsableState.Never)]
274             public void Reset()
275             {
276                 currentIndex = -1;
277                 currentObject = null;
278                 if (collectionRef.Count != currentSize)
279                 {
280                     throw new global::System.InvalidOperationException("Collection modified.");
281                 }
282             }
283
284             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
285             [EditorBrowsable(EditorBrowsableState.Never)]
286             public void Dispose()
287             {
288                 currentIndex = -1;
289                 currentObject = null;
290             }
291         }
292
293         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
294         [EditorBrowsable(EditorBrowsableState.Never)]
295         public void Clear()
296         {
297             Interop.ItemIdContainer.ItemIdContainer_Clear(swigCPtr);
298             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299         }
300
301         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
302         [EditorBrowsable(EditorBrowsableState.Never)]
303         public void Add(uint x)
304         {
305             Interop.ItemIdContainer.ItemIdContainer_Add(swigCPtr, x);
306             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307         }
308
309         private uint size()
310         {
311             uint ret = Interop.ItemIdContainer.ItemIdContainer_size(swigCPtr);
312             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313             return ret;
314         }
315
316         private uint capacity()
317         {
318             uint ret = Interop.ItemIdContainer.ItemIdContainer_capacity(swigCPtr);
319             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320             return ret;
321         }
322
323         private void reserve(uint n)
324         {
325             Interop.ItemIdContainer.ItemIdContainer_reserve(swigCPtr, n);
326             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
327         }
328
329         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
330         [EditorBrowsable(EditorBrowsableState.Never)]
331         public ItemIdContainer() : this(Interop.ItemIdContainer.new_ItemIdContainer__SWIG_0(), true)
332         {
333             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334         }
335
336         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
337         [EditorBrowsable(EditorBrowsableState.Never)]
338         public ItemIdContainer(ItemIdContainer other) : this(Interop.ItemIdContainer.new_ItemIdContainer__SWIG_1(ItemIdContainer.getCPtr(other)), true)
339         {
340             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341         }
342
343         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
344         [EditorBrowsable(EditorBrowsableState.Never)]
345         public ItemIdContainer(int capacity) : this(Interop.ItemIdContainer.new_ItemIdContainer__SWIG_2(capacity), true)
346         {
347             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348         }
349
350         private uint getitemcopy(int index)
351         {
352             uint ret = Interop.ItemIdContainer.ItemIdContainer_getitemcopy(swigCPtr, index);
353             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354             return ret;
355         }
356
357         private uint getitem(int index)
358         {
359             uint ret = Interop.ItemIdContainer.ItemIdContainer_getitem(swigCPtr, index);
360             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361             return ret;
362         }
363
364         private void setitem(int index, uint val)
365         {
366             Interop.ItemIdContainer.ItemIdContainer_setitem(swigCPtr, index, val);
367             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
368         }
369
370         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
371         [EditorBrowsable(EditorBrowsableState.Never)]
372         public void AddRange(ItemIdContainer values)
373         {
374             Interop.ItemIdContainer.ItemIdContainer_AddRange(swigCPtr, ItemIdContainer.getCPtr(values));
375             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376         }
377
378         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
379         [EditorBrowsable(EditorBrowsableState.Never)]
380         public ItemIdContainer GetRange(int index, int count)
381         {
382             global::System.IntPtr cPtr = Interop.ItemIdContainer.ItemIdContainer_GetRange(swigCPtr, index, count);
383             ItemIdContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemIdContainer(cPtr, true);
384             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385             return ret;
386         }
387
388         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
389         [EditorBrowsable(EditorBrowsableState.Never)]
390         public void Insert(int index, uint x)
391         {
392             Interop.ItemIdContainer.ItemIdContainer_Insert(swigCPtr, index, x);
393             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394         }
395
396         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
397         [EditorBrowsable(EditorBrowsableState.Never)]
398         public void InsertRange(int index, ItemIdContainer values)
399         {
400             Interop.ItemIdContainer.ItemIdContainer_InsertRange(swigCPtr, index, ItemIdContainer.getCPtr(values));
401             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402         }
403
404         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
405         [EditorBrowsable(EditorBrowsableState.Never)]
406         public void RemoveAt(int index)
407         {
408             Interop.ItemIdContainer.ItemIdContainer_RemoveAt(swigCPtr, index);
409             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
410         }
411
412         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
413         [EditorBrowsable(EditorBrowsableState.Never)]
414         public void RemoveRange(int index, int count)
415         {
416             Interop.ItemIdContainer.ItemIdContainer_RemoveRange(swigCPtr, index, count);
417             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418         }
419
420         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
421         [EditorBrowsable(EditorBrowsableState.Never)]
422         public static ItemIdContainer Repeat(uint value, int count)
423         {
424             global::System.IntPtr cPtr = Interop.ItemIdContainer.ItemIdContainer_Repeat(value, count);
425             ItemIdContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemIdContainer(cPtr, true);
426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427             return ret;
428         }
429
430         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
431         [EditorBrowsable(EditorBrowsableState.Never)]
432         public void Reverse()
433         {
434             Interop.ItemIdContainer.ItemIdContainer_Reverse__SWIG_0(swigCPtr);
435             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436         }
437
438         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
439         [EditorBrowsable(EditorBrowsableState.Never)]
440         public void Reverse(int index, int count)
441         {
442             Interop.ItemIdContainer.ItemIdContainer_Reverse__SWIG_1(swigCPtr, index, count);
443             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444         }
445
446         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
447         [EditorBrowsable(EditorBrowsableState.Never)]
448         public void SetRange(int index, ItemIdContainer values)
449         {
450             Interop.ItemIdContainer.ItemIdContainer_SetRange(swigCPtr, index, ItemIdContainer.getCPtr(values));
451             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452         }
453
454         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
455         [EditorBrowsable(EditorBrowsableState.Never)]
456         public bool Contains(uint value)
457         {
458             bool ret = Interop.ItemIdContainer.ItemIdContainer_Contains(swigCPtr, value);
459             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460             return ret;
461         }
462
463         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
464         [EditorBrowsable(EditorBrowsableState.Never)]
465         public int IndexOf(uint value)
466         {
467             int ret = Interop.ItemIdContainer.ItemIdContainer_IndexOf(swigCPtr, value);
468             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469             return ret;
470         }
471
472         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
473         [EditorBrowsable(EditorBrowsableState.Never)]
474         public int LastIndexOf(uint value)
475         {
476             int ret = Interop.ItemIdContainer.ItemIdContainer_LastIndexOf(swigCPtr, value);
477             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478             return ret;
479         }
480
481         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
482         [EditorBrowsable(EditorBrowsableState.Never)]
483         public bool Remove(uint value)
484         {
485             bool ret = Interop.ItemIdContainer.ItemIdContainer_Remove(swigCPtr, value);
486             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487             return ret;
488         }
489     }
490 }