X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fobject%2Fhandle.cpp;h=45f8fcd9adff1e9bb77fae7dfdbe720be871af89;hb=c4750afbf79f15bf71e2aa8ef54f84750463aae2;hp=01065b5a48df310748286d9619f1966dde364ce0;hpb=b3355d3e24c02b29c0ffd6d98c996cf45946d276;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/object/handle.cpp b/dali/public-api/object/handle.cpp index 01065b5..45f8fcd 100644 --- a/dali/public-api/object/handle.cpp +++ b/dali/public-api/object/handle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -19,139 +19,163 @@ #include // INTERNAL INCLUDES -#include +#include +#include +#include #include #include #include -#include -#include -#include -#include namespace Dali { - -Handle::Handle( Dali::Internal::Object* handle ) +Handle::Handle(Dali::Internal::Object* handle) : BaseHandle(handle) { } +Handle::Handle() = default; -Handle::Handle() +Handle Handle::New() { + return Handle(Internal::Object::New().Get()); } -Handle Handle::New() +Handle::~Handle() = default; + +Handle::Handle(const Handle& handle) = default; + +Handle& Handle::operator=(const Handle& rhs) = default; + +Handle::Handle(Handle&& rhs) noexcept = default; + +Handle& Handle::operator=(Handle&& rhs) noexcept = default; + +Handle Handle::DownCast(BaseHandle handle) { - return Handle( Internal::CustomObject::New() ); + return Handle(dynamic_cast(handle.GetObjectPtr())); } -Handle::~Handle() +bool Handle::Supports(Capability capability) const { + return GetImplementation(*this).Supports(capability); } -Handle::Handle( const Handle& handle ) -: BaseHandle( handle ) +uint32_t Handle::GetPropertyCount() const { + return GetImplementation(*this).GetPropertyCount(); } -Handle& Handle::operator=( const Handle& rhs ) +std::string Handle::GetPropertyName(Property::Index index) const { - if( this != &rhs ) - { - BaseHandle::operator=(rhs); - } + return std::string(GetImplementation(*this).GetPropertyName(index)); +} - return *this; +Property::Index Handle::GetPropertyIndex(Property::Key key) const +{ + return GetImplementation(*this).GetPropertyIndex(key); } -Handle Handle::DownCast( BaseHandle handle ) +bool Handle::IsPropertyWritable(Property::Index index) const { - return Handle( dynamic_cast(handle.GetObjectPtr()) ); + return GetImplementation(*this).IsPropertyWritable(index); } +bool Handle::IsPropertyAnimatable(Property::Index index) const +{ + return GetImplementation(*this).IsPropertyAnimatable(index); +} -bool Handle::Supports( Capability capability ) const +bool Handle::IsPropertyAConstraintInput(Property::Index index) const { - return GetImplementation(*this).Supports( capability ); + return GetImplementation(*this).IsPropertyAConstraintInput(index); } -unsigned int Handle::GetPropertyCount() const +Property::Type Handle::GetPropertyType(Property::Index index) const { - return GetImplementation(*this).GetPropertyCount(); + return GetImplementation(*this).GetPropertyType(index); } -std::string Handle::GetPropertyName( Property::Index index ) const +void Handle::SetProperty(Property::Index index, Property::Value propertyValue) { - return GetImplementation(*this).GetPropertyName( index ); + GetImplementation(*this).SetProperty(index, std::move(propertyValue)); } -Property::Index Handle::GetPropertyIndex( const std::string& name ) const +void Handle::ReserveCustomProperties(int propertyCount) { - return GetImplementation(*this).GetPropertyIndex( name ); + GetImplementation(*this).ReserveCustomProperties(propertyCount); } -bool Handle::IsPropertyWritable( Property::Index index ) const +Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue) { - return GetImplementation(*this).IsPropertyWritable( index ); + return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue)); } -bool Handle::IsPropertyAnimatable( Property::Index index ) const +Property::Index Handle::RegisterProperty(Property::Index key, std::string_view name, Property::Value propertyValue) { - return GetImplementation(*this).IsPropertyAnimatable( index ); + return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), true); } -bool Handle::IsPropertyAConstraintInput( Property::Index index ) const +Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode) { - return GetImplementation(*this).IsPropertyAConstraintInput( index ); + return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue), accessMode); } -Property::Type Handle::GetPropertyType( Property::Index index ) const +Property::Index Handle::RegisterUniqueProperty(std::string_view name, Property::Value propertyValue) { - return GetImplementation(*this).GetPropertyType( index ); + return GetImplementation(*this).RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), false); } -void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue ) +Property::Index Handle::RegisterUniqueProperty(Property::Index key, std::string_view name, Property::Value propertyValue) { - GetImplementation(*this).SetProperty( index, propertyValue ); + return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), false); } -Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue ) +Property::Value Handle::GetProperty(Property::Index index) const { - return GetImplementation(*this).RegisterProperty( name, propertyValue ); + return GetImplementation(*this).GetProperty(index); } -Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ) +Property::Value Handle::GetCurrentProperty(Property::Index index) const { - return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode ); + return GetImplementation(*this).GetCurrentProperty(index); } -Property::Value Handle::GetProperty( Property::Index index ) const +void Handle::SetProperties(const Property::Map& properties) { - return GetImplementation(*this).GetProperty( index ); + GetImplementation(*this).SetProperties(properties); } -void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const +void Handle::GetProperties(Property::Map& properties) { - GetImplementation(*this).GetPropertyIndices( indices ); + GetImplementation(*this).GetProperties(properties); } -Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index, - const PropertyCondition& condition ) +void Handle::GetPropertyIndices(Property::IndexContainer& indices) const { - return GetImplementation(*this).AddPropertyNotification( index, -1, condition ); + GetImplementation(*this).GetPropertyIndices(indices); } -Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index, - int componentIndex, - const PropertyCondition& condition ) +bool Handle::DoesCustomPropertyExist(Property::Index index) { - return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition ); + return GetImplementation(*this).DoesCustomPropertyExist(index); } -void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification ) +Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index, + const PropertyCondition& condition) { - GetImplementation(*this).RemovePropertyNotification( propertyNotification ); + return GetImplementation(*this).AddPropertyNotification(index, -1, condition); +} + +Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index, + int componentIndex, + const PropertyCondition& condition) +{ + return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition); +} + +void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification) +{ + GetImplementation(*this).RemovePropertyNotification(propertyNotification); } void Handle::RemovePropertyNotifications() @@ -159,41 +183,42 @@ void Handle::RemovePropertyNotifications() GetImplementation(*this).RemovePropertyNotifications(); } -ActiveConstraint Handle::ApplyConstraint( Constraint constraint ) +void Handle::RemoveConstraints() { - return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) ); + GetImplementation(*this).RemoveConstraints(); } -ActiveConstraint Handle::ApplyConstraint( Constraint constraint, Handle weightObject ) +void Handle::RemoveConstraints(uint32_t tag) { - return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject ); + GetImplementation(*this).RemoveConstraints(tag); } -void Handle::RemoveConstraint(ActiveConstraint activeConstraint) +IndirectValue Handle::operator[](Property::Index index) { - GetImplementation(*this).RemoveConstraint( activeConstraint ); + // Will assert on access if handle is empty + return IndirectValue(*this, index); } -void Handle::RemoveConstraints() +IndirectValue Handle::operator[](const std::string& name) { - GetImplementation(*this).RemoveConstraints(); + // Will assert immediately when GetPropertyIndex is called if handle is empty + return IndirectValue(*this, GetPropertyIndex(name)); } -void Handle::RemoveConstraints( unsigned int tag ) +Handle::PropertySetSignalType& Handle::PropertySetSignal() { - GetImplementation(*this).RemoveConstraints( tag ); + return GetImplementation(*this).PropertySetSignal(); } namespace WeightObject { - const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX; Handle New() { Handle handle = Handle::New(); - handle.RegisterProperty( "weight", 0.0f ); + handle.RegisterProperty("weight", 0.0f); return handle; }