1 #ifndef __DALI_INTERNAL_PROPERTY_METADATA_H__
2 #define __DALI_INTERNAL_PROPERTY_METADATA_H__
5 * Copyright (c) 2014 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>
41 * An entry in a property metadata lookup.
42 * The type field should be queried, before accessing the scene-graph property:
45 * void Example(PropertyEntry entry)
47 * if (entry.type == Property::VECTOR3)
49 * SceneGraph::AnimatableProperty<Vector3>* property = dynamic_cast< SceneGraph::AnimatableProperty<Vector3>* >( entry.property );
55 class PropertyMetadata
60 * Constructor for an uninitalized property metadata
63 : type(Property::NONE),
70 * Constructor for property metadata
71 * @param [in] newProperty A pointer to the property metadata.
73 PropertyMetadata(const SceneGraph::PropertyBase* newProperty)
74 : type(Property::NONE),
75 value(), // value is held by newProperty
76 mProperty(newProperty)
78 DALI_ASSERT_DEBUG(mProperty && "Uninitialized scenegraph property") ;
82 * Constructor for property metadata
83 * @param [in] newValue The value of the scene-graph owned property.
85 PropertyMetadata(Property::Value newValue)
86 : type(newValue.GetType()),
93 * Destructor for property metadata
95 virtual ~PropertyMetadata()
100 * @return true if the property is animatable (i.e. if its a scene graph property)
102 bool IsAnimatable(void) const
104 return NULL != mProperty;
108 * @return true if the property can be written to
110 virtual bool IsWritable(void) const = 0;
113 * @return the scene graph property
115 const SceneGraph::PropertyBase* GetSceneGraphProperty() const
117 DALI_ASSERT_DEBUG(mProperty && "Accessing uninitialized SceneGraph property") ;
121 Property::Type type; ///< The type of the property
122 Property::Value value; ///< The property value for a non animatable and custom property
127 PropertyMetadata( const PropertyMetadata& );
128 PropertyMetadata& operator=( const PropertyMetadata& );
130 const SceneGraph::PropertyBase* mProperty; ///< A pointer to a scene-graph property; should not be modified from actor-thread.
135 * An entry in an animatable property metadata lookup.
136 * The type field should be queried, before accessing the animatable property:
138 class AnimatablePropertyMetadata : public PropertyMetadata
143 * Constructor for metadata of animatable property
144 * @param [in] newProperty A pointer to the scene-graph owned property.
146 AnimatablePropertyMetadata( Property::Type newType,
147 const SceneGraph::PropertyBase* newProperty )
150 mProperty = newProperty;
151 DALI_ASSERT_DEBUG(mProperty && "Uninitialized scenegraph property") ;
155 * Constructor for metadata of animatable property
156 * @param [in] newValue The value of the scene-graph owned property.
158 AnimatablePropertyMetadata( Property::Value newValue )
160 type = newValue.GetType();
165 * @return true if the property can be written to
167 virtual bool IsWritable(void) const
175 AnimatablePropertyMetadata();
176 AnimatablePropertyMetadata( const AnimatablePropertyMetadata& );
177 AnimatablePropertyMetadata& operator=( const AnimatablePropertyMetadata& );
180 class CustomPropertyMetadata : public PropertyMetadata
185 * Constructor for metadata of scene graph based properties
186 * @param [in] newName The name of the custom property.
187 * @param [in] newType The type ID of the custom property.
188 * @param [in] newProperty A pointer to the scene-graph owned property.
190 CustomPropertyMetadata( const std::string& newName,
191 Property::Type newType,
192 const SceneGraph::PropertyBase* newProperty)
194 mAccessMode(Property::ANIMATABLE)
197 mProperty = newProperty;
198 DALI_ASSERT_DEBUG(mProperty && "Uninitialized scenegraph property") ;
202 * Constructor for metadata of event side only properties
203 * @param [in] newName The name of the custom property.
204 * @param [in] newValue The value of the custom property.
205 * @param [in] accessMode The access mode of the custom property (writable, animatable etc).
207 CustomPropertyMetadata( const std::string& newName,
208 Property::Value newValue,
209 Property::AccessMode accessMode )
211 mAccessMode(accessMode)
213 type = newValue.GetType();
215 DALI_ASSERT_DEBUG(accessMode != Property::ANIMATABLE && "Animatable must have scenegraph property") ;
219 * @return true if the property can be written to
221 virtual bool IsWritable(void) const
223 return (mAccessMode == Property::ANIMATABLE) || (mAccessMode == Property::READ_WRITE) ;
226 std::string name; ///< The name of the property
231 CustomPropertyMetadata();
232 CustomPropertyMetadata( const CustomPropertyMetadata& );
233 CustomPropertyMetadata& operator=( const CustomPropertyMetadata& );
236 Property::AccessMode mAccessMode; ///< The mode of the property
239 } // namespace Internal
243 #endif // __DALI_INTERNAL_PROPERTY_METADATA_H__