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