[NUI] Implement shadow in View (#1235)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PropertyMap.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 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// A map of property values, the key type could be string or Property::Index.
22     /// </summary>
23     /// <since_tizen> 3 </since_tizen>
24     public class PropertyMap : Disposable
25     {
26         /// <summary>
27         /// swigCMemOwn
28         /// </summary>
29         /// <since_tizen> 3 </since_tizen>
30         protected bool swigCMemOwn;
31         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32
33         /// <summary>
34         /// The constructor.
35         /// </summary>
36         /// <since_tizen> 3 </since_tizen>
37         public PropertyMap() : this(Interop.PropertyMap.new_Property_Map__SWIG_0(), true)
38         {
39             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
40         }
41
42         /// <summary>
43         /// The copy constructor.
44         /// </summary>
45         /// <param name="other">The map to copy from.</param>
46         /// <since_tizen> 3 </since_tizen>
47         public PropertyMap(PropertyMap other) : this(Interop.PropertyMap.new_Property_Map__SWIG_1(PropertyMap.getCPtr(other)), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         internal PropertyMap(global::System.IntPtr cPtr, bool cMemoryOwn)
53         {
54             swigCMemOwn = cMemoryOwn;
55             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
56         }
57
58         /// <summary>
59         /// The operator to access the element with the specified string key.<br />
60         /// If an element with the key does not exist, then it is created.<br />
61         /// </summary>
62         /// <param name="key">The key whose value to access.</param>
63         /// <returns>A value for the element with the specified key.</returns>
64         /// <since_tizen> 3 </since_tizen>
65         public PropertyValue this[string key]
66         {
67             get
68             {
69                 return ValueOfIndex(key);
70             }
71             internal set
72             {
73                 SetValue(key, value);
74             }
75         }
76
77         /// <summary>
78         /// The operator to access the element with the specified index key.<br />
79         /// If an element with the key does not exist, then it is created.<br />
80         /// </summary>
81         /// <param name="key">The key whose value to access.</param>
82         /// <returns>A value for the element with the specified key.</returns>
83         /// <since_tizen> 3 </since_tizen>
84         public PropertyValue this[int key]
85         {
86             get
87             {
88                 return ValueOfIndex(key);
89             }
90             internal set
91             {
92                 SetValue(key, value);
93             }
94         }
95
96         /// <summary>
97         /// Retrieves the number of elements in the map.
98         /// </summary>
99         /// <returns>The number of elements in the map.</returns>
100         /// <since_tizen> 3 </since_tizen>
101         public uint Count()
102         {
103             uint ret = Interop.PropertyMap.Property_Map_Count(swigCPtr);
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105             return ret;
106         }
107
108         /// <summary>
109         /// Returns whether the map is empty.
110         /// </summary>
111         /// <returns>Returns true if empty, false otherwise.</returns>
112         /// <since_tizen> 3 </since_tizen>
113         public bool Empty()
114         {
115             bool ret = Interop.PropertyMap.Property_Map_Empty(swigCPtr);
116             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117             return ret;
118         }
119
120         /// <summary>
121         /// Inserts the key-value pair in the map, with the key type as string.<br />
122         /// Does not check for duplicates.<br />
123         /// </summary>
124         /// <param name="key">The key to insert.</param>
125         /// <param name="value">The value to insert.</param>
126         /// <since_tizen> 3 </since_tizen>
127         public void Insert(string key, PropertyValue value)
128         {
129             Interop.PropertyMap.Property_Map_Insert__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value));
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131         }
132
133         /// <summary>
134         /// Inserts the key-value pair in the map, with the key type as index.<br />
135         /// Does not check for duplicates.<br />
136         /// </summary>
137         /// <param name="key">The key to insert.</param>
138         /// <param name="value">The value to insert.</param>
139         /// <since_tizen> 3 </since_tizen>
140         public void Insert(int key, PropertyValue value)
141         {
142             Interop.PropertyMap.Property_Map_Insert__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value));
143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144         }
145
146         /// <summary>
147         /// Inserts the key-value pair in the map, with the key type as string.<br />
148         /// Does not check for duplicates.<br />
149         /// </summary>
150         /// <param name="key">The key to insert.</param>
151         /// <param name="value">The value to insert.</param>
152         /// <returns>Returns a reference to this object.</returns>
153         /// <since_tizen> 3 </since_tizen>
154         public PropertyMap Add(string key, PropertyValue value)
155         {
156             PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value)), false);
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158             return ret;
159         }
160
161         /// <summary>
162         /// Inserts the key-value pair in the map, with the key type as string.<br />
163         /// Does not check for duplicates.<br />
164         /// </summary>
165         /// <param name="key">The key to insert.</param>
166         /// <param name="value">The value to insert.</param>
167         /// <returns>Returns a reference to this object.</returns>
168         /// <since_tizen> 3 </since_tizen>
169         public PropertyMap Add(int key, PropertyValue value)
170         {
171             PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value)), false);
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173             return ret;
174         }
175
176         /// <summary>
177         /// Inserts the keyvalue to the map.<br />
178         /// Does not check for duplicates.<br />
179         /// </summary>
180         /// <param name="keyValue">The keyvalue to insert.</param>
181         /// <returns>Returns a reference to this object.</returns>
182         public PropertyMap Add(KeyValue keyValue)
183         {
184             PropertyMap ret = new PropertyMap();
185             if ( keyValue.KeyInt != null )
186             {
187                 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, (int)keyValue.KeyInt, PropertyValue.getCPtr(keyValue.TrueValue)), false);
188             }
189             else if ( keyValue.KeyString != null )
190             {
191                 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, keyValue.KeyString, PropertyValue.getCPtr(keyValue.TrueValue)), false);
192             }
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194
195             return ret;
196         }
197
198         /// <summary>
199         /// Retrieves the value at the specified position.
200         /// </summary>
201         /// <param name="position">The specified position.</param>
202         /// <returns>A reference to the value at the specified position.</returns>
203         /// <since_tizen> 3 </since_tizen>
204         public PropertyValue GetValue(uint position)
205         {
206             PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_GetValue(swigCPtr, position), false);
207             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208             return ret;
209         }
210
211         /// <summary>
212         /// Retrieves the key at the specified position.
213         /// </summary>
214         /// <param name="position">The specified position.</param>
215         /// <returns>A copy of the key at the specified position.</returns>
216         /// <since_tizen> 3 </since_tizen>
217         public PropertyKey GetKeyAt(uint position)
218         {
219             PropertyKey ret = new PropertyKey(Interop.PropertyMap.Property_Map_GetKeyAt(swigCPtr, position), true);
220             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221             return ret;
222         }
223
224         /// <summary>
225         /// Finds the value for the specified key if it exists.
226         /// </summary>
227         /// <param name="key">The key to find.</param>
228         /// <returns>The value if it exists, an empty object otherwise.</returns>
229         /// <since_tizen> 3 </since_tizen>
230         public PropertyValue Find(int key)
231         {
232             global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_2(swigCPtr, key);
233             PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
234             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235             return ret;
236         }
237
238         /// <summary>
239         /// Finds the value for the specified keys if either exist.
240         /// </summary>
241         /// <param name="indexKey">The index key to find.</param>
242         /// <param name="stringKey">The string key to find.</param>
243         /// <returns>The value if it exists, an empty object otherwise.</returns>
244         /// <since_tizen> 3 </since_tizen>
245         public PropertyValue Find(int indexKey, string stringKey)
246         {
247             global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_3(swigCPtr, indexKey, stringKey);
248             PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
249             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250             return ret;
251         }
252
253         /// <summary>
254         /// Clears the map.
255         /// </summary>
256         /// <since_tizen> 3 </since_tizen>
257         public void Clear()
258         {
259             Interop.PropertyMap.Property_Map_Clear(swigCPtr);
260             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261         }
262
263         /// <summary>
264         /// Merges values from the map 'from' to the current.<br />
265         /// Any values in 'from' will overwrite the values in the current map.<br />
266         /// </summary>
267         /// <param name="from">The map to merge from.</param>
268         /// <since_tizen> 3 </since_tizen>
269         public void Merge(PropertyMap from)
270         {
271             Interop.PropertyMap.Property_Map_Merge(swigCPtr, PropertyMap.getCPtr(from));
272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273         }
274
275         /// <summary>
276         /// Retrieves the element with the specified string key.
277         /// </summary>
278         /// <param name="key">The key whose value to retrieve.</param>
279         /// <returns>The value for the element with the specified key.</returns>
280         internal PropertyValue ValueOfIndex(string key)
281         {
282             PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_0(swigCPtr, key), false);
283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284             return ret;
285         }
286
287         /// <summary>
288         /// Retrieves the element with the specified index key.
289         /// </summary>
290         /// <param name="key">The key whose value to retrieve.</param>
291         /// <returns>The value for the element with the specified key.</returns>
292         internal PropertyValue ValueOfIndex(int key)
293         {
294             PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_2(swigCPtr, key), false);
295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296             return ret;
297         }
298
299         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyMap obj)
300         {
301             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
302         }
303
304         internal void SetValue(int key, PropertyValue value)
305         {
306             Interop.PropertyMap.Property_Map_SetValue_IntKey(swigCPtr, key, PropertyValue.getCPtr(value));
307             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308         }
309
310         internal void SetValue(string key, PropertyValue value)
311         {
312             Interop.PropertyMap.Property_Map_SetValue_StringKey(swigCPtr, key, PropertyValue.getCPtr(value));
313             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314         }
315
316         /// <summary>
317         /// Dispose.
318         /// </summary>
319         /// <since_tizen> 3 </since_tizen>
320         protected override void Dispose(DisposeTypes type)
321         {
322             if (disposed)
323             {
324                 return;
325             }
326
327             //Release your own unmanaged resources here.
328             //You should not access any managed member here except static instance.
329             //because the execution order of Finalizes is non-deterministic.
330
331             if (swigCPtr.Handle != global::System.IntPtr.Zero)
332             {
333                 if (swigCMemOwn)
334                 {
335                     swigCMemOwn = false;
336                     Interop.PropertyMap.delete_Property_Map(swigCPtr);
337                 }
338                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
339             }
340             base.Dispose(type);
341         }
342     }
343 }