Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / common / uniform-map.h
index 1814bb7..2df39e2 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_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.
  * limitations under the License.
  */
 
-#include <dali/devel-api/common/hash.h>
-#include <dali/internal/common/owner-container.h>
-
+// EXTERNAL INCLUDES
 #include <string>
+#include <cstdint> // uint32_t
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/common/hash.h>
+#include <dali/devel-api/common/owner-container.h>
 
 namespace Dali
 {
@@ -37,20 +40,20 @@ namespace SceneGraph
 class UniformPropertyMapping
 {
 public:
-  typedef unsigned long Hash;
+  using Hash = unsigned long;
 
   /**
    * Constructor
    */
-  UniformPropertyMapping( const std::string& theUniformName, const PropertyInputImpl* thePropertyPtr )
-  : propertyPtr( thePropertyPtr ),
-    uniformName( theUniformName ),
-    uniformNameHash( Dali::CalculateHash( theUniformName ) )
+  UniformPropertyMapping(std::string theUniformName, const PropertyInputImpl* thePropertyPtr)
+  : propertyPtr(thePropertyPtr),
+    uniformName(std::move(theUniformName)),
+    uniformNameHash(Dali::CalculateHash(theUniformName))
   {
   }
 
   UniformPropertyMapping()
-  : propertyPtr( NULL ),
+  : propertyPtr( nullptr ),
     uniformName( "" ),
     uniformNameHash( 0 )
   {
@@ -65,17 +68,31 @@ public:
 /**
  * The UniformMap class is used to map uniform names to property values. It is available
  * in all of the classes responsible for rendering:
- * Actor, Renderer, Geometry, PropertyBuffer, Material, Sampler, Shader.
+ * Actor, Renderer, Geometry, TextureSet, Shader.
  *
  * It can be observed for changes to the mapping table.
  */
 class UniformMap
 {
 public:
+  using SizeType = uint32_t;
+
   class Observer
   {
   public:
+
+    /**
+     * Inform observer that uniform mappings have been changed
+     * @param mappings
+     */
     virtual void UniformMappingsChanged(const UniformMap& mappings) = 0;
+
+  protected:
+
+    /**
+     * Virtual destructor, no deletion through this interface
+     */
+    virtual ~Observer() = default;
   };
 
   /**
@@ -118,14 +135,14 @@ public:
    * Get the count of uniforms in the map
    * @return The number of uniform mappings
    */
-  unsigned int Count() const;
+  SizeType Count() const;
 
   /**
    * @pre index must be in the range 0 :: Count()-1
    * @param[in] index The index of the element to fetch
    * @return reference to the element in the map
    */
-  const UniformPropertyMapping& operator[]( unsigned int index ) const;
+  const UniformPropertyMapping& operator[]( SizeType index ) const;
 
 private:
   /**
@@ -134,10 +151,10 @@ private:
   void MappingChanged();
 
 private:
-  typedef OwnerContainer< UniformPropertyMapping* > UniformMapContainer;
-  typedef UniformMapContainer::Iterator UniformMapIter;
-  typedef Dali::Vector< Observer* > Observers;
-  typedef Observers::Iterator ObserversIter;
+  using UniformMapContainer = OwnerContainer<UniformPropertyMapping*>;
+  using UniformMapIter      = UniformMapContainer::Iterator;
+  using Observers           = Dali::Vector<Observer*>;
+  using ObserversIter       = Observers::Iterator;
 
   UniformMapContainer mUniformMaps; // Owner container of uniform maps