[dali_1.0.15] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / public-api / object / property.h
1 #ifndef __DALI_PROPERTY_H__
2 #define __DALI_PROPERTY_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <utility>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/common/dali-common.h>
28
29 namespace Dali
30 {
31
32 class Handle;
33
34 /**
35  * @brief An object + property pair.
36  */
37 struct DALI_IMPORT_API Property
38 {
39   /**
40    * @brief A valid property index is zero or greater.
41    */
42   typedef int Index;
43
44   static const int INVALID_INDEX; ///< -1 is not a valid property index
45   static const int INVALID_COMPONENT_INDEX; ///< -1 is not a valid property index
46
47   typedef std::vector< Index > IndexContainer; ///< A vector of property indices
48
49   /**
50    * @brief A value-type representing a property value.
51    */
52   class Value;
53
54   /**
55    * @brief A pair of property values.
56    */
57   typedef std::pair<std::string, Value> StringValuePair;
58
59   /**
60    * @brief A Map of property values.
61    */
62   class Map;
63
64   /**
65    * @brief An Array of property values.
66    */
67   typedef std::vector<Value> Array;
68
69   /**
70    * @brief The property types supported.
71    */
72   enum Type
73   {
74     NONE,            ///< No type
75
76     BOOLEAN,         ///< A boolean type
77     FLOAT,           ///< A float type
78     INTEGER,         ///< An integer type
79     UNSIGNED_INTEGER,///< An unsigned integer type
80     VECTOR2,         ///< a vector array of size=2 with float precision
81     VECTOR3,         ///< a vector array of size=3 with float precision
82     VECTOR4,         ///< a vector array of size=4 with float precision
83     MATRIX3,         ///< a 3x3 matrix
84     MATRIX,          ///< a 4x4 matrix
85     RECTANGLE,       ///< an integer array of size=4
86     ROTATION,        ///< either a quaternion or an axis angle rotation
87     STRING,          ///< A string type
88     ARRAY,           ///< an array of Property::Value
89     MAP,             ///< a string key to Property:value mapping
90     TYPE_COUNT       ///< The number of supported property types
91   };
92
93   /**
94    * @brief The access mode for custom properties
95    */
96   enum AccessMode
97   {
98     READ_ONLY,          ///< if the property is read-only
99     READ_WRITE,         ///< If the property is read/writeable
100     ANIMATABLE,         ///< If the property can be animated or constrained
101     ACCESS_MODE_COUNT   ///< The number of access modes
102   };
103
104
105   /**
106    * @brief Create a Property instance.
107    *
108    * @param [in] object A valid handle to the target object.
109    * @param [in] propertyIndex The index of a property.
110    */
111   Property( Handle& object, Property::Index propertyIndex );
112
113
114   /**
115    * @brief Create a Property instance.
116    *
117    * @param [in] object A valid handle to the target object.
118    * @param [in] propertyIndex The index of a property.
119    * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4. -1 for main property (default is -1)
120    */
121   Property( Handle& object, Property::Index propertyIndex, int componentIndex );
122
123   /**
124    * @brief Create a Property instance.
125    *
126    * @note This performs a property index query and is therefore slower than
127    * constructing a Property directly with the index.
128    * @param [in] object A valid handle to the target object.
129    * @param [in] propertyName The property name.
130    */
131   Property( Handle& object, const std::string& propertyName );
132
133   /**
134    * @brief Create a Property instance.
135    *
136    * @note This performs a property index query and is therefore slower than
137    * constructing a Property directly with the index.
138    * @param [in] object A valid handle to the target object.
139    * @param [in] propertyName The property name.
140    * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4. -1 for main property (default is -1)
141    */
142   Property( Handle& object, const std::string& propertyName, int componentIndex );
143
144   /**
145    * @brief Non-virtual destructor; Property is not intended as a base class.
146    */
147   ~Property();
148
149   Handle& object; ///< A valid handle to the target object.
150
151   Index propertyIndex; ///< The index of a property provided by object.
152
153   int componentIndex; ///< Index of a property sub component, for use with Vector2, Vector3 and Vector4, -1 if using main property
154 };
155
156 } // namespace Dali
157
158 #endif // __DALI_PROPERTY_H__