Reduce the binary size of Constraint code by refactoring the templates to produce... 56/194456/2
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Mon, 26 Nov 2018 17:50:17 +0000 (17:50 +0000)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Tue, 4 Dec 2018 17:45:38 +0000 (17:45 +0000)
Change-Id: Iede00fcdd937fcfd592f9bece6a655a4bad5354f

dali/internal/event/animation/animator-connector-base.h
dali/internal/event/animation/constraint-base.cpp
dali/internal/event/animation/constraint-base.h
dali/internal/event/animation/constraint-impl.h
dali/internal/event/animation/property-constraint.h
dali/internal/event/animation/property-input-accessor.h
dali/internal/update/animation/property-accessor.h
dali/internal/update/animation/property-component-accessor.h
dali/internal/update/animation/scene-graph-constraint.h

index ebcc4e0..bcb383f 100644 (file)
@@ -95,9 +95,9 @@ public:
    */
   void CreateAnimator()
   {
-    DALI_ASSERT_DEBUG( mAnimator == NULL );
-    DALI_ASSERT_DEBUG( mAnimatorFunction != NULL );
-    DALI_ASSERT_DEBUG( mParent != NULL );
+    DALI_ASSERT_DEBUG( mAnimator == nullptr );
+    DALI_ASSERT_DEBUG( mAnimatorFunction != nullptr );
+    DALI_ASSERT_DEBUG( mParent != nullptr );
 
     //Get the PropertyOwner the animator is going to animate
     const SceneGraph::PropertyOwner& propertyOwner = mObject->GetSceneObject();
@@ -116,11 +116,11 @@ public:
     // call the type specific method to create the concrete animator
     bool resetterRequired = DoCreateAnimator( propertyOwner, *baseProperty );
 
-    DALI_ASSERT_DEBUG( mAnimator != NULL );
+    DALI_ASSERT_DEBUG( mAnimator != nullptr );
 
     // Add the new SceneGraph::Animator to its correspondent SceneGraph::Animation via message
     const SceneGraph::Animation* animation = mParent->GetSceneObject();
-    DALI_ASSERT_DEBUG( NULL != animation );
+    DALI_ASSERT_DEBUG( nullptr != animation );
     AddAnimatorMessage( mParent->GetEventThreadServices(), *animation, *mAnimator );
 
     // Add the new SceneGraph::PropertyResetter to the update manager via message
@@ -143,7 +143,7 @@ public:
    */
   void SetParent( Animation& parent )
   {
-    DALI_ASSERT_ALWAYS( mParent == NULL && "AnimationConnector already has a parent" );
+    DALI_ASSERT_ALWAYS( mParent == nullptr && "AnimationConnector already has a parent" );
     mParent = &parent;
 
     if( mObject )
@@ -154,7 +154,7 @@ public:
 
   /**
    * Retrieve the parent of the AnimatorConnector.
-   * @return The parent object, or NULL.
+   * @return The parent object, or nullptr.
    */
   Animation* GetParent() const
   {
index c9f04eb..8ebbd6e 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/event/common/property-helper.h>
 #include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
 #include <dali/internal/update/common/animatable-property.h>
 #include <dali/internal/update/common/property-owner-messages.h>
 
@@ -36,6 +35,24 @@ namespace Dali
 namespace Internal
 {
 
+namespace
+{
+/**
+ * Helper to add only unique entries to the propertyOwner container
+ * @param propertyOwners to add the entries to
+ * @param object to add
+ */
+inline void AddUnique( SceneGraph::PropertyOwnerContainer& propertyOwners, SceneGraph::PropertyOwner* object )
+{
+  const SceneGraph::PropertyOwnerIter iter = std::find( propertyOwners.Begin(), propertyOwners.End(), object );
+  if( iter == propertyOwners.End() )
+  {
+    // each owner should only be added once
+    propertyOwners.PushBack( object );
+  }
+}
+} // unnamed namespace
+
 ConstraintBase::ConstraintBase( Object& object, Property::Index targetPropertyIndex, SourceContainer& sources )
 : mEventThreadServices( *Stage::GetCurrent() ),
   mTargetObject( &object ),
@@ -51,6 +68,17 @@ ConstraintBase::ConstraintBase( Object& object, Property::Index targetPropertyIn
   ObserveObject( object );
 }
 
+ConstraintBase* ConstraintBase::Clone( Object& object )
+{
+  DALI_ASSERT_ALWAYS( !mSourceDestroyed && "An input source object has been destroyed" );
+
+  // create the type specific object
+  ConstraintBase* clone = DoClone( object );
+  clone->SetRemoveAction( mRemoveAction );
+  clone->SetTag( mTag );
+  return clone;
+}
+
 ConstraintBase::~ConstraintBase()
 {
   StopObservation();
@@ -225,6 +253,58 @@ void ConstraintBase::StopObservation()
   mObservedObjects.Clear();
 }
 
+PropertyInputImpl* ConstraintBase::AddInputProperty( Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex )
+{
+  PropertyInputImpl* inputProperty = nullptr;
+
+  if ( OBJECT_PROPERTY == source.sourceType )
+  {
+    DALI_ASSERT_ALWAYS( source.object->IsPropertyAConstraintInput( source.propertyIndex ) );
+
+    SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( source.object->GetSceneObject() );
+
+    AddUnique( propertyOwners, &owner );
+    inputProperty = const_cast< PropertyInputImpl* >( source.object->GetSceneObjectInputProperty( source.propertyIndex ) );
+    componentIndex = source.object->GetPropertyComponentIndex( source.propertyIndex );
+
+    // The scene-object property should exist, when the property owner exists
+    DALI_ASSERT_ALWAYS( inputProperty && "Constraint source property does not exist" );
+  }
+  else if ( LOCAL_PROPERTY == source.sourceType )
+  {
+    DALI_ASSERT_ALWAYS( mTargetObject->IsPropertyAConstraintInput( source.propertyIndex ) );
+
+    inputProperty = const_cast< PropertyInputImpl* >( mTargetObject->GetSceneObjectInputProperty( source.propertyIndex ) );
+    componentIndex = mTargetObject->GetPropertyComponentIndex( source.propertyIndex );
+
+    // The target scene-object should provide this property
+    DALI_ASSERT_ALWAYS( inputProperty && "Constraint source property does not exist" );
+  }
+  else
+  {
+    DALI_ASSERT_ALWAYS( PARENT_PROPERTY == source.sourceType && "Constraint source property type is invalid" );
+
+    Object* objectParent = dynamic_cast< Actor& >( *mTargetObject ).GetParent();
+
+    // This will not exist, if the target object is off-stage
+    if ( objectParent )
+    {
+      DALI_ASSERT_ALWAYS( objectParent->IsPropertyAConstraintInput( source.propertyIndex ) );
+
+      SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( objectParent->GetSceneObject() );
+
+      AddUnique( propertyOwners, &owner );
+      inputProperty = const_cast< PropertyInputImpl* >( objectParent->GetSceneObjectInputProperty( source.propertyIndex ) );
+      componentIndex = objectParent->GetPropertyComponentIndex( source.propertyIndex );
+
+      // The scene-object property should exist, when the property owner exists
+      DALI_ASSERT_ALWAYS( inputProperty && "Constraint source property does not exist" );
+    }
+  }
+  return inputProperty;
+}
+
+
 } // namespace Internal
 
 } // namespace Dali
index 8195aa1..8b9caa9 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H__
 
 /*
- * Copyright (c) 2014 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/internal/common/owner-pointer.h>
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/object/base-object.h>
+#include <dali/internal/common/owner-pointer.h>
 #include <dali/internal/event/animation/constraint-source-impl.h>
+#include <dali/internal/update/animation/scene-graph-constraint-base.h>
 
 namespace Dali
 {
@@ -67,7 +68,7 @@ public:
    * @param[in]  object  The object to clone this constraint for
    * @return A new constraint.
    */
-  virtual ConstraintBase* Clone( Object& object ) = 0;
+  ConstraintBase* Clone( Object& object );
 
   /**
    * Virtual destructor.
@@ -166,13 +167,30 @@ private:
   // To be implemented in derived classes
 
   /**
-   * Create and connect a constraint for a scene-object.
+   * Clone the actual constraint
+   *
+   * @param object to clone to
+   * @return pointer to the clone
+   */
+  virtual ConstraintBase* DoClone( Object& object ) = 0;
+
+  /**
+   * Connect the constraint
    */
   virtual void ConnectConstraint() = 0;
 
 protected:
 
   /**
+   * Helper to Add an input property to the container of property owners
+   * @param source constraint[in] source used to determine the type and locate the property on the object
+   * @param propertyOwners[out] reference to the container to add
+   * @param componentIndex[out] component index
+   * @return pointer to input property if it was found, nullptr otherwise
+   */
+  PropertyInputImpl* AddInputProperty( Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex );
+
+  /**
    * Get the event thread services object - used for sending messages to the scene graph
    * Assert if called from the wrong thread.
    * This is intentionally inline for performance reasons.
index f765bb2..eb3327d 100644 (file)
@@ -43,21 +43,6 @@ namespace Internal
 {
 
 /**
- * Helper to add only unique entries to the propertyOwner container
- * @param propertyOwners to add the entries to
- * @param object to add
- */
-inline void AddUnique( SceneGraph::PropertyOwnerContainer& propertyOwners, SceneGraph::PropertyOwner* object )
-{
-  const SceneGraph::PropertyOwnerIter iter = std::find( propertyOwners.Begin(), propertyOwners.End(), object );
-  if( iter == propertyOwners.End() )
-  {
-    // each owner should only be added once
-    propertyOwners.PushBack( object );
-  }
-}
-
-/**
  * Connects a constraint which takes another property as an input.
  */
 template < typename PropertyType >
@@ -65,10 +50,7 @@ class Constraint : public ConstraintBase
 {
 public:
 
-  typedef SceneGraph::Constraint< PropertyType, PropertyAccessor<PropertyType> > SceneGraphConstraint;
-  typedef const SceneGraph::AnimatableProperty<PropertyType>* ScenePropertyPtr;
-  typedef typename PropertyConstraintPtr<PropertyType>::Type ConstraintFunctionPtr;
-  typedef const SceneGraph::TransformManagerPropertyHandler<PropertyType> TransformManagerProperty;
+  using ConstraintFunctionPtr = typename PropertyConstraintPtr<PropertyType>::Type;
 
   /**
    * Construct a new constraint.
@@ -83,42 +65,31 @@ public:
                               SourceContainer& sources,
                               ConstraintFunctionPtr func )
   {
-    return new Constraint< PropertyType >( object, targetIndex, sources, func );
+    return new Constraint( object, targetIndex, sources, func );
   }
 
   /**
-   * @copydoc ConstraintBase::Clone()
+   * Virtual destructor.
    */
-  virtual ConstraintBase* Clone( Object& object )
+  virtual ~Constraint()
   {
-    DALI_ASSERT_ALWAYS( !mSourceDestroyed && "An input source object has been destroyed" );
-
-    ConstraintBase* clone( NULL );
-
-    ConstraintFunctionPtr funcPtr( mUserFunction->Clone() );
-
-    clone = new Constraint< PropertyType >( object,
-                                            mTargetIndex,
-                                            mSources,
-                                            funcPtr );
-
-    clone->SetRemoveAction(mRemoveAction);
-    clone->SetTag( mTag );
-
-    return clone;
+    // This is not responsible for removing constraints.
   }
 
+private:
 
   /**
-   * Virtual destructor.
+   * @copydoc ConstraintBase::DoClone()
    */
-  virtual ~Constraint()
+  ConstraintBase* DoClone( Object& object ) override final
   {
-    // This is not responsible for removing constraints.
+    ConstraintFunctionPtr funcPtr( mUserFunction->Clone() );
+    return new Constraint( object,
+                            mTargetPropertyIndex,
+                            mSources,
+                            funcPtr );
   }
 
-private:
-
   /**
    * Private constructor; see also Constraint::New().
    */
@@ -127,27 +98,26 @@ private:
               SourceContainer& sources,
               ConstraintFunctionPtr& func )
   : ConstraintBase( object, targetIndex, sources ),
-    mTargetIndex( targetIndex ),
     mUserFunction( func )
   {
   }
 
   // Undefined
-  Constraint( const Constraint& );
+  Constraint() = delete;
+  Constraint( const Constraint& ) = delete;
+  Constraint& operator=( const Constraint& rhs ) = delete;
 
-  // Undefined
-  Constraint& operator=( const Constraint& rhs );
 
   /**
-   * Create and connect a constraint and property resetter for a scene-graph property
+   * @copydoc ConstraintBase::ConnectConstraint()
    */
-  void ConnectConstraint()
+  void ConnectConstraint() override final
   {
     // Should not come here if target object has been destroyed
-    DALI_ASSERT_DEBUG( NULL != mTargetObject );
+    DALI_ASSERT_DEBUG( nullptr != mTargetObject );
 
     // Guard against double connections
-    DALI_ASSERT_DEBUG( NULL == mSceneGraphConstraint );
+    DALI_ASSERT_DEBUG( nullptr == mSceneGraphConstraint );
 
     SceneGraph::PropertyOwner& targetObject = const_cast< SceneGraph::PropertyOwner& >( mTargetObject->GetSceneObject() );
 
@@ -160,39 +130,31 @@ private:
 
     if ( func )
     {
-      // Create the SceneGraphConstraint and PropertyResetter, and connect them to the scene-graph
-
-      const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetIndex );
       OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
-
-      // The targetProperty should exist, when targetObject exists
-      DALI_ASSERT_ALWAYS( NULL != targetProperty && "Constraint target property does not exist" );
-
+      // Create the SceneGraphConstraint and PropertyResetter, and connect them to the scene-graph
+      const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetPropertyIndex );
+      DALI_ASSERT_ALWAYS( targetProperty && "Constraint target property does not exist" );
       if( targetProperty->IsTransformManagerProperty() )  //It is a property managed by the transform manager
       {
         // Connect the constraint
-        mSceneGraphConstraint =
-          SceneGraph::Constraint<PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
-                                                                                                      propertyOwners,
-                                                                                                      func,
-                                                                                                      mRemoveAction );
+        mSceneGraphConstraint = SceneGraph::Constraint< PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
+                                                                                                                             propertyOwners,
+                                                                                                                             func,
+                                                                                                                             mRemoveAction );
         // Don't create a resetter for transform manager property, it's less efficient
       }
       else  //SceneGraph property
       {
         // Connect the constraint
-        mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty,
-                                                           propertyOwners,
-                                                           func,
-                                                           mRemoveAction );
-        // Connect the resetter
+        mSceneGraphConstraint = SceneGraph::Constraint< PropertyType, PropertyAccessor<PropertyType> >::New( *targetProperty,
+                                                                                                             propertyOwners,
+                                                                                                             func,
+                                                                                                             mRemoveAction );
         resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
-
       }
       OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
       ApplyConstraintMessage( GetEventThreadServices(), targetObject, transferOwnership );
-
-      if( resetter != nullptr )
+      if( resetter )
       {
         AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
       }
@@ -203,74 +165,27 @@ private:
    * Helper for ConnectConstraint. Creates a connected constraint-function.
    * Also populates the property-owner container, for each input connected to the constraint-function.
    * @param[out] propertyOwners The container of property-owners providing the scene-graph properties.
-   * @return A connected constraint-function, or NULL if the scene-graph properties are not available.
+   * @return A connected constraint-function, or nullptr if the scene-graph properties are not available.
    */
   PropertyConstraint<PropertyType>* ConnectConstraintFunction( SceneGraph::PropertyOwnerContainer& propertyOwners )
   {
     PropertyConstraint<PropertyType>* func = mUserFunction->Clone();
 
-    for ( SourceIter iter = mSources.begin(); mSources.end() != iter; ++iter )
+    for ( auto&& source : mSources )
     {
-      Source& source = *iter;
-
-      PropertyInputImpl* inputProperty( NULL );
-      int componentIndex( Property::INVALID_COMPONENT_INDEX );
-
-      if ( OBJECT_PROPERTY == source.sourceType )
-      {
-        DALI_ASSERT_ALWAYS( source.object->IsPropertyAConstraintInput( source.propertyIndex ) );
-
-        SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( source.object->GetSceneObject() );
-
-        AddUnique( propertyOwners, &owner );
-        inputProperty = const_cast< PropertyInputImpl* >( source.object->GetSceneObjectInputProperty( source.propertyIndex ) );
-        componentIndex = source.object->GetPropertyComponentIndex( source.propertyIndex );
-
-        // The scene-object property should exist, when the property owner exists
-        DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
-      }
-      else if ( LOCAL_PROPERTY == source.sourceType )
-      {
-        DALI_ASSERT_ALWAYS( mTargetObject->IsPropertyAConstraintInput( source.propertyIndex ) );
-
-        inputProperty = const_cast< PropertyInputImpl* >( mTargetObject->GetSceneObjectInputProperty( source.propertyIndex ) );
-        componentIndex = mTargetObject->GetPropertyComponentIndex( source.propertyIndex );
-
-        // The target scene-object should provide this property
-        DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
-      }
-      else
-      {
-        DALI_ASSERT_ALWAYS( PARENT_PROPERTY == source.sourceType && "Constraint source property type is invalid" );
-
-        Object* objectParent = dynamic_cast< Actor& >( *mTargetObject ).GetParent();
+      int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
+      PropertyInputImpl* inputProperty = AddInputProperty( source, propertyOwners, componentIndex );
 
-        // This will not exist, if the target object is off-stage
-        if ( NULL != objectParent )
-        {
-          DALI_ASSERT_ALWAYS( objectParent->IsPropertyAConstraintInput( source.propertyIndex ) );
-
-          SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( objectParent->GetSceneObject() );
-
-          AddUnique( propertyOwners, &owner );
-          inputProperty = const_cast< PropertyInputImpl* >( objectParent->GetSceneObjectInputProperty( source.propertyIndex ) );
-          componentIndex = objectParent->GetPropertyComponentIndex( source.propertyIndex );
-
-          // The scene-object property should exist, when the property owner exists
-          DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
-        }
-      }
-
-      if ( NULL == inputProperty )
+      if ( nullptr == inputProperty )
       {
         delete func;
-        func = NULL;
+        func = nullptr;
 
         // Exit if a scene-graph object is not available from one of the sources
         break;
       }
 
-      func->SetInput( ( iter - mSources.begin() ), componentIndex, *inputProperty );
+      func->AddInput( inputProperty, componentIndex );
     }
 
     return func;
@@ -278,20 +193,19 @@ private:
 
 protected:
 
-  Property::Index mTargetIndex;
-
   ConstraintFunctionPtr mUserFunction;
+
 };
 
 /**
- * Variant which allows float components to be animated individually.
+ * Variant which allows float components to be constrained individually.
  */
 template <>
 class Constraint<float> : public ConstraintBase
 {
 public:
 
-  typedef typename PropertyConstraintPtr<float>::Type ConstraintFunctionPtr;
+  using ConstraintFunctionPtr = typename PropertyConstraintPtr<float>::Type;
 
   /**
    * Construct a new constraint.
@@ -306,29 +220,7 @@ public:
                               SourceContainer& sources,
                               ConstraintFunctionPtr func )
   {
-    return new Constraint< float >( object, targetIndex, sources, func );
-  }
-
-  /**
-   * @copydoc ConstraintBase::Clone()
-   */
-  virtual ConstraintBase* Clone( Object& object )
-  {
-    DALI_ASSERT_ALWAYS( !mSourceDestroyed && "An input source object has been destroyed" );
-
-    ConstraintBase* clone( NULL );
-
-    ConstraintFunctionPtr funcPtr( mUserFunction->Clone() );
-
-    clone = new Constraint< float >( object,
-                                     mTargetIndex,
-                                     mSources,
-                                     funcPtr );
-
-    clone->SetRemoveAction(mRemoveAction);
-    clone->SetTag( mTag );
-
-    return clone;
+    return new Constraint( object, targetIndex, sources, func );
   }
 
   /**
@@ -342,6 +234,18 @@ public:
 private:
 
   /**
+   * @copydoc ConstraintBase::DoClone()
+   */
+  virtual ConstraintBase* DoClone( Object& object ) override final
+  {
+    ConstraintFunctionPtr funcPtr( mUserFunction->Clone() );
+    return new Constraint( object,
+                           mTargetPropertyIndex,
+                           mSources,
+                           funcPtr );
+  }
+
+  /**
    * Private constructor; see also Constraint::New().
    */
   Constraint( Object& object,
@@ -349,29 +253,25 @@ private:
               SourceContainer& sources,
               ConstraintFunctionPtr& func )
   : ConstraintBase( object, targetIndex, sources ),
-    mTargetIndex( targetIndex ),
     mUserFunction( func )
   {
   }
 
   // Undefined
-  Constraint( const Constraint& );
-
-  // Undefined
-  Constraint& operator=( const Constraint& rhs );
+  Constraint() = delete;
+  Constraint( const Constraint& ) = delete;
+  Constraint& operator=( const Constraint& rhs ) = delete;
 
   /**
-   * Create and connect a constraint for a scene-object.
+   * @copydoc ConstraintBase::ConnectConstraint()
    */
-  void ConnectConstraint()
+  void ConnectConstraint() override final
   {
-    // Should not come here if target-object has been destroyed
-    DALI_ASSERT_DEBUG( NULL != mTargetObject );
-
+    // Should not come here if target object has been destroyed
+    DALI_ASSERT_DEBUG( nullptr != mTargetObject );
     // Guard against double connections
-    DALI_ASSERT_DEBUG( NULL == mSceneGraphConstraint );
+    DALI_ASSERT_DEBUG( nullptr == mSceneGraphConstraint );
 
-    // Short-circuit until the target scene-object exists
     SceneGraph::PropertyOwner& targetObject = const_cast< SceneGraph::PropertyOwner& >( mTargetObject->GetSceneObject() );
 
     // Build a container of property-owners, providing the scene-graph properties
@@ -384,47 +284,34 @@ private:
     if ( func )
     {
       // Create the SceneGraphConstraint, and connect to the scene-graph
-
-      const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetIndex );
-      OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
-
+      bool resetterRequired = false;
+      const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetPropertyIndex );
       // The targetProperty should exist, when targetObject exists
-      DALI_ASSERT_ALWAYS( NULL != targetProperty && "Constraint target property does not exist" );
-
-      const int componentIndex = mTargetObject->GetPropertyComponentIndex( mTargetIndex );
-
+      DALI_ASSERT_ALWAYS( nullptr != targetProperty && "Constraint target property does not exist" );
+      const int32_t componentIndex = mTargetObject->GetPropertyComponentIndex( mTargetPropertyIndex );
       if ( Property::INVALID_COMPONENT_INDEX == componentIndex )
       {
         // Not a Vector2, Vector3 or Vector4 component, expecting float type
         DALI_ASSERT_DEBUG( PropertyTypes::Get< float >() == targetProperty->GetType() );
 
-        typedef SceneGraph::Constraint< float, PropertyAccessor<float> > SceneGraphConstraint;
-
-        mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
-        resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
+        mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyAccessor<float> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+        resetterRequired = true;
       }
       else
       {
         // Expecting Vector2, Vector3 or Vector4 type
-
         if ( PropertyTypes::Get< Vector2 >() == targetProperty->GetType() )
         {
           // Constrain float component of Vector2 property
-
           if ( 0 == componentIndex )
           {
-            typedef SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector2> > SceneGraphConstraint;
-            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+            mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector2> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 1 == componentIndex )
           {
-            typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector2> > SceneGraphConstraint;
-            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
-          }
-          if( mSceneGraphConstraint )
-          {
-            resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
+            mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector2> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
+          resetterRequired = (mSceneGraphConstraint != nullptr);
         }
         else if ( PropertyTypes::Get< Vector3 >() == targetProperty->GetType() )
         {
@@ -433,18 +320,24 @@ private:
           {
             if ( 0 == componentIndex )
             {
-              typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,0> > SceneGraphConstraint;
-              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+              mSceneGraphConstraint = SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,0> >::New( *targetProperty,
+                                                                                                                                  propertyOwners,
+                                                                                                                                  func,
+                                                                                                                                  mRemoveAction );
             }
             else if ( 1 == componentIndex )
             {
-              typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,1> > SceneGraphConstraint;
-              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+              mSceneGraphConstraint = SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,1> >::New( *targetProperty,
+                                                                                                                                  propertyOwners,
+                                                                                                                                  func,
+                                                                                                                                  mRemoveAction );
             }
             else if ( 2 == componentIndex )
             {
-              typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,2> > SceneGraphConstraint;
-              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+              mSceneGraphConstraint = SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,2> >::New( *targetProperty,
+                                                                                                                                  propertyOwners,
+                                                                                                                                  func,
+                                                                                                                                  mRemoveAction );
             }
             // Do not create a resetter for transform manager property
           }
@@ -452,65 +345,51 @@ private:
           {
             if ( 0 == componentIndex )
             {
-              typedef SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector3> > SceneGraphConstraint;
-              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+              mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector3> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
             else if ( 1 == componentIndex )
             {
-              typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector3> > SceneGraphConstraint;
-              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+              mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector3> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
             else if ( 2 == componentIndex )
             {
-              typedef SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector3> > SceneGraphConstraint;
-              mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
-            }
-            if( mSceneGraphConstraint )
-            {
-              resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
+              mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector3> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
             }
+            resetterRequired = (mSceneGraphConstraint != nullptr);
           }
         }
         else if ( PropertyTypes::Get< Vector4 >() == targetProperty->GetType() )
         {
           // Constrain float component of Vector4 property
-
           if ( 0 == componentIndex )
           {
-            typedef SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector4> > SceneGraphConstraint;
-            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+            mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 1 == componentIndex )
           {
-            typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector4> > SceneGraphConstraint;
-            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+            mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 2 == componentIndex )
           {
-            typedef SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector4> > SceneGraphConstraint;
-            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+            mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
           else if ( 3 == componentIndex )
           {
-            typedef SceneGraph::Constraint< float, PropertyComponentAccessorW<Vector4> > SceneGraphConstraint;
-            mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+            mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorW<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
           }
 
-          if( mSceneGraphConstraint )
-          {
-            resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
-          }
+          resetterRequired = (mSceneGraphConstraint != nullptr);
         }
       }
-
       if( mSceneGraphConstraint )
       {
         OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
         ApplyConstraintMessage( GetEventThreadServices(), targetObject, transferOwnership );
-      }
-      if( resetter != nullptr )
-      {
-        AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
+        if( resetterRequired )
+        {
+          OwnerPointer<SceneGraph::PropertyResetterBase> resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
+          AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
+        }
       }
     }
   }
@@ -519,76 +398,27 @@ private:
    * Helper for ConnectConstraint. Creates a connected constraint-function.
    * Also populates the property-owner container, for each input connected to the constraint-function.
    * @param[out] propertyOwners The container of property-owners providing the scene-graph properties.
-   * @return A connected constraint-function, or NULL if the scene-graph properties are not available.
+   * @return A connected constraint-function, or nullptr if the scene-graph properties are not available.
    */
   PropertyConstraint<float>* ConnectConstraintFunction( SceneGraph::PropertyOwnerContainer& propertyOwners )
   {
     PropertyConstraint<float>* func = mUserFunction->Clone();
 
-    for ( SourceIter iter = mSources.begin(); mSources.end() != iter; ++iter )
+    for ( auto&& source : mSources )
     {
-      Source& source = *iter;
-
-      PropertyInputImpl* inputProperty( NULL );
-      int componentIndex( Property::INVALID_COMPONENT_INDEX );
-
-      if ( OBJECT_PROPERTY == source.sourceType )
-      {
-        DALI_ASSERT_ALWAYS( source.object->IsPropertyAConstraintInput( source.propertyIndex ) );
-
-        SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( source.object->GetSceneObject() );
-
-        // The property owner will not exist, if the target object is off-stage
-        AddUnique( propertyOwners, &owner );
-        inputProperty = const_cast< PropertyInputImpl* >( source.object->GetSceneObjectInputProperty( source.propertyIndex ) );
-        componentIndex = source.object->GetPropertyComponentIndex( source.propertyIndex );
-
-        // The scene-object property should exist, when the property owner exists
-        DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
-      }
-      else if ( LOCAL_PROPERTY == source.sourceType )
-      {
-        DALI_ASSERT_ALWAYS( mTargetObject->IsPropertyAConstraintInput( source.propertyIndex ) );
+      int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
+      PropertyInputImpl* inputProperty = AddInputProperty( source, propertyOwners, componentIndex );
 
-        inputProperty = const_cast< PropertyInputImpl* >( mTargetObject->GetSceneObjectInputProperty( source.propertyIndex ) );
-        componentIndex = mTargetObject->GetPropertyComponentIndex( source.propertyIndex );
-
-        // The target scene-object should provide this property
-        DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
-      }
-      else
-      {
-        DALI_ASSERT_ALWAYS( PARENT_PROPERTY == source.sourceType && "Constraint source property type is invalid" );
-
-        Object* objectParent = dynamic_cast< Actor& >( *mTargetObject ).GetParent();
-
-        // This will not exist, if the target object is off-stage
-        if ( NULL != objectParent )
-        {
-          DALI_ASSERT_ALWAYS( objectParent->IsPropertyAConstraintInput( source.propertyIndex ) );
-
-          SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( objectParent->GetSceneObject() );
-
-          // The property owner will not exist, if the parent object is off-stage
-          AddUnique( propertyOwners, &owner );
-          inputProperty = const_cast< PropertyInputImpl* >( objectParent->GetSceneObjectInputProperty( source.propertyIndex ) );
-          componentIndex = objectParent->GetPropertyComponentIndex( source.propertyIndex );
-
-          // The scene-object property should exist, when the property owner exists
-          DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
-        }
-      }
-
-      if ( NULL == inputProperty )
+      if ( nullptr == inputProperty )
       {
         delete func;
-        func = NULL;
+        func = nullptr;
 
         // Exit if a scene-graph object is not available from one of the sources
         break;
       }
 
-      func->SetInput( ( iter - mSources.begin() ), componentIndex, *inputProperty );
+      func->AddInput( inputProperty, componentIndex );
     }
 
     return func;
@@ -596,9 +426,8 @@ private:
 
 protected:
 
-  Property::Index mTargetIndex;
-
   ConstraintFunctionPtr mUserFunction;
+
 };
 
 } // namespace Internal
index 20cba76..f08c7d2 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_PROPERTY_CONSTRAINT_H__
 
 /*
- * Copyright (c) 2014 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.
@@ -40,23 +40,19 @@ class PropertyConstraint
 {
 public:
 
-  typedef std::vector < PropertyInputAccessor > InputContainer;
-  typedef typename InputContainer::iterator InputContainerIter;
-  typedef typename InputContainer::const_iterator InputContainerConstIter;
-
-  typedef std::vector< PropertyInputIndexer< PropertyInputAccessor > > InputIndexerContainer;
-
-  typedef Dali::Constraint::Function< PropertyType > ConstraintFunction;
+  using ConstraintFunction = Dali::Constraint::Function< PropertyType >;
+  using InputContainer = std::vector < PropertyInputAccessor >;
+  using InputIndexerContainer = std::vector< PropertyInputIndexer< PropertyInputAccessor > >;
 
   /**
    * Create a property constraint.
    *
    * @param[in]  func  A constraint function. Ownership of this callback-function is passed to this object.
    */
-  PropertyConstraint( Dali::Constraint::Function< PropertyType >* func )
-  : mInputsInitialized( false ),
-    mFunction( func ),
-    mInputs()
+  PropertyConstraint( ConstraintFunction* func )
+  : mFunction( func ),
+    mInputs(),
+    mInputsInitialized( false )
   {
   }
 
@@ -65,11 +61,11 @@ public:
    * @param [in]  func    A constraint function. Ownership of this callback-function is passed to this object.
    * @param [in]  inputs  Property inputs.
    */
-  PropertyConstraint( Dali::Constraint::Function< PropertyType >* func,
+  PropertyConstraint( ConstraintFunction* func,
                       const InputContainer& inputs )
-  : mInputsInitialized( false ),
-    mFunction( func ),
-    mInputs( inputs )
+  : mFunction( func ),
+    mInputs( inputs ),
+    mInputsInitialized( false )
   {
   }
 
@@ -95,32 +91,27 @@ public:
 
   /**
    * Set the input for one of the property constraint parameters.
-   * @param [in] index The parameter index.
    * @param [in] input The interface for receiving a property value.
+   * @param [in] componentIndex Component index.
    */
-  void SetInput( std::size_t index, int componentIndex, const PropertyInputImpl& input )
+  void AddInput( const PropertyInputImpl* input, int32_t componentIndex )
   {
-    if ( index >= mInputs.size() )
-    {
-      mInputs.push_back( PropertyInputAccessor() );
-    }
-
-    mInputs[ index ].SetInput( input, componentIndex );
+    mInputs.push_back( PropertyInputAccessor{ input, componentIndex } );
   }
 
   /**
    * Retrieve the input for one of the property constraint parameters.
    * @param [in] index The parameter index.
-   * @return The property input, or NULL if no input exists with this index.
+   * @return The property input, or nullptr if no input exists with this index.
    */
-  const PropertyInputImpl* GetInput( unsigned int index ) const
+  const PropertyInputImpl* GetInput( uint32_t index ) const
   {
     if ( index < mInputs.size() )
     {
       return mInputs[ index ].GetInput();
     }
 
-    return NULL;
+    return nullptr;
   }
 
   /**
@@ -132,9 +123,9 @@ public:
     if ( !mInputsInitialized )
     {
       // Check whether the inputs are initialized yet
-      unsigned int index( 0u );
+      uint32_t index( 0u );
       for ( const PropertyInputImpl* input = GetInput( index );
-            NULL != input;
+            nullptr != input;
             input = GetInput( ++index ) )
       {
         if ( !input->InputInitialized() )
@@ -156,9 +147,9 @@ public:
    */
   bool InputsChanged()
   {
-    unsigned int index( 0u );
+    uint32_t index( 0u );
     for ( const PropertyInputImpl* input = GetInput( index );
-          NULL != input;
+          nullptr != input;
           input = GetInput( ++index ) )
     {
       if ( input->InputChanged() )
@@ -178,40 +169,38 @@ public:
    */
   void Apply( BufferIndex bufferIndex, PropertyType& current )
   {
-    InputIndexerContainer mInputIndices;
-    PropertyInputContainer mIndices;
-    const std::size_t noOfInputs = mInputs.size();
+    InputIndexerContainer inputIndices;
+    PropertyInputContainer indices;
+    const uint32_t noOfInputs = static_cast<uint32_t>( mInputs.size() );
 
-    mInputIndices.reserve( noOfInputs );
-    mIndices.Reserve( noOfInputs );
+    inputIndices.reserve( noOfInputs );
+    indices.Reserve( noOfInputs );
 
-    const InputContainerConstIter endIter = mInputs.end();
-    unsigned int index = 0;
-    for ( InputContainerConstIter iter = mInputs.begin(); iter != endIter; ++iter, ++index )
+    const auto&& endIter = mInputs.end();
+    uint32_t index = 0;
+    for ( auto&& iter = mInputs.begin(); iter != endIter; ++iter, ++index )
     {
-      DALI_ASSERT_DEBUG( NULL != iter->GetInput() );
-      mInputIndices.push_back( PropertyInputIndexer< PropertyInputAccessor >( bufferIndex, &*iter ) );
-      mIndices.PushBack( &mInputIndices[ index ] );
+      DALI_ASSERT_DEBUG( nullptr != iter->GetInput() );
+      inputIndices.push_back( PropertyInputIndexer< PropertyInputAccessor >( bufferIndex, &*iter ) );
+      indices.PushBack( &inputIndices[ index ] );
     }
 
-    CallbackBase::Execute< PropertyType&, const PropertyInputContainer& >( *mFunction, current, mIndices );
+    CallbackBase::Execute< PropertyType&, const PropertyInputContainer& >( *mFunction, current, indices );
   }
 
 private:
 
   // Undefined
-  PropertyConstraint( const PropertyConstraint& );
-
-  // Undefined
-  PropertyConstraint& operator=( const PropertyConstraint& rhs );
+  PropertyConstraint() = delete;
+  PropertyConstraint( const PropertyConstraint& ) = delete;
+  PropertyConstraint& operator=( const PropertyConstraint& rhs ) = delete;
 
 private:
 
-  bool mInputsInitialized;
-
   ConstraintFunction* mFunction;
-
   InputContainer mInputs;
+  bool mInputsInitialized;
+
 };
 
 } // namespace Internal
index aca460b..40893f7 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_PROPERTY_INPUT_ACCESSOR_H__
 
 /*
- * Copyright (c) 2016 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.
@@ -36,7 +36,7 @@ public:
    * Create the PropertyInputAccessor.
    */
   PropertyInputAccessor()
-  : mInput( NULL ),
+  : mInput( nullptr ),
     mComponentIndex( -1 )
   {
   }
@@ -44,7 +44,7 @@ public:
   /**
    * Create the PropertyInputAccessor.
    */
-  PropertyInputAccessor( const PropertyInputImpl* input, int componentIndex )
+  PropertyInputAccessor( const PropertyInputImpl* input, int32_t componentIndex )
   : mInput( input ),
     mComponentIndex( componentIndex )
   {
@@ -75,7 +75,7 @@ public:
   /**
    * Set the property input.
    */
-  void SetInput( const PropertyInputImpl& input, int componentIndex )
+  void SetInput( const PropertyInputImpl& input, int32_t componentIndex )
   {
     mInput = &input;
     mComponentIndex = componentIndex;
@@ -220,7 +220,8 @@ public:
 public:
 
   const PropertyInputImpl* mInput;
-  int mComponentIndex;
+  int32_t mComponentIndex;
+
 };
 
 } // namespace Internal
index d26ad90..cf37c1f 100644 (file)
@@ -43,7 +43,7 @@ public:
    * @param [in] property The property to access.
    */
   PropertyAccessor( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
   {
   }
 
@@ -60,7 +60,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -69,7 +69,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -86,7 +86,7 @@ public:
    */
   const PropertyType& Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
     return mProperty->Get( bufferIndex );
   }
 
@@ -95,7 +95,7 @@ public:
    */
   void Set( BufferIndex bufferIndex, const PropertyType& value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
     mProperty->Set( bufferIndex, value );
   }
 
@@ -104,27 +104,25 @@ public:
    */
   void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
     mProperty->Bake( bufferIndex, value );
   }
 
 private:
 
   // Undefined
-  PropertyAccessor(const PropertyAccessor& property);
-
-  // Undefined
-  PropertyAccessor& operator=(const PropertyAccessor& rhs);
+  PropertyAccessor() = delete;
+  PropertyAccessor(const PropertyAccessor& property) = delete;
+  PropertyAccessor& operator=(const PropertyAccessor& rhs) = delete;
 
 private:
 
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
-};
-
 
+};
 
 /**
- * A wrapper class for getting/setting a property.
+ * A wrapper class for getting/setting a transform manager property
  * Animators use this instead of accessing properties directly.
  */
 template <typename T>
@@ -137,7 +135,7 @@ public:
    * @param [in] property The property to access.
    */
   TransformManagerPropertyAccessor( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) )
+  : mProperty( static_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) ) // we know the type
   {
   }
 
@@ -154,7 +152,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -163,7 +161,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -181,7 +179,7 @@ public:
    */
   const T& Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
     return mProperty->Get( bufferIndex );
   }
 
@@ -190,7 +188,7 @@ public:
    */
   void Set( BufferIndex bufferIndex, const T& value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
     mProperty->Set( bufferIndex, value );
   }
 
@@ -199,24 +197,27 @@ public:
    */
   void Bake( BufferIndex bufferIndex, const T& value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
     mProperty->Bake( bufferIndex, value );
   }
 
 private:
 
   // Undefined
-  TransformManagerPropertyAccessor(const TransformManagerPropertyAccessor& property);
-
-  // Undefined
-  TransformManagerPropertyAccessor& operator=(const TransformManagerPropertyAccessor& rhs);
+  TransformManagerPropertyAccessor() = delete;
+  TransformManagerPropertyAccessor(const TransformManagerPropertyAccessor& property) = delete;
+  TransformManagerPropertyAccessor& operator=(const TransformManagerPropertyAccessor& rhs) = delete;
 
 private:
 
   SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
-};
 
+};
 
+/**
+ * A wrapper class for getting/setting a transform manager property component
+ * Animators use this instead of accessing properties directly.
+ */
 template <typename T, uint32_t COMPONENT>
 class TransformManagerPropertyComponentAccessor
 {
@@ -227,7 +228,7 @@ public:
    * @param [in] property The property to access.
    */
   TransformManagerPropertyComponentAccessor( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) )
+  : mProperty( static_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) ) // we know the type
   {
   }
 
@@ -244,7 +245,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -253,7 +254,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -269,41 +270,41 @@ public:
    * @param [in] bufferIndex The current update buffer index.
    * @return The value of the component of the property
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
     return mProperty->GetFloatComponent( COMPONENT );
   }
 
   /**
    * @copydoc AnimatableProperty<float>::Set()
    */
-  void Set( BufferIndex bufferIndex, const float& value ) const
+  void Set( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
     mProperty->SetFloatComponent( value, COMPONENT );
   }
 
   /**
    * @copydoc AnimatableProperty<float>::Bake()
    */
-  void Bake( BufferIndex bufferIndex, const float& value ) const
+  void Bake( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
     mProperty->BakeFloatComponent( value, COMPONENT );
   }
 
 private:
 
   // Undefined
-  TransformManagerPropertyComponentAccessor(const TransformManagerPropertyComponentAccessor& property);
-
-  // Undefined
-  TransformManagerPropertyComponentAccessor& operator=(const TransformManagerPropertyComponentAccessor& rhs);
+  TransformManagerPropertyComponentAccessor() = delete;
+  TransformManagerPropertyComponentAccessor(const TransformManagerPropertyComponentAccessor& property) = delete;
+  TransformManagerPropertyComponentAccessor& operator=(const TransformManagerPropertyComponentAccessor& rhs) = delete;
 
 private:
 
   SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
+
 };
 
 } // namespace Internal
index e1e596b..4faf682 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
 
 /*
- * Copyright (c) 2014 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.
@@ -42,7 +42,7 @@ public:
    * @param [in] property The property which holds a float component.
    */
   PropertyComponentAccessorX( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
   {
   }
 
@@ -59,7 +59,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -68,7 +68,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -83,9 +83,9 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr" );
     return mProperty->Get( bufferIndex ).x; // X Component only!
   }
 
@@ -94,7 +94,7 @@ public:
    */
   void Set( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr" );
     mProperty->SetX( bufferIndex, value );
   }
 
@@ -103,21 +103,21 @@ public:
    */
   void Bake( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr" );
     mProperty->BakeX( bufferIndex, value );
   }
 
 private:
 
   // Undefined
-  PropertyComponentAccessorX(const PropertyComponentAccessorX& property);
-
-  // Undefined
-  PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs);
+  PropertyComponentAccessorX() = delete;
+  PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
+  PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
 
 private:
 
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
+
 };
 
 /**
@@ -134,7 +134,7 @@ public:
    * @param [in] property The property which holds a float component.
    */
   PropertyComponentAccessorY( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
   {
   }
 
@@ -151,7 +151,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -160,7 +160,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -175,9 +175,9 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr" );
     return mProperty->Get( bufferIndex ).y; // Y Component only!
   }
 
@@ -186,7 +186,7 @@ public:
    */
   void Set( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr" );
     mProperty->SetY( bufferIndex, value );
   }
 
@@ -195,17 +195,16 @@ public:
    */
   void Bake( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr" );
     mProperty->BakeY( bufferIndex, value );
   }
 
 private:
 
   // Undefined
-  PropertyComponentAccessorY(const PropertyComponentAccessorY& property);
-
-  // Undefined
-  PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs);
+  PropertyComponentAccessorY() = delete;
+  PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
+  PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
 
 private:
 
@@ -226,7 +225,7 @@ public:
    * @param [in] property The property which holds a float component.
    */
   PropertyComponentAccessorZ( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
   {
   }
 
@@ -243,7 +242,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -252,7 +251,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -267,9 +266,9 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr" );
     return mProperty->Get( bufferIndex ).z; // Z Component only!
   }
 
@@ -278,7 +277,7 @@ public:
    */
   void Set( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr" );
     mProperty->SetZ( bufferIndex, value );
   }
 
@@ -287,17 +286,16 @@ public:
    */
   void Bake( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr" );
     mProperty->BakeZ( bufferIndex, value );
   }
 
 private:
 
   // Undefined
-  PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property);
-
-  // Undefined
-  PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs);
+  PropertyComponentAccessorZ() = delete;
+  PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
+  PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
 
 private:
 
@@ -318,7 +316,7 @@ public:
    * @param [in] property The property which holds a float component.
    */
   PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
   {
   }
 
@@ -335,7 +333,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -344,7 +342,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -359,9 +357,9 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Get() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr" );
     return mProperty->Get( bufferIndex ).w; // W Component only!
   }
 
@@ -370,7 +368,7 @@ public:
    */
   void Set( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Set() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr" );
     mProperty->SetW( bufferIndex, value );
   }
 
@@ -379,21 +377,21 @@ public:
    */
   void Bake( BufferIndex bufferIndex, float value ) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Bake() mProperty was NULL" );
+    DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr" );
     mProperty->BakeW( bufferIndex, value );
   }
 
 private:
 
   // Undefined
-  PropertyComponentAccessorW(const PropertyComponentAccessorW& property);
-
-  // Undefined
-  PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs);
+  PropertyComponentAccessorW() = delete;
+  PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
+  PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
 
 private:
 
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
+
 };
 
 } // namespace Internal
index 6e47cac..349ab20 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_H__
 
 /*
- * Copyright (c) 2017 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.
@@ -45,7 +45,7 @@ class Constraint : public ConstraintBase
 {
 public:
 
-  typedef typename PropertyConstraintPtr< PropertyType >::Type ConstraintFunctionPtr;
+  using ConstraintFunctionPtr = typename PropertyConstraintPtr< PropertyType >::Type;
 
   /**
    * Create a new scene-graph constraint.
@@ -81,31 +81,29 @@ public:
    */
   virtual void Apply( BufferIndex updateBufferIndex )
   {
-    if ( mDisconnected )
+    if ( !mDisconnected )
     {
-      return; // Early-out when property owners have been disconnected
-    }
-
-    if ( mFunc->InputsInitialized() )
-    {
-      PropertyType current = mTargetProperty.Get( updateBufferIndex );
-      mFunc->Apply( updateBufferIndex, current );
-
-      // Optionally bake the final value
-      if ( Dali::Constraint::Bake == mRemoveAction )
+      if ( mFunc->InputsInitialized() )
       {
-        mTargetProperty.Bake( updateBufferIndex, current );
+        PropertyType current = mTargetProperty.Get( updateBufferIndex );
+        mFunc->Apply( updateBufferIndex, current );
+
+        // Optionally bake the final value
+        if ( Dali::Constraint::Bake == mRemoveAction )
+        {
+          mTargetProperty.Bake( updateBufferIndex, current );
+        }
+        else
+        {
+          mTargetProperty.Set( updateBufferIndex, current );
+        }
+
+        INCREASE_COUNTER(PerformanceMonitor::CONSTRAINTS_APPLIED);
       }
       else
       {
-        mTargetProperty.Set( updateBufferIndex, current );
+        INCREASE_COUNTER(PerformanceMonitor::CONSTRAINTS_SKIPPED);
       }
-
-      INCREASE_COUNTER(PerformanceMonitor::CONSTRAINTS_APPLIED);
-    }
-    else
-    {
-      INCREASE_COUNTER(PerformanceMonitor::CONSTRAINTS_SKIPPED);
     }
   }
 
@@ -125,10 +123,9 @@ private:
   }
 
   // Undefined
-  Constraint( const Constraint& constraint );
-
-  // Undefined
-  Constraint& operator=( const Constraint& rhs );
+  Constraint() = delete;
+  Constraint( const Constraint& constraint ) = delete;
+  Constraint& operator=( const Constraint& rhs ) = delete;
 
   /**
    * @copydoc Dali::Internal::SceneGraph::ConstraintBase::OnDisconnect()
@@ -137,7 +134,7 @@ private:
   {
     // Discard target object/property pointers
     mTargetProperty.Reset();
-    mFunc = NULL;
+    mFunc = nullptr;
   }
 
 protected:
@@ -145,6 +142,7 @@ protected:
   PropertyAccessorType mTargetProperty; ///< Raw-pointer to the target property. Not owned.
 
   ConstraintFunctionPtr mFunc;
+
 };
 
 } // namespace SceneGraph