Making DALi core internals typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-buffer-impl.h
index 715e62d..2f57eaf 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_PROPERTY_BUFFER_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/object/property-buffer.h> // Dali::PropertyBuffer
+#include <dali/public-api/object/base-object.h>
 #include <dali/public-api/object/property-map.h> // Dali::Property::Map
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/render/renderers/render-property-buffer.h>
 
 namespace Dali
 {
 namespace Internal
 {
-namespace SceneGraph
-{
-class PropertyBuffer;
-
-namespace PropertyBufferMetadata
-{
-struct Format;
-} // namespace PropertyBufferMetadata
-
-} // namespace SceneGraph
 
 class PropertyBuffer;
 typedef IntrusivePtr<PropertyBuffer> PropertyBufferPtr;
@@ -49,157 +38,33 @@ typedef IntrusivePtr<PropertyBuffer> PropertyBufferPtr;
  * PropertyBuffer is an object that contains an array of structures of values that
  * can be accessed as properties.
  */
-class PropertyBuffer : public Object, public Connectable
+class PropertyBuffer : public BaseObject
 {
 public:
 
   /**
    * @copydoc PropertBuffer::New()
    */
-  static PropertyBufferPtr New();
-
-  /**
-   * @copydoc PropertBuffer::SetSize()
-   */
-  void SetSize( std::size_t size );
-
-  /**
-   * @copydoc PropertBuffer::GetSize()
-   */
-  std::size_t GetSize() const;
+  static PropertyBufferPtr New( Dali::Property::Map& format );
 
   /**
    * @copydoc PropertBuffer::SetData()
    */
-  void SetData( const void* data );
-
-  /**
-   * @copydoc PropertBuffer::GetPropertyIndex()
-   */
-  Dali::Property::Index GetPropertyIndex( const std::string name, std::size_t index );
-
-  /**
-   * @brief Get the propertyBuffer scene object
-   *
-   * @return the propertyBuffer scene object
-   */
-  const SceneGraph::PropertyBuffer* GetPropertyBufferSceneObject() const;
-
-  /**
-   * @brief Set the type of PropertyBuffer
-   *
-   * @pre Has not been set yet
-   *
-   * @param[in] type of PropertyBuffer
-   */
-  void SetType( Dali::PropertyBuffer::Type type );
+  void SetData( const void* data, uint32_t size );
 
   /**
-   * @brief Set the format of the PropertyBuffer
-   *
-   * @pre Has not been set yet
-   *
-   * @param[in] format of the PropertyBuffer
+   * @copydoc PropertBuffer::GetSize()
    */
-  void SetFormat( Dali::Property::Map& format );
+  uint32_t GetSize() const;
 
 public: // Default property extensions from Object
 
   /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
-   */
-  virtual unsigned int GetDefaultPropertyCount() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
-   */
-  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
-   */
-  virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
-   */
-  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
-   */
-  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
-   */
-  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
-   */
-  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
-   */
-  virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::SetDefaultProperty()
-   */
-  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
-  /**
-   * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
-   */
-  virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultProperty()
-   */
-  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetPropertyOwner()
-   */
-  virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObject()
-   */
-  virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
-   */
-  virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
-   */
-  virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
-   */
-  virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
-  /**
-   * @copydoc Dali::Internal::Connectable::OnStage()
-   */
-  virtual bool OnStage() const;
-
-  /**
-   * @copydoc Dali::Internal::Connectable::Contnect()
-   */
-  virtual void Connect();
-
-  /**
-   * @copydoc Dali::Internal::Connectable::Disconnect()
+   * @brief Get the render thread side of the PropertyBuffer
+   *
+   * @return The render thread side of this PropertyBuffer
    */
-  virtual void Disconnect();
+  const Render::PropertyBuffer* GetRenderObject() const;
 
 protected:
   /**
@@ -216,32 +81,17 @@ private: // implementation
   /**
    * Second stage initialization
    */
-  void Initialize();
-
-  /**
-   * Update the buffer when the format changes
-   */
-  void FormatChanged();
-
-  /**
-   * Update the buffer when the size changes
-   */
-  void SizeChanged();
+  void Initialize( Dali::Property::Map& format );
 
 private: // unimplemented methods
   PropertyBuffer( const PropertyBuffer& );
   PropertyBuffer& operator=( const PropertyBuffer& );
 
 private: // data
-  SceneGraph::PropertyBuffer* mSceneObject; ///< Update side object
-
-  Property::Map mFormat;  ///< Format of the property buffer
-  const SceneGraph::PropertyBufferMetadata::Format* mBufferFormat;  ///< Metadata for the format of the property buffer
-  unsigned int mSize; ///< Number of elements in the buffer
-  Dali::PropertyBuffer::Type mType; ///< Type of propertyBuffer
-  Dali::Vector< char > mBuffer; // Data of the property-buffer
-
-  bool mOnStage;  ///< Flag to know if the object is on stage
+  EventThreadServices& mEventThreadServices;    ///<Used to send messages to the render thread via update thread
+  Render::PropertyBuffer* mRenderObject;        ///<Render side object
+  uint32_t mBufferFormatSize;
+  uint32_t mSize; ///< Number of elements in the buffer
 };
 
 /**
@@ -254,7 +104,6 @@ template<Property::Type type> struct PropertyImplementationType
 template<> struct PropertyImplementationType< Property::BOOLEAN > { typedef bool Type; };
 template<> struct PropertyImplementationType< Property::FLOAT > { typedef float Type; };
 template<> struct PropertyImplementationType< Property::INTEGER > { typedef int Type; };
-template<> struct PropertyImplementationType< Property::UNSIGNED_INTEGER > { typedef unsigned int Type; };
 template<> struct PropertyImplementationType< Property::VECTOR2 > { typedef Vector2 Type; };
 template<> struct PropertyImplementationType< Property::VECTOR3 > { typedef Vector3 Type; };
 template<> struct PropertyImplementationType< Property::VECTOR4 > { typedef Vector4 Type; };
@@ -263,14 +112,7 @@ template<> struct PropertyImplementationType< Property::MATRIX > { typedef Matri
 template<> struct PropertyImplementationType< Property::RECTANGLE > { typedef Rect<int> Type; };
 template<> struct PropertyImplementationType< Property::ROTATION > { typedef Quaternion Type; };
 
-/**
- * Get the size of the implementation of a Property::Type
- *
- * @param[in] propertyType Property::Type used to check the size
- *
- * @return Size given by sizeof for the implementation this propertyType
- */
-unsigned int GetPropertyImplementationSize( Property::Type& propertyType );
+uint32_t GetPropertyImplementationSize( Property::Type& propertyType );
 
 } // namespace Internal