*/
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();
// 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
*/
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 )
/**
* Retrieve the parent of the AnimatorConnector.
- * @return The parent object, or NULL.
+ * @return The parent object, or nullptr.
*/
Animation* GetParent() const
{
#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>
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 ),
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();
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
#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
{
* @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.
// 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.
{
/**
- * 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 >
{
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.
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().
*/
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() );
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 );
}
* 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;
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.
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 );
}
/**
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,
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
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() )
{
{
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
}
{
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 );
+ }
}
}
}
* 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;
protected:
- Property::Index mTargetIndex;
-
ConstraintFunctionPtr mUserFunction;
+
};
} // namespace Internal
#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.
{
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 )
{
}
* @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 )
{
}
/**
* 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;
}
/**
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() )
*/
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() )
*/
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
#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.
* Create the PropertyInputAccessor.
*/
PropertyInputAccessor()
- : mInput( NULL ),
+ : mInput( nullptr ),
mComponentIndex( -1 )
{
}
/**
* Create the PropertyInputAccessor.
*/
- PropertyInputAccessor( const PropertyInputImpl* input, int componentIndex )
+ PropertyInputAccessor( const PropertyInputImpl* input, int32_t componentIndex )
: mInput( input ),
mComponentIndex( componentIndex )
{
/**
* Set the property input.
*/
- void SetInput( const PropertyInputImpl& input, int componentIndex )
+ void SetInput( const PropertyInputImpl& input, int32_t componentIndex )
{
mInput = &input;
mComponentIndex = componentIndex;
public:
const PropertyInputImpl* mInput;
- int mComponentIndex;
+ int32_t mComponentIndex;
+
};
} // namespace Internal
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
*/
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 );
}
*/
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 );
}
*/
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>
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
*/
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 );
}
*/
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 );
}
*/
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
{
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
* @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
#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.
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
* 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!
}
*/
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 );
}
*/
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
+
};
/**
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
* 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!
}
*/
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 );
}
*/
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:
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
* 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!
}
*/
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 );
}
*/
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:
* @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
{
}
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
* 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!
}
*/
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 );
}
*/
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
#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.
{
public:
- typedef typename PropertyConstraintPtr< PropertyType >::Type ConstraintFunctionPtr;
+ using ConstraintFunctionPtr = typename PropertyConstraintPtr< PropertyType >::Type;
/**
* Create a new scene-graph constraint.
*/
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);
}
}
}
// 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()
{
// Discard target object/property pointers
mTargetProperty.Reset();
- mFunc = NULL;
+ mFunc = nullptr;
}
protected:
PropertyAccessorType mTargetProperty; ///< Raw-pointer to the target property. Not owned.
ConstraintFunctionPtr mFunc;
+
};
} // namespace SceneGraph