Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / property-accessor.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/internal/update/common/animatable-property.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 /**
31  * A wrapper class for getting/setting a property.
32  * Animators use this instead of accessing properties directly.
33  */
34 template < typename PropertyType >
35 class PropertyAccessor
36 {
37 public:
38
39   /**
40    * Create a property component.
41    * @param [in] property The property to access.
42    */
43   PropertyAccessor( SceneGraph::PropertyBase* property )
44   : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
45   {
46   }
47
48   /**
49    * Non-virtual destructor; PropertyAccessor is not suitable as a base class.
50    */
51   ~PropertyAccessor()
52   {
53   }
54
55   /**
56    * Query whether the accessor is set.
57    * @return True if set.
58    */
59   bool IsSet() const
60   {
61     return mProperty != NULL;
62   }
63
64   /**
65    * Reset the property accessor
66    * @post Calling any other PropertyAccessor is invalid.
67    */
68   void Reset()
69   {
70     mProperty = NULL;
71   }
72
73   /**
74    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
75    */
76   bool IsClean() const
77   {
78     return mProperty->IsClean();
79   }
80
81   /**
82    * Read access to the property.
83    * @param [in] bufferIndex The current update buffer index.
84    */
85   const PropertyType& Get( BufferIndex bufferIndex ) const
86   {
87     DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
88     return mProperty->Get( bufferIndex );
89   }
90
91   /**
92    * @copydoc AnimatableProperty<float>::Set()
93    */
94   void Set( BufferIndex bufferIndex, const PropertyType& value ) const
95   {
96     DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
97     mProperty->Set( bufferIndex, value );
98   }
99
100   /**
101    * @copydoc AnimatableProperty<float>::Bake()
102    */
103   void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
104   {
105     DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
106     mProperty->Bake( bufferIndex, value );
107   }
108
109 private:
110
111   // Undefined
112   PropertyAccessor(const PropertyAccessor& property);
113
114   // Undefined
115   PropertyAccessor& operator=(const PropertyAccessor& rhs);
116
117 private:
118
119   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
120 };
121
122 } // namespace Internal
123
124 } // namespace Dali
125
126 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__