Dali 3D User Interface Engine
property-buffer-impl.h
Go to the documentation of this file.
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
25 #include <dali/public-api/object/property-map.h> // Dali::Property::Map
26 #include <dali/devel-api/object/property-buffer.h> // Dali::PropertyBuffer
29 
30 namespace Dali
31 {
32 namespace Internal
33 {
34 
37 
42 class PropertyBuffer : public BaseObject
43 {
44 public:
45 
49  static PropertyBufferPtr New();
50 
54  void SetSize( std::size_t size );
55 
59  std::size_t GetSize() const;
60 
64  void SetData( const void* data );
65 
73  void SetFormat( Dali::Property::Map& format );
74 
75 public: // Default property extensions from Object
76 
83 
84 protected:
89 
90 private: // implementation
95 
99  void Initialize();
100 
104  void FormatChanged();
105 
109  void SizeChanged();
110 
111 private: // unimplemented methods
112  PropertyBuffer( const PropertyBuffer& );
114 
115 private: // data
118 
121  unsigned int mSize;
122  Dali::Vector< char > mBuffer; // Data of the property-buffer
123 };
124 
128 template<Property::Type type> struct PropertyImplementationType
129 {
130  // typedef ... Type; not defined, only support types declared bellow
131 };
132 template<> struct PropertyImplementationType< Property::BOOLEAN > { typedef bool Type; };
133 template<> struct PropertyImplementationType< Property::FLOAT > { typedef float Type; };
134 template<> struct PropertyImplementationType< Property::INTEGER > { typedef int Type; };
135 template<> struct PropertyImplementationType< Property::VECTOR2 > { typedef Vector2 Type; };
136 template<> struct PropertyImplementationType< Property::VECTOR3 > { typedef Vector3 Type; };
137 template<> struct PropertyImplementationType< Property::VECTOR4 > { typedef Vector4 Type; };
138 template<> struct PropertyImplementationType< Property::MATRIX3 > { typedef Matrix3 Type; };
139 template<> struct PropertyImplementationType< Property::MATRIX > { typedef Matrix Type; };
140 template<> struct PropertyImplementationType< Property::RECTANGLE > { typedef Rect<int> Type; };
141 template<> struct PropertyImplementationType< Property::ROTATION > { typedef Quaternion Type; };
142 
143 unsigned int GetPropertyImplementationSize( Property::Type& propertyType );
144 
145 } // namespace Internal
146 
147 // Helpers for public-api forwarding methods
149 {
150  DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty");
151 
152  BaseObject& object = handle.GetBaseObject();
153 
154  return static_cast<Internal::PropertyBuffer&>(object);
155 }
156 
158 {
159  DALI_ASSERT_ALWAYS(handle && "PropertyBuffer handle is empty");
160 
161  const BaseObject& object = handle.GetBaseObject();
162 
163  return static_cast<const Internal::PropertyBuffer&>(object);
164 }
165 
166 } // namespace Dali
167 
168 #endif // DALI_INTERNAL_PROPERTY_BUFFER_H
Dali Docs Home
Read more about Dali