[NUI.Scene3D] Deprecate direct accessor to motion value list
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Scene3D / src / public / ModelMotion / MotionData.cs
1 /*
2  * Copyright(c) 2023 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;
19 using System.ComponentModel;
20 using System.Collections.Generic;
21
22 namespace Tizen.NUI.Scene3D
23 {
24     /// <summary>
25     /// List of each motion value.
26     /// </summary>
27     /// <remark>
28     /// We don't check MotionValue type is matched with MotionIndex.
29     /// </remark>
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class MotionData : IDisposable
32     {
33         private List<(MotionIndex, MotionValue)> motionValues { get; set; } = null;
34
35         /// <summary>
36         /// Owned motion value list.
37         /// </summary>
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         [Obsolete("Do not use this MotionValues property directly. Use Add and GetIndex, GetValue instead.")]
40         public List<(MotionIndex, MotionValue)> MotionValues
41         {
42             get
43             {
44                 return motionValues;
45             }
46             set
47             {
48                 motionValues = value;
49             }
50         }
51
52         /// <summary>
53         /// Append pair of MotionIndex and MotionValue end of list.
54         /// </summary>
55         [EditorBrowsable(EditorBrowsableState.Never)]
56         public void Add(MotionIndex index, MotionValue value)
57         {
58             if(motionValues == null)
59             {
60                 motionValues = new List<(MotionIndex, MotionValue)>();
61             }
62             motionValues.Add((index, value));
63         }
64
65         /// <summary>
66         /// Get MotionIndex at index'th. null if invalid index inputed
67         /// </summary>
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public MotionIndex GetIndex(uint index)
70         {
71             if(motionValues != null && index < motionValues.Count)
72             {
73                 return motionValues[(int)index].Item1;
74             }
75             return null;
76         }
77
78         /// <summary>
79         /// Get MotionValue at index'th. null if invalid index inputed
80         /// </summary>
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public MotionValue GetValue(uint index)
83         {
84             if(motionValues != null && index < motionValues.Count)
85             {
86                 return motionValues[(int)index].Item2;
87             }
88             return null;
89         }
90
91         /// <summary>
92         /// Clear all inputed values.
93         /// </summary>
94         [EditorBrowsable(EditorBrowsableState.Never)]
95         public void Clear()
96         {
97             motionValues = null;
98         }
99
100         /// <summary>
101         /// Create an initialized motion data.
102         /// </summary>
103         public MotionData()
104         {
105         }
106
107         /// <summary>
108         /// IDisposable.Dipsose.
109         /// </summary>
110         [EditorBrowsable(EditorBrowsableState.Never)]
111         public void Dispose()
112         {
113             if (motionValues != null)
114             {
115                 foreach (var indexValuePair in motionValues)
116                 {
117                     indexValuePair.Item1?.Dispose();
118                     indexValuePair.Item2?.Dispose();
119                 }
120                 motionValues = null;
121             }
122         }
123     }
124 }