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