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