Enable -Wnon-virtual-dtor to avoid incorrect C++ code sneaking in
[platform/core/uifw/dali-core.git] / dali / internal / update / common / property-owner.h
index b3dfa12..fa7bf46 100644 (file)
@@ -1,33 +1,35 @@
 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__
 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // EXTERNAL INCLUDES
-#include <set>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/devel-api/common/owner-container.h>
 #include <dali/internal/common/message.h>
-#include <dali/internal/common/owner-container.h>
 #include <dali/internal/update/common/property-base.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/internal/update/common/uniform-map.h>
 #include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
 
+
 namespace Dali
 {
 
@@ -39,9 +41,6 @@ namespace SceneGraph
 
 class PropertyOwner;
 
-typedef std::set<PropertyOwner*>   PropertyOwnerSet;
-typedef PropertyOwnerSet::iterator PropertyOwnerIter;
-
 typedef OwnerContainer< PropertyBase* > OwnedPropertyContainer;
 typedef OwnedPropertyContainer::Iterator  OwnedPropertyIter;
 
@@ -58,9 +57,33 @@ public:
   public:
 
     /**
+     * Called when the observable object is connected to the scene graph.
+     * @param[in] owner A reference to the connected PropertyOwner
+     */
+    virtual void PropertyOwnerConnected( PropertyOwner& owner ) = 0;
+
+    /**
+     * Called when the observable object is disconnected from the scene graph.
+     * @param[in] currentBufferIndex The buffer to reset.
+     * @param[in] owner A reference to the disconnected PropertyOwner
+     */
+    virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) = 0;
+
+    /**
      * Called shortly before the observable object is destroyed.
+     *
+     * @note Cleanup should be done in both this and PropertyOwnerDisconnected as PropertyOwnerDisconnected
+     * may not be called (i.e. when shutting down).
      */
     virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
+
+  protected:
+
+    /**
+     * Virtual destructor, no deletion through this interface
+     */
+    virtual ~Observer() {}
+
   };
 
   /**
@@ -96,10 +119,23 @@ public:
   bool IsObserved();
 
   /**
-   * Disconnect all observers and remove constraints.
+   * Called just before destruction to disconnect all observers and remove constraints.
+   * This occurs when the object is in the process of being destroyed.
+   */
+  void Destroy();
+
+  /**
+   * Notify all observers that the object has been connected
+   * This occurs when the object is connected to the scene-graph during UpdateManager::Update().
+   */
+  void ConnectToSceneGraph();
+
+  /**
+   * Notify all observers that the object has been disconnected and remove constraints.
    * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
+   * @param[in] currentBufferIndex The current update buffer.
    */
-  void DisconnectFromSceneGraph();
+  void DisconnectFromSceneGraph( BufferIndex updateBufferIndex );
 
   /**
    * Install a custom property.
@@ -153,6 +189,32 @@ public:
    */
   ConstraintOwnerContainer& GetConstraints();
 
+  /**
+   * @copydoc UniformMap::Add
+   */
+  virtual void AddUniformMapping( UniformPropertyMapping* map );
+
+  /**
+   * @copydoc UniformMap::Remove
+   */
+  virtual void RemoveUniformMapping( const std::string& uniformName );
+
+  /**
+   * Get the mappings table
+   */
+  const UniformMap& GetUniformMap() const;
+
+  /**
+   * @copydoc UniformMap::AddUniformMapObserver
+   */
+  void AddUniformMapObserver( UniformMap::Observer& observer );
+
+  /**
+   * @copydoc UniformMap::RemoveUniformMapObserver
+   */
+  void RemoveUniformMapObserver( UniformMap::Observer& observer );
+
+
 protected:
 
   /**
@@ -177,6 +239,7 @@ private:
 protected:
 
   OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
+  UniformMap mUniformMaps; ///< Container of owned uniform maps
 
 private:
 
@@ -187,7 +250,6 @@ private:
   ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
 
   ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
-
 };
 
 } // namespace SceneGraph