62b555baf2fe27a5910a52a5f3f127d9cf2bf6a4
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ItemContainer.cs
1 /*
2  * Copyright(c) 2019 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 ItemContainer : Disposable, global::System.Collections.IEnumerable,
26         global::System.Collections.Generic.IEnumerable<Item>
27     {
28
29         internal ItemContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
30         {
31         }
32
33         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ItemContainer obj)
34         {
35             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36         }
37
38         /// This will be public opened.
39         [EditorBrowsable(EditorBrowsableState.Never)]
40         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
41         {
42             Interop.ItemContainer.delete_ItemContainer(swigCPtr);
43         }
44
45         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
46         [EditorBrowsable(EditorBrowsableState.Never)]
47         public ItemContainer(global::System.Collections.ICollection c) : this()
48         {
49             if (c == null)
50                 throw new global::System.ArgumentNullException("c");
51             foreach (Item element in c)
52             {
53                 this.Add(element);
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 bool IsFixedSize
60         {
61             get
62             {
63                 return false;
64             }
65         }
66
67         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public bool IsReadOnly
70         {
71             get
72             {
73                 return false;
74             }
75         }
76
77         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
78         [EditorBrowsable(EditorBrowsableState.Never)]
79         public Item this[int index]
80         {
81             get
82             {
83                 return getitem(index);
84             }
85             set
86             {
87                 setitem(index, value);
88             }
89         }
90
91         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
92         [EditorBrowsable(EditorBrowsableState.Never)]
93         public int Capacity
94         {
95             get
96             {
97                 return (int)capacity();
98             }
99             set
100             {
101                 if (value < size())
102                     throw new global::System.ArgumentOutOfRangeException("Capacity");
103                 reserve((uint)value);
104             }
105         }
106
107         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
108         [EditorBrowsable(EditorBrowsableState.Never)]
109         public int Count
110         {
111             get
112             {
113                 return (int)size();
114             }
115         }
116
117         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
118         [EditorBrowsable(EditorBrowsableState.Never)]
119         public bool IsSynchronized
120         {
121             get
122             {
123                 return false;
124             }
125         }
126
127         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public void CopyTo(Item[] array)
130         {
131             CopyTo(0, array, 0, this.Count);
132         }
133
134         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
135         [EditorBrowsable(EditorBrowsableState.Never)]
136         public void CopyTo(Item[] array, int arrayIndex)
137         {
138             CopyTo(0, array, arrayIndex, this.Count);
139         }
140
141         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public void CopyTo(int index, Item[] array, int arrayIndex, int count)
144         {
145             if (array == null)
146                 throw new global::System.ArgumentNullException("array");
147             if (index < 0)
148                 throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
149             if (arrayIndex < 0)
150                 throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
151             if (count < 0)
152                 throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
153             if (array.Rank > 1)
154                 throw new global::System.ArgumentException("Multi dimensional array.", "array");
155             if (index + count > this.Count || arrayIndex + count > array.Length)
156                 throw new global::System.ArgumentException("Number of elements to copy is too large.");
157             for (int i = 0; i < count; i++)
158                 array.SetValue(getitemcopy(index + i), arrayIndex + i);
159         }
160
161         global::System.Collections.Generic.IEnumerator<Item> global::System.Collections.Generic.IEnumerable<Item>.GetEnumerator()
162         {
163             return new ItemContainerEnumerator(this);
164         }
165
166         global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
167         {
168             return new ItemContainerEnumerator(this);
169         }
170
171         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
172         [EditorBrowsable(EditorBrowsableState.Never)]
173         public ItemContainerEnumerator GetEnumerator()
174         {
175             return new ItemContainerEnumerator(this);
176         }
177
178         // The type-safe enumerator.
179         /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
180         /// whenever the collection is modified. This has been done for changes in the size of the
181         /// collection, but not when one of the elements of the collection is modified as it is a bit
182         /// tricky to detect unmanaged code that modifies the collection under our feet.
183         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
184         [EditorBrowsable(EditorBrowsableState.Never)]
185         public sealed class ItemContainerEnumerator : global::System.Collections.IEnumerator,
186             global::System.Collections.Generic.IEnumerator<Item>
187         {
188             private ItemContainer collectionRef;
189             private int currentIndex;
190             private object currentObject;
191             private int currentSize;
192
193             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
194             [EditorBrowsable(EditorBrowsableState.Never)]
195             public ItemContainerEnumerator(ItemContainer collection)
196             {
197                 collectionRef = collection;
198                 currentIndex = -1;
199                 currentObject = null;
200                 currentSize = collectionRef.Count;
201             }
202
203             // Type-safe iterator Current
204             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
205             [EditorBrowsable(EditorBrowsableState.Never)]
206             public Item Current
207             {
208                 get
209                 {
210                     if (currentIndex == -1)
211                         throw new global::System.InvalidOperationException("Enumeration not started.");
212                     if (currentIndex > currentSize - 1)
213                         throw new global::System.InvalidOperationException("Enumeration finished.");
214                     if (currentObject == null)
215                         throw new global::System.InvalidOperationException("Collection modified.");
216                     return (Item)currentObject;
217                 }
218             }
219
220             // Type-unsafe IEnumerator.Current
221             object global::System.Collections.IEnumerator.Current
222             {
223                 get
224                 {
225                     return Current;
226                 }
227             }
228
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 bool MoveNext()
232             {
233                 int size = collectionRef.Count;
234                 bool moveOkay = (currentIndex + 1 < size) && (size == currentSize);
235                 if (moveOkay)
236                 {
237                     currentIndex++;
238                     currentObject = collectionRef[currentIndex];
239                 }
240                 else
241                 {
242                     currentObject = null;
243                 }
244                 return moveOkay;
245             }
246
247             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
248             [EditorBrowsable(EditorBrowsableState.Never)]
249             public void Reset()
250             {
251                 currentIndex = -1;
252                 currentObject = null;
253                 if (collectionRef.Count != currentSize)
254                 {
255                     throw new global::System.InvalidOperationException("Collection modified.");
256                 }
257             }
258
259             /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
260             [EditorBrowsable(EditorBrowsableState.Never)]
261             public void Dispose()
262             {
263                 currentIndex = -1;
264                 currentObject = null;
265             }
266         }
267
268         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
269         [EditorBrowsable(EditorBrowsableState.Never)]
270         public void Clear()
271         {
272             Interop.ItemContainer.ItemContainer_Clear(swigCPtr);
273             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274         }
275
276         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
277         [EditorBrowsable(EditorBrowsableState.Never)]
278         public void Add(Item x)
279         {
280             Interop.ItemContainer.ItemContainer_Add(swigCPtr, Item.getCPtr(x));
281             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282         }
283
284         private uint size()
285         {
286             uint ret = Interop.ItemContainer.ItemContainer_size(swigCPtr);
287             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288             return ret;
289         }
290
291         private uint capacity()
292         {
293             uint ret = Interop.ItemContainer.ItemContainer_capacity(swigCPtr);
294             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295             return ret;
296         }
297
298         private void reserve(uint n)
299         {
300             Interop.ItemContainer.ItemContainer_reserve(swigCPtr, n);
301             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302         }
303
304         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
305         [EditorBrowsable(EditorBrowsableState.Never)]
306         public ItemContainer() : this(Interop.ItemContainer.new_ItemContainer__SWIG_0(), true)
307         {
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309         }
310
311         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
312         [EditorBrowsable(EditorBrowsableState.Never)]
313         public ItemContainer(ItemContainer other) : this(Interop.ItemContainer.new_ItemContainer__SWIG_1(ItemContainer.getCPtr(other)), true)
314         {
315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316         }
317
318         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
319         [EditorBrowsable(EditorBrowsableState.Never)]
320         public ItemContainer(int capacity) : this(Interop.ItemContainer.new_ItemContainer__SWIG_2(capacity), true)
321         {
322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323         }
324
325         private Item getitemcopy(int index)
326         {
327             Item ret = new Item(Interop.ItemContainer.ItemContainer_getitemcopy(swigCPtr, index), true);
328             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329             return ret;
330         }
331
332         private Item getitem(int index)
333         {
334             Item ret = new Item(Interop.ItemContainer.ItemContainer_getitem(swigCPtr, index), false);
335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336             return ret;
337         }
338
339         private void setitem(int index, Item val)
340         {
341             Interop.ItemContainer.ItemContainer_setitem(swigCPtr, index, Item.getCPtr(val));
342             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
343         }
344
345         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
346         [EditorBrowsable(EditorBrowsableState.Never)]
347         public void AddRange(ItemContainer values)
348         {
349             Interop.ItemContainer.ItemContainer_AddRange(swigCPtr, ItemContainer.getCPtr(values));
350             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351         }
352
353         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
354         [EditorBrowsable(EditorBrowsableState.Never)]
355         public ItemContainer GetRange(int index, int count)
356         {
357             global::System.IntPtr cPtr = Interop.ItemContainer.ItemContainer_GetRange(swigCPtr, index, count);
358             ItemContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemContainer(cPtr, true);
359             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360             return ret;
361         }
362
363         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
364         [EditorBrowsable(EditorBrowsableState.Never)]
365         public void Insert(int index, Item x)
366         {
367             Interop.ItemContainer.ItemContainer_Insert(swigCPtr, index, Item.getCPtr(x));
368             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369         }
370
371         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
372         [EditorBrowsable(EditorBrowsableState.Never)]
373         public void InsertRange(int index, ItemContainer values)
374         {
375             Interop.ItemContainer.ItemContainer_InsertRange(swigCPtr, index, ItemContainer.getCPtr(values));
376             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377         }
378
379         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
380         [EditorBrowsable(EditorBrowsableState.Never)]
381         public void RemoveAt(int index)
382         {
383             Interop.ItemContainer.ItemContainer_RemoveAt(swigCPtr, index);
384             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385         }
386
387         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
388         [EditorBrowsable(EditorBrowsableState.Never)]
389         public void RemoveRange(int index, int count)
390         {
391             Interop.ItemContainer.ItemContainer_RemoveRange(swigCPtr, index, count);
392             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393         }
394
395         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
396         [EditorBrowsable(EditorBrowsableState.Never)]
397         public static ItemContainer Repeat(Item value, int count)
398         {
399             global::System.IntPtr cPtr = Interop.ItemContainer.ItemContainer_Repeat(Item.getCPtr(value), count);
400             ItemContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemContainer(cPtr, true);
401             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402             return ret;
403         }
404
405         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
406         [EditorBrowsable(EditorBrowsableState.Never)]
407         public void Reverse()
408         {
409             Interop.ItemContainer.ItemContainer_Reverse__SWIG_0(swigCPtr);
410             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411         }
412
413         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
414         [EditorBrowsable(EditorBrowsableState.Never)]
415         public void Reverse(int index, int count)
416         {
417             Interop.ItemContainer.ItemContainer_Reverse__SWIG_1(swigCPtr, index, count);
418             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419         }
420
421         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
422         [EditorBrowsable(EditorBrowsableState.Never)]
423         public void SetRange(int index, ItemContainer values)
424         {
425             Interop.ItemContainer.ItemContainer_SetRange(swigCPtr, index, ItemContainer.getCPtr(values));
426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427         }
428     }
429 }