e8846c57f3359f4a049c1a6e92befefc1f1a45af
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-buffer-impl.h
1 #ifndef DALI_INTERNAL_PROPERTY_BUFFER_H
2 #define DALI_INTERNAL_PROPERTY_BUFFER_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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/public-api/object/property-buffer.h> // Dali::PropertyBuffer
25 #include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
26 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
27 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace SceneGraph
34 {
35 class PropertyBuffer;
36 }
37
38 class PropertyBuffer;
39 typedef IntrusivePtr<PropertyBuffer> PropertyBufferPtr;
40
41 /**
42  * PropertyBuffer is an object that contains an array of structures of values that
43  * can be accessed as properties.
44  */
45 class PropertyBuffer : public Object, public Connectable
46 {
47 public:
48
49   /**
50    * @copydoc PropertBuffer::New()
51    */
52   static PropertyBufferPtr New();
53
54   /**
55    * @copydoc PropertBuffer::SetSize()
56    */
57   void SetSize( std::size_t size );
58
59   /**
60    * @copydoc PropertBuffer::GetSize()
61    */
62   std::size_t GetSize() const;
63
64   /**
65    * @copydoc PropertBuffer::SetData()
66    */
67   void SetData( void* data );
68
69   /**
70    * @copydoc PropertBuffer::GetPropertyIndex()
71    */
72   Dali::Property::Index GetPropertyIndex( const std::string name, std::size_t index );
73
74   /**
75    * @brief Get the propertyBuffer scene object
76    *
77    * @return the propertyBuffer scene object
78    */
79   const SceneGraph::PropertyBuffer* GetPropertyBufferSceneObject() const;
80
81 public: // Default property extensions from Object
82
83   /**
84    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
85    */
86   virtual unsigned int GetDefaultPropertyCount() const;
87
88   /**
89    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
90    */
91   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
92
93   /**
94    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
95    */
96   virtual const char* GetDefaultPropertyName(Property::Index index) const;
97
98   /**
99    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
100    */
101   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
102
103   /**
104    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
105    */
106   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
107
108   /**
109    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
110    */
111   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
112
113   /**
114    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
115    */
116   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
117
118   /**
119    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
120    */
121   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
122
123   /**
124    * @copydoc Dali::Internal::Object::SetDefaultProperty()
125    */
126   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
127
128   /**
129    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
130    */
131   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
132
133   /**
134    * @copydoc Dali::Internal::Object::GetDefaultProperty()
135    */
136   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
137
138   /**
139    * @copydoc Dali::Internal::Object::GetPropertyOwner()
140    */
141   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
142
143   /**
144    * @copydoc Dali::Internal::Object::GetSceneObject()
145    */
146   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
147
148   /**
149    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
150    */
151   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
152
153   /**
154    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
155    */
156   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
157
158   /**
159    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
160    */
161   virtual int GetPropertyComponentIndex( Property::Index index ) const;
162
163 public: // Functions from Connectable
164   /**
165    * @copydoc Dali::Internal::Connectable::OnStage()
166    */
167   virtual bool OnStage() const;
168
169   /**
170    * @copydoc Dali::Internal::Connectable::Connect()
171    */
172   virtual void Connect();
173
174   /**
175    * @copydoc Dali::Internal::Connectable::Disconnect()
176    */
177   virtual void Disconnect();
178
179 private: // implementation
180   PropertyBuffer();
181
182 private: // unimplemented methods
183   PropertyBuffer( const PropertyBuffer& );
184   PropertyBuffer& operator=( const PropertyBuffer& );
185
186 private: // data
187   SceneGraph::PropertyBuffer* mSceneObject;
188   bool mOnStage;
189 };
190
191 } // namespace Internal
192
193 // Helpers for public-api forwarding methods
194 inline Internal::PropertyBuffer& GetImplementation(Dali::PropertyBuffer& handle)
195 {
196   DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty");
197
198   BaseObject& object = handle.GetBaseObject();
199
200   return static_cast<Internal::PropertyBuffer&>(object);
201 }
202
203 inline const Internal::PropertyBuffer& GetImplementation(const Dali::PropertyBuffer& handle)
204 {
205   DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty");
206
207   const BaseObject& object = handle.GetBaseObject();
208
209   return static_cast<const Internal::PropertyBuffer&>(object);
210 }
211
212 } // namespace Dali
213
214 #endif // DALI_INTERNAL_PROPERTY_BUFFER_H