/*
- * Copyright (c) 2015 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.
#include <dali/public-api/object/handle.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/internal/event/animation/constraint-impl.h>
+#include <dali/internal/event/common/object-impl.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-conditions.h>
#include <dali/public-api/object/property-notification.h>
-#include <dali/internal/event/animation/constraint-impl.h>
-#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/object/custom-object-internal.h>
-#include <dali/integration-api/debug.h>
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(dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()));
+}
+
+bool Handle::Supports(Capability capability) const
+{
+ return GetImplementation(*this).Supports(capability);
+}
+
+uint32_t Handle::GetPropertyCount() const
{
- return Handle( Internal::CustomObject::New() );
+ return GetImplementation(*this).GetPropertyCount();
}
-Handle::~Handle()
+std::string Handle::GetPropertyName(Property::Index index) const
{
+ return std::string(GetImplementation(*this).GetPropertyName(index));
}
-Handle::Handle( const Handle& handle )
-: BaseHandle( handle )
+Property::Index Handle::GetPropertyIndex(Property::Key key) const
{
+ return GetImplementation(*this).GetPropertyIndex(key);
}
-Handle& Handle::operator=( const Handle& rhs )
+bool Handle::IsPropertyWritable(Property::Index index) const
{
- if( this != &rhs )
- {
- BaseHandle::operator=(rhs);
- }
+ return GetImplementation(*this).IsPropertyWritable(index);
+}
- return *this;
+bool Handle::IsPropertyAnimatable(Property::Index index) const
+{
+ return GetImplementation(*this).IsPropertyAnimatable(index);
}
-Handle Handle::DownCast( BaseHandle handle )
+bool Handle::IsPropertyAConstraintInput(Property::Index index) const
{
- return Handle( dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()) );
+ return GetImplementation(*this).IsPropertyAConstraintInput(index);
}
+Property::Type Handle::GetPropertyType(Property::Index index) const
+{
+ return GetImplementation(*this).GetPropertyType(index);
+}
-bool Handle::Supports( Capability capability ) const
+void Handle::SetProperty(Property::Index index, Property::Value propertyValue)
{
- return GetImplementation(*this).Supports( capability );
+ GetImplementation(*this).SetProperty(index, std::move(propertyValue));
}
-unsigned int Handle::GetPropertyCount() const
+void Handle::ReserveCustomProperties(int propertyCount)
{
- return GetImplementation(*this).GetPropertyCount();
+ GetImplementation(*this).ReserveCustomProperties(propertyCount);
}
-std::string Handle::GetPropertyName( Property::Index index ) const
+Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue)
{
- return GetImplementation(*this).GetPropertyName( index );
+ return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue));
}
-Property::Index Handle::GetPropertyIndex( const std::string& name ) const
+Property::Index Handle::RegisterProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
{
- return GetImplementation(*this).GetPropertyIndex( name );
+ return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), true);
}
-bool Handle::IsPropertyWritable( Property::Index index ) const
+Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode)
{
- return GetImplementation(*this).IsPropertyWritable( index );
+ return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue), accessMode);
}
-bool Handle::IsPropertyAnimatable( Property::Index index ) const
+Property::Index Handle::RegisterUniqueProperty(std::string_view name, Property::Value propertyValue)
{
- return GetImplementation(*this).IsPropertyAnimatable( index );
+ return GetImplementation(*this).RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), false);
}
-bool Handle::IsPropertyAConstraintInput( Property::Index index ) const
+Property::Index Handle::RegisterUniqueProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
{
- return GetImplementation(*this).IsPropertyAConstraintInput( index );
+ return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue), false);
}
-Property::Type Handle::GetPropertyType( Property::Index index ) const
+Property::Value Handle::GetProperty(Property::Index index) const
{
- return GetImplementation(*this).GetPropertyType( index );
+ return GetImplementation(*this).GetProperty(index);
}
-void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue )
+Property::Value Handle::GetCurrentProperty(Property::Index index) const
{
- GetImplementation(*this).SetProperty( index, propertyValue );
+ return GetImplementation(*this).GetCurrentProperty(index);
}
-Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue )
+void Handle::SetProperties(const Property::Map& properties)
{
- return GetImplementation(*this).RegisterProperty( name, propertyValue );
+ GetImplementation(*this).SetProperties(properties);
}
-Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
+void Handle::GetProperties(Property::Map& properties)
{
- return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode );
+ GetImplementation(*this).GetProperties(properties);
}
-Property::Value Handle::GetProperty( Property::Index index ) const
+void Handle::GetPropertyIndices(Property::IndexContainer& indices) const
{
- return GetImplementation(*this).GetProperty( index );
+ GetImplementation(*this).GetPropertyIndices(indices);
}
-void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const
+bool Handle::DoesCustomPropertyExist(Property::Index index)
{
- GetImplementation(*this).GetPropertyIndices( indices );
+ return GetImplementation(*this).DoesCustomPropertyExist(index);
}
-Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
- const PropertyCondition& condition )
+Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
+ const PropertyCondition& condition)
{
- return GetImplementation(*this).AddPropertyNotification( index, -1, condition );
+ return GetImplementation(*this).AddPropertyNotification(index, -1, condition);
}
-Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
- int componentIndex,
- const PropertyCondition& condition )
+Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
+ int componentIndex,
+ const PropertyCondition& condition)
{
- return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition );
+ return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition);
}
-void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification )
+void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
{
- GetImplementation(*this).RemovePropertyNotification( propertyNotification );
+ GetImplementation(*this).RemovePropertyNotification(propertyNotification);
}
void Handle::RemovePropertyNotifications()
GetImplementation(*this).RemoveConstraints();
}
-void Handle::RemoveConstraints( unsigned int tag )
+void Handle::RemoveConstraints(uint32_t tag)
{
- GetImplementation(*this).RemoveConstraints( tag );
+ GetImplementation(*this).RemoveConstraints(tag);
}
-namespace WeightObject
+IndirectValue Handle::operator[](Property::Index index)
{
+ // Will assert on access if handle is empty
+ return IndirectValue(*this, index);
+}
+IndirectValue Handle::operator[](const std::string& name)
+{
+ // Will assert immediately when GetPropertyIndex is called if handle is empty
+ return IndirectValue(*this, GetPropertyIndex(name));
+}
+
+Handle::PropertySetSignalType& Handle::PropertySetSignal()
+{
+ 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;
}