From 213407cee3425b2b9061e4a46b52ff7ece78e525 Mon Sep 17 00:00:00 2001 From: Richard Underhill Date: Wed, 19 Mar 2014 11:25:20 +0000 Subject: [PATCH] Boost::any replacement in Dali Core functions [Issue#] N/A [Problem] [Cause] [Solution] [Notes] This needs to be verified with the corresponding adaptor and CAPI patches: http://slp-info.sec.samsung.net/gerrit/#/c/450053/ http://slp-info.sec.samsung.net/gerrit/#/c/450681/ [Updates] Patch Set 2 Changes: * Updated comments according to Kimmo feedback. Patch Set 3: * Synced with CAPI patch set 5. Patch Set 4: * Simple rebase. Signed-off-by: Richard Underhill --- capi/dali/public-api/animation/active-constraint.h | 1 + capi/dali/public-api/animation/animation.h | 4 +- capi/dali/public-api/animation/constraint.h | 4 +- .../public-api/animation/interpolator-functions.h | 6 +- capi/dali/public-api/object/any.h | 21 ++-- .../event/animation/active-constraint-base.h | 2 +- dali/internal/event/animation/animation-impl.cpp | 12 +-- dali/internal/event/animation/constraint-impl.cpp | 31 +++--- dali/internal/event/animation/constraint-impl.h | 2 +- dali/public-api/object/property-value.cpp | 108 ++++++++++----------- 10 files changed, 95 insertions(+), 96 deletions(-) diff --git a/capi/dali/public-api/animation/active-constraint.h b/capi/dali/public-api/animation/active-constraint.h index 84f3902..a1ae23f 100644 --- a/capi/dali/public-api/animation/active-constraint.h +++ b/capi/dali/public-api/animation/active-constraint.h @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include +#include #include #include diff --git a/capi/dali/public-api/animation/animation.h b/capi/dali/public-api/animation/animation.h index 622b737..2549d58 100644 --- a/capi/dali/public-api/animation/animation.h +++ b/capi/dali/public-api/animation/animation.h @@ -23,13 +23,13 @@ */ // EXTERNAL INCLUDES -#include #include // INTERNAL INCLUDES #include #include #include +#include #include #include #include @@ -117,7 +117,7 @@ public: typedef SignalV2< void (Animation&) > AnimationSignalV2; ///< Animation finished signal type - typedef boost::any AnyFunction; ///< Interpolation function + typedef Any AnyFunction; ///< Interpolation function typedef boost::function Vector3AnimatorFunc; ///< Interpolation function typedef boost::function QuaternionAnimatorFunc; ///< Interpolation function diff --git a/capi/dali/public-api/animation/constraint.h b/capi/dali/public-api/animation/constraint.h index 5d12aed..b00af1b 100644 --- a/capi/dali/public-api/animation/constraint.h +++ b/capi/dali/public-api/animation/constraint.h @@ -23,13 +23,13 @@ */ // EXTERNAL INCLUDES -#include #include // INTERNAL INCLUDES #include #include #include +#include #include #include #include @@ -55,7 +55,7 @@ class DALI_IMPORT_API Constraint : public BaseHandle { public: - typedef boost::any AnyFunction; ///< Generic function pointer for constraint and interpolator functions + typedef Any AnyFunction; ///< Generic function pointer for constraint and interpolator functions /** * @brief The action that will happen when the constraint is removed. diff --git a/capi/dali/public-api/animation/interpolator-functions.h b/capi/dali/public-api/animation/interpolator-functions.h index 2b2ca05..124c69c 100644 --- a/capi/dali/public-api/animation/interpolator-functions.h +++ b/capi/dali/public-api/animation/interpolator-functions.h @@ -22,10 +22,8 @@ * @{ */ -// EXTERNAL INCLUDES -#include - // INTERNAL INCLUDES +#include #include #include #include @@ -181,7 +179,7 @@ typedef boost::function Any& operator=( const Type& value ) { - // If the container is empty then assign the new value if ( NULL == mContainer ) { @@ -133,9 +130,9 @@ public: /** * @brief Assignment operator. * - * @note Asserts if values of different types are assigned. + * @exception DaliException If parameter any is of a different type. * - * @param [in] any Any to be assigned. + * @param [in] any Any to be assigned which contains a value of identical type to current contents. */ Any& operator=( const Any& any ); @@ -153,7 +150,8 @@ public: /** * @brief Returns the type info of the stored value. * - * @note Returns the info of the void type if there is no value stored. + * @return The std::type_info of the stored value or the type info of the void + * type if there is no value stored. */ const std::type_info& GetType() const; @@ -202,7 +200,7 @@ public: /** * @brief Returns whether container holds a value * - * @return true or false + * @return true if the container is empty, else false. */ bool Empty() { @@ -313,13 +311,18 @@ public: /** * @brief Get the container's stored value * - * @return value of Type + * @return value of type Type */ const Type& GetValue() const { return mValue; } + /** + * @brief Set the container's stored value + * + * @param value of type Type + */ void SetValue( const Type& value ) { mValue = value; diff --git a/dali/internal/event/animation/active-constraint-base.h b/dali/internal/event/animation/active-constraint-base.h index 895867e..051ee19 100644 --- a/dali/internal/event/animation/active-constraint-base.h +++ b/dali/internal/event/animation/active-constraint-base.h @@ -49,7 +49,7 @@ class ActiveConstraintBase : public ProxyObject public: typedef Dali::Constraint::RemoveAction RemoveAction; - typedef boost::any AnyFunction; + typedef Any AnyFunction; /** * Constructor. diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index 74a12ac..d162c3b 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -617,7 +617,7 @@ void Animation::Animate( Property& target, Property::Type targetType, AnyFunctio AddAnimatorConnector( AnimatorConnector::New(proxy, target.propertyIndex, target.componentIndex, - boost::any_cast< AnimatorFunctionBool >( func ), + AnyCast< AnimatorFunctionBool >( func ), alpha, period) ); break; @@ -628,7 +628,7 @@ void Animation::Animate( Property& target, Property::Type targetType, AnyFunctio AddAnimatorConnector( AnimatorConnector::New(proxy, target.propertyIndex, target.componentIndex, - boost::any_cast< AnimatorFunctionFloat >( func ), + AnyCast< AnimatorFunctionFloat >( func ), alpha, period) ); break; @@ -639,7 +639,7 @@ void Animation::Animate( Property& target, Property::Type targetType, AnyFunctio AddAnimatorConnector( AnimatorConnector::New(proxy, target.propertyIndex, target.componentIndex, - boost::any_cast< AnimatorFunctionVector2 >( func ), + AnyCast< AnimatorFunctionVector2 >( func ), alpha, period) ); break; @@ -650,7 +650,7 @@ void Animation::Animate( Property& target, Property::Type targetType, AnyFunctio AddAnimatorConnector( AnimatorConnector::New(proxy, target.propertyIndex, target.componentIndex, - boost::any_cast< AnimatorFunctionVector3 >( func ), + AnyCast< AnimatorFunctionVector3 >( func ), alpha, period) ); break; @@ -661,7 +661,7 @@ void Animation::Animate( Property& target, Property::Type targetType, AnyFunctio AddAnimatorConnector( AnimatorConnector::New(proxy, target.propertyIndex, target.componentIndex, - boost::any_cast< AnimatorFunctionVector4 >( func ), + AnyCast< AnimatorFunctionVector4 >( func ), alpha, period) ); break; @@ -672,7 +672,7 @@ void Animation::Animate( Property& target, Property::Type targetType, AnyFunctio AddAnimatorConnector( AnimatorConnector::New(proxy, target.propertyIndex, target.componentIndex, - boost::any_cast< AnimatorFunctionQuaternion >( func ), + AnyCast< AnimatorFunctionQuaternion >( func ), alpha, period) ); break; diff --git a/dali/internal/event/animation/constraint-impl.cpp b/dali/internal/event/animation/constraint-impl.cpp index 3ce2a78..4e1e3ce 100644 --- a/dali/internal/event/animation/constraint-impl.cpp +++ b/dali/internal/event/animation/constraint-impl.cpp @@ -18,7 +18,6 @@ #include // EXTERNAL INCLUDES -#include #include // INTERNAL INCLUDES @@ -45,20 +44,20 @@ PropertyConstraintBase

* CreatePropertyConstraint( Constraint::AnyFunction& fu { case 0u: { - propertyConstraint = new PropertyConstraint0

( boost::any_cast >( func ) ); + propertyConstraint = new PropertyConstraint0

( AnyCast >( func ) ); break; } case 1u: { - propertyConstraint = new PropertyConstraint1( boost::any_cast< boost::function

( AnyCast< boost::function

>( func ) ); break; } case 2u: { - propertyConstraint = new PropertyConstraint2( boost::any_cast< boost::function

( AnyCast< boost::function

>( func ) ); break; @@ -66,7 +65,7 @@ PropertyConstraintBase

* CreatePropertyConstraint( Constraint::AnyFunction& fu case 3u: { - propertyConstraint = new PropertyConstraint3( boost::any_cast< boost::function

( AnyCast< boost::function

>( func ) ); @@ -75,7 +74,7 @@ PropertyConstraintBase

* CreatePropertyConstraint( Constraint::AnyFunction& fu case 4u: { - propertyConstraint = new PropertyConstraint4( boost::any_cast< boost::function

( AnyCast< boost::function

* CreatePropertyConstraint( Constraint::AnyFunction& fu case 5u: { - propertyConstraint = new PropertyConstraint5( boost::any_cast< boost::function

( AnyCast< boost::function

* CreatePropertyConstraint( Constraint::AnyFunction& fu case 6u: { - propertyConstraint = new PropertyConstraint6( boost::any_cast< boost::function

( AnyCast< boost::function

::New( targetIndex, sources, funcPtr, - boost::any_cast< BoolInterpolator >( interpolator ) ); + AnyCast< BoolInterpolator >( interpolator ) ); break; } @@ -147,7 +146,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< FloatInterpolator >( interpolator ) ); + AnyCast< FloatInterpolator >( interpolator ) ); break; } @@ -158,7 +157,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< Vector2Interpolator >( interpolator ) ); + AnyCast< Vector2Interpolator >( interpolator ) ); break; } @@ -169,7 +168,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< Vector3Interpolator >( interpolator ) ); + AnyCast< Vector3Interpolator >( interpolator ) ); break; } @@ -180,7 +179,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< Vector4Interpolator >( interpolator ) ); + AnyCast< Vector4Interpolator >( interpolator ) ); break; } @@ -191,7 +190,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< QuaternionInterpolator >( interpolator ) ); + AnyCast< QuaternionInterpolator >( interpolator ) ); break; } @@ -202,7 +201,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< MatrixInterpolator >( interpolator ) ); + AnyCast< MatrixInterpolator >( interpolator ) ); break; } @@ -213,7 +212,7 @@ Constraint::Constraint( Property::Index targetIndex, mActiveConstraintTemplate = ActiveConstraint::New( targetIndex, sources, funcPtr, - boost::any_cast< Matrix3Interpolator >( interpolator ) ); + AnyCast< Matrix3Interpolator >( interpolator ) ); break; } diff --git a/dali/internal/event/animation/constraint-impl.h b/dali/internal/event/animation/constraint-impl.h index 418f5f5..7c0b9fa 100644 --- a/dali/internal/event/animation/constraint-impl.h +++ b/dali/internal/event/animation/constraint-impl.h @@ -41,7 +41,7 @@ class Constraint : public BaseObject { public: - typedef boost::any AnyFunction; + typedef Any AnyFunction; /** * Construct a new constraint which targets a property. diff --git a/dali/public-api/object/property-value.cpp b/dali/public-api/object/property-value.cpp index a08b943..5ce4351 100644 --- a/dali/public-api/object/property-value.cpp +++ b/dali/public-api/object/property-value.cpp @@ -17,10 +17,8 @@ // CLASS HEADER #include -// EXTERNAL INCLUDES -#include - // INTERNAL INCLUDES +#include #include #include #include @@ -135,7 +133,7 @@ struct Property::Value::Impl Type mType; - typedef boost::any AnyValue; + typedef Any AnyValue; AnyValue mValue; }; @@ -550,70 +548,70 @@ Property::Type Property::Value::GetType() const void Property::Value::Get(bool& boolValue) const { - DALI_ASSERT_ALWAYS( Property::BOOLEAN == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::BOOLEAN == GetType() && "Property type invalid" ); // AnyCast does asserted type checking - boolValue = boost::any_cast(mImpl->mValue); + boolValue = AnyCast(mImpl->mValue); } void Property::Value::Get(float& floatValue) const { - DALI_ASSERT_ALWAYS( Property::FLOAT == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::FLOAT == GetType() && "Property type invalid" ); - floatValue = boost::any_cast(mImpl->mValue); + floatValue = AnyCast(mImpl->mValue); } void Property::Value::Get(int& integerValue) const { - DALI_ASSERT_ALWAYS( Property::INTEGER == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::INTEGER == GetType() && "Property type invalid" ); - integerValue = boost::any_cast(mImpl->mValue); + integerValue = AnyCast(mImpl->mValue); } void Property::Value::Get(unsigned int& unsignedIntegerValue) const { - DALI_ASSERT_ALWAYS( Property::UNSIGNED_INTEGER == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::UNSIGNED_INTEGER == GetType() && "Property type invalid" ); - unsignedIntegerValue = boost::any_cast(mImpl->mValue); + unsignedIntegerValue = AnyCast(mImpl->mValue); } void Property::Value::Get(Vector2& vectorValue) const { - DALI_ASSERT_ALWAYS( Property::VECTOR2 == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::VECTOR2 == GetType() && "Property type invalid" ); - vectorValue = boost::any_cast(mImpl->mValue); + vectorValue = AnyCast(mImpl->mValue); } void Property::Value::Get(Vector3& vectorValue) const { - DALI_ASSERT_ALWAYS( Property::VECTOR3 == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::VECTOR3 == GetType() && "Property type invalid" ); - vectorValue = boost::any_cast(mImpl->mValue); + vectorValue = AnyCast(mImpl->mValue); } void Property::Value::Get(Vector4& vectorValue) const { - DALI_ASSERT_ALWAYS( Property::VECTOR4 == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::VECTOR4 == GetType() && "Property type invalid" ); - vectorValue = boost::any_cast(mImpl->mValue); + vectorValue = AnyCast(mImpl->mValue); } void Property::Value::Get(Matrix3& matrixValue) const { - DALI_ASSERT_ALWAYS( Property::MATRIX3 == GetType() && "Property type invalid" ); - matrixValue = boost::any_cast(mImpl->mValue); + DALI_ASSERT_DEBUG( Property::MATRIX3 == GetType() && "Property type invalid" ); + matrixValue = AnyCast(mImpl->mValue); } void Property::Value::Get(Matrix& matrixValue) const { - DALI_ASSERT_ALWAYS( Property::MATRIX == GetType() && "Property type invalid" ); - matrixValue = boost::any_cast(mImpl->mValue); + DALI_ASSERT_DEBUG( Property::MATRIX == GetType() && "Property type invalid" ); + matrixValue = AnyCast(mImpl->mValue); } void Property::Value::Get(Rect& rect) const { - DALI_ASSERT_ALWAYS( Property::RECTANGLE == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::RECTANGLE == GetType() && "Property type invalid" ); - rect = boost::any_cast >(mImpl->mValue); + rect = AnyCast >(mImpl->mValue); } void Property::Value::Get(AngleAxis& angleAxisValue) const @@ -621,12 +619,12 @@ void Property::Value::Get(AngleAxis& angleAxisValue) const DALI_ASSERT_ALWAYS( Property::ROTATION == GetType() && "Property type invalid" ); // Rotations have two representations - DALI_ASSERT_DEBUG( typeid(Quaternion) == mImpl->mValue.type() || - typeid(AngleAxis) == mImpl->mValue.type() ); + DALI_ASSERT_DEBUG( typeid(Quaternion) == mImpl->mValue.GetType() || + typeid(AngleAxis) == mImpl->mValue.GetType() ); - if ( typeid(Quaternion) == mImpl->mValue.type() ) + if ( typeid(Quaternion) == mImpl->mValue.GetType() ) { - Quaternion quaternion = boost::any_cast(mImpl->mValue); + Quaternion quaternion = AnyCast(mImpl->mValue); Radian angleRadians(0.0f); quaternion.ToAxisAngle( angleAxisValue.axis, angleRadians ); @@ -634,25 +632,25 @@ void Property::Value::Get(AngleAxis& angleAxisValue) const } else { - angleAxisValue = boost::any_cast(mImpl->mValue); + angleAxisValue = AnyCast(mImpl->mValue); } } void Property::Value::Get(Quaternion& quaternionValue) const { - DALI_ASSERT_ALWAYS( Property::ROTATION == GetType() && "Property type invalid" ); + DALI_ASSERT_DEBUG( Property::ROTATION == GetType() && "Property type invalid" ); // Rotations have two representations - DALI_ASSERT_DEBUG( typeid(Quaternion) == mImpl->mValue.type() || - typeid(AngleAxis) == mImpl->mValue.type() ); + DALI_ASSERT_DEBUG( typeid(Quaternion) == mImpl->mValue.GetType() || + typeid(AngleAxis) == mImpl->mValue.GetType() ); - if ( typeid(Quaternion) == mImpl->mValue.type() ) + if ( typeid(Quaternion) == mImpl->mValue.GetType() ) { - quaternionValue = boost::any_cast(mImpl->mValue); + quaternionValue = AnyCast(mImpl->mValue); } else { - AngleAxis angleAxis = boost::any_cast(mImpl->mValue); + AngleAxis angleAxis = AnyCast(mImpl->mValue); quaternionValue = Quaternion( Radian(angleAxis.angle), angleAxis.axis ); } @@ -660,30 +658,30 @@ void Property::Value::Get(Quaternion& quaternionValue) const void Property::Value::Get(std::string &out) const { - DALI_ASSERT_ALWAYS(Property::STRING == GetType() && "Property type invalid"); + DALI_ASSERT_DEBUG(Property::STRING == GetType() && "Property type invalid"); - out = boost::any_cast(mImpl->mValue); + out = AnyCast(mImpl->mValue); } void Property::Value::Get(Property::Array &out) const { - DALI_ASSERT_ALWAYS(Property::ARRAY == GetType() && "Property type invalid"); + DALI_ASSERT_DEBUG(Property::ARRAY == GetType() && "Property type invalid"); - out = boost::any_cast(mImpl->mValue); + out = AnyCast(mImpl->mValue); } void Property::Value::Get(Property::Map &out) const { - DALI_ASSERT_ALWAYS(Property::MAP == GetType() && "Property type invalid"); + DALI_ASSERT_DEBUG(Property::MAP == GetType() && "Property type invalid"); - out = boost::any_cast(mImpl->mValue); + out = AnyCast(mImpl->mValue); } Property::Value& Property::Value::GetValue(const std::string& key) const { - DALI_ASSERT_ALWAYS(Property::MAP == GetType() && "Property type invalid"); + DALI_ASSERT_DEBUG(Property::MAP == GetType() && "Property type invalid"); - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); DALI_ASSERT_DEBUG(container); @@ -712,7 +710,7 @@ bool Property::Value::HasKey(const std::string& key) const if( Property::MAP == GetType() ) { - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); DALI_ASSERT_DEBUG(container && "Property::Map has no container?"); @@ -739,7 +737,7 @@ const std::string& Property::Value::GetKey(const int index) const case Property::MAP: { int i = 0; - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); DALI_ASSERT_DEBUG(container && "Property::Map has no container?"); if(container) { @@ -785,9 +783,9 @@ const std::string& Property::Value::GetKey(const int index) const void Property::Value::SetValue(const std::string& key, const Property::Value &value) { - DALI_ASSERT_ALWAYS(Property::MAP == GetType() && "Property type invalid"); + DALI_ASSERT_DEBUG(Property::MAP == GetType() && "Property type invalid"); - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); if(container) { @@ -813,7 +811,7 @@ Property::Value& Property::Value::GetItem(const int index) const case Property::MAP: { int i = 0; - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); DALI_ASSERT_DEBUG(container && "Property::Map has no container?"); if(container) @@ -835,7 +833,7 @@ Property::Value& Property::Value::GetItem(const int index) const case Property::ARRAY: { int i = 0; - Property::Array *container = boost::any_cast(&(mImpl->mValue)); + Property::Array *container = AnyCast(&(mImpl->mValue)); DALI_ASSERT_DEBUG(container && "Property::Map has no container?"); if(container) @@ -889,7 +887,7 @@ void Property::Value::SetItem(const int index, const Property::Value &value) { case Property::MAP: { - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); if( container && index < static_cast(container->size()) ) { int i = 0; @@ -907,7 +905,7 @@ void Property::Value::SetItem(const int index, const Property::Value &value) case Property::ARRAY: { - Property::Array *container = boost::any_cast(&(mImpl->mValue)); + Property::Array *container = AnyCast(&(mImpl->mValue)); if( container && index < static_cast(container->size()) ) { (*container)[index] = value; @@ -938,9 +936,9 @@ void Property::Value::SetItem(const int index, const Property::Value &value) int Property::Value::AppendItem(const Property::Value &value) { - DALI_ASSERT_ALWAYS(Property::ARRAY == GetType() && "Property type invalid"); + DALI_ASSERT_DEBUG(Property::ARRAY == GetType() && "Property type invalid"); - Property::Array *container = boost::any_cast(&(mImpl->mValue)); + Property::Array *container = AnyCast(&(mImpl->mValue)); if(container) { @@ -962,7 +960,7 @@ int Property::Value::GetSize() const { case Property::MAP: { - Property::Map *container = boost::any_cast(&(mImpl->mValue)); + Property::Map *container = AnyCast(&(mImpl->mValue)); if(container) { ret = container->size(); @@ -972,7 +970,7 @@ int Property::Value::GetSize() const case Property::ARRAY: { - Property::Array *container = boost::any_cast(&(mImpl->mValue)); + Property::Array *container = AnyCast(&(mImpl->mValue)); if(container) { ret = container->size(); -- 2.7.4