[dali_1.1.2] Merge branch 'devel/master'
[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) 2015 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 #include <dali/public-api/common/dali-vector.h>
29
30 namespace Dali
31 {
32 /**
33  * @addtogroup dali-core-object
34  * @{
35  */
36
37 class Handle;
38
39 /**
40  * @brief An object + property pair.
41  */
42 struct DALI_IMPORT_API Property
43 {
44   /**
45    * @brief A valid property index is zero or greater.
46    */
47   typedef int Index;
48
49   static const int INVALID_INDEX; ///< -1 is not a valid property index
50   static const int INVALID_COMPONENT_INDEX; ///< -1 is not a valid property index
51
52   typedef Dali::Vector< Index > IndexContainer; ///< A vector of property indices
53
54   /**
55    * @brief A value-type representing a property value.
56    */
57   class Value;
58
59   /**
60    * @brief A Map of property values.
61    */
62   class Map;
63
64   /**
65    * @brief An Array of property values.
66    */
67   class 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     VECTOR2,         ///< a vector array of size=2 with float precision
80     VECTOR3,         ///< a vector array of size=3 with float precision
81     VECTOR4,         ///< a vector array of size=4 with float precision
82     MATRIX3,         ///< a 3x3 matrix
83     MATRIX,          ///< a 4x4 matrix
84     RECTANGLE,       ///< an integer array of size=4
85     ROTATION,        ///< either a quaternion or an axis angle rotation
86     STRING,          ///< A string type
87     ARRAY,           ///< an array of Property::Value
88     MAP              ///< a string key to Property:value mapping
89   };
90
91   /**
92    * @brief The access mode for custom properties
93    */
94   enum AccessMode
95   {
96     READ_ONLY,          ///< if the property is read-only
97     READ_WRITE,         ///< If the property is read/writeable
98     ANIMATABLE,         ///< If the property can be animated or constrained
99     ACCESS_MODE_COUNT   ///< The number of access modes
100   };
101
102
103   /**
104    * @brief Create a Property instance.
105    *
106    * @param [in] object A valid handle to the target object.
107    * @param [in] propertyIndex The index of a property.
108    */
109   Property( Handle& object, Property::Index propertyIndex );
110
111
112   /**
113    * @brief Create a Property instance.
114    *
115    * @param [in] object A valid handle to the target object.
116    * @param [in] propertyIndex The index of a property.
117    * @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)
118    */
119   Property( Handle& object, Property::Index propertyIndex, int componentIndex );
120
121   /**
122    * @brief Create a Property instance.
123    *
124    * @note This performs a property index query and is therefore slower than
125    * constructing a Property directly with the index.
126    * @param [in] object A valid handle to the target object.
127    * @param [in] propertyName The property name.
128    */
129   Property( Handle& object, const std::string& propertyName );
130
131   /**
132    * @brief Create a Property instance.
133    *
134    * @note This performs a property index query and is therefore slower than
135    * constructing a Property directly with the index.
136    * @param [in] object A valid handle to the target object.
137    * @param [in] propertyName The property name.
138    * @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)
139    */
140   Property( Handle& object, const std::string& propertyName, int componentIndex );
141
142   /**
143    * @brief Non-virtual destructor; Property is not intended as a base class.
144    */
145   ~Property();
146
147   Handle& object; ///< A valid handle to the target object.
148
149   Index propertyIndex; ///< The index of a property provided by object.
150
151   int componentIndex; ///< Index of a property sub component, for use with Vector2, Vector3 and Vector4, -1 if using main property
152 };
153
154 /**
155  * @}
156  */
157 } // namespace Dali
158
159 #endif // __DALI_PROPERTY_H__