1 #ifndef __DALI_INTERNAL_PROPERTY_METADATA_H__
2 #define __DALI_INTERNAL_PROPERTY_METADATA_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <dali/public-api/common/constants.h>
27 #include <dali/public-api/object/property.h>
28 #include <dali/public-api/object/property-value.h>
42 * An entry in a property metadata lookup.
43 * The value type field should be queried, before accessing the scene-graph property:
46 * void Example(PropertyEntry entry)
48 * if (entry.value.GetType() == Property::VECTOR3)
50 * SceneGraph::AnimatableProperty<Vector3>* property = dynamic_cast< SceneGraph::AnimatableProperty<Vector3>* >( entry.property );
56 class PropertyMetadata
61 * Constructor for an uninitalized property metadata
65 componentIndex(Property::INVALID_COMPONENT_INDEX),
71 * Constructor for property metadata
72 * @param [in] newProperty A pointer to the property metadata.
74 PropertyMetadata(const SceneGraph::PropertyBase* newProperty)
75 : value(), // value is held by newProperty
76 componentIndex(Property::INVALID_COMPONENT_INDEX),
77 mProperty(newProperty)
79 DALI_ASSERT_DEBUG(mProperty && "Uninitialized scenegraph property");
83 * Constructor for property metadata
84 * @param [in] newValue The value of the scene-graph owned property.
86 PropertyMetadata(Property::Value newValue)
88 componentIndex(Property::INVALID_COMPONENT_INDEX),
94 * Destructor for property metadata
96 virtual ~PropertyMetadata()
101 * @return true if the property is animatable (i.e. if its a scene graph property)
103 bool IsAnimatable(void) const
105 return NULL != mProperty;
109 * @return true if the property can be written to
111 virtual bool IsWritable(void) const = 0;
114 * @return the scene graph property
116 const SceneGraph::PropertyBase* GetSceneGraphProperty() const
118 DALI_ASSERT_DEBUG(mProperty && "Accessing uninitialized SceneGraph property");
123 * @return type of the held property value
125 inline Property::Type GetType() const { return value.GetType(); }
127 Property::Value value; ///< The property value for a non animatable and custom property
128 int componentIndex; ///< The index of the property component
133 PropertyMetadata( const PropertyMetadata& );
134 PropertyMetadata& operator=( const PropertyMetadata& );
136 const SceneGraph::PropertyBase* mProperty; ///< A pointer to a scene-graph property; should not be modified from actor-thread.
141 * An entry in an animatable property metadata lookup.
142 * The value type field should be queried, before accessing the animatable property:
144 class AnimatablePropertyMetadata : public PropertyMetadata
149 * Constructor for metadata of animatable property
150 * @param [in] newIndex The index of the animatable property.
151 * @param [in] newType The type ID of the animatable property.
152 * @param [in] newProperty A pointer to the scene-graph owned property.
154 AnimatablePropertyMetadata( Property::Index newIndex,
155 int newComponentIndex,
156 Property::Type newType,
157 const SceneGraph::PropertyBase* newProperty )
160 componentIndex = newComponentIndex;
161 value = Property::Value(newType);
162 mProperty = newProperty;
163 DALI_ASSERT_DEBUG(mProperty && "Uninitialized scenegraph property");
167 * Constructor for metadata of animatable property
168 * @param [in] newIndex The index of the animatable property.
169 * @param [in] newValue The value of the scene-graph owned property.
171 AnimatablePropertyMetadata( Property::Index newIndex,
172 int newComponentIndex,
173 Property::Value newValue )
176 componentIndex = newComponentIndex;
181 * @return true if the property can be written to
183 virtual bool IsWritable(void) const
188 Property::Index index; ///< The index of the property
193 AnimatablePropertyMetadata();
194 AnimatablePropertyMetadata( const AnimatablePropertyMetadata& );
195 AnimatablePropertyMetadata& operator=( const AnimatablePropertyMetadata& );
198 class CustomPropertyMetadata : public PropertyMetadata
203 * Constructor for metadata of scene graph based properties
204 * @param [in] newName The name of the custom property.
205 * @param [in] newKey The key of the custom property.
206 * @param [in] newType The type ID of the custom property.
207 * @param [in] newProperty A pointer to the scene-graph owned property.
209 CustomPropertyMetadata( const std::string& newName,
210 Property::Index newKey,
211 Property::Type newType,
212 const SceneGraph::PropertyBase* newProperty)
215 childPropertyIndex(Property::INVALID_INDEX),
216 mAccessMode(Property::ANIMATABLE)
218 value = Property::Value(newType);
219 mProperty = newProperty;
220 DALI_ASSERT_DEBUG(mProperty && "Uninitialized scenegraph property");
224 * Constructor for metadata of event side only properties
225 * @param [in] newName The name of the custom property.
226 * @param [in] newValue The value of the custom property.
227 * @param [in] accessMode The access mode of the custom property (writable, animatable etc).
229 CustomPropertyMetadata( const std::string& newName,
230 Property::Value newValue,
231 Property::AccessMode accessMode )
233 key(Property::INVALID_KEY),
234 childPropertyIndex(Property::INVALID_INDEX),
235 mAccessMode(accessMode)
238 DALI_ASSERT_DEBUG(accessMode != Property::ANIMATABLE && "Animatable must have scenegraph property");
242 * @return true if the property can be written to
244 virtual bool IsWritable(void) const
246 return (mAccessMode == Property::ANIMATABLE) || (mAccessMode == Property::READ_WRITE);
249 std::string name; ///< The name of the property
250 Property::Index key; ///< The key of the property
251 Property::Index childPropertyIndex; ///< The index as a child property
256 CustomPropertyMetadata();
257 CustomPropertyMetadata( const CustomPropertyMetadata& );
258 CustomPropertyMetadata& operator=( const CustomPropertyMetadata& );
261 Property::AccessMode mAccessMode; ///< The mode of the property
264 } // namespace Internal
268 #endif // __DALI_INTERNAL_PROPERTY_METADATA_H__