/*
- * Copyright (c) 2018 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.
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/internal/event/common/type-registry-impl.h>
#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/common/type-registry-impl.h>
using std::find_if;
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/*
* Functor to find by given type for vector of pairs
*/
-template <typename S, typename T>
+template<typename S, typename T>
struct PairFinder
{
PairFinder(const S& find)
}
private:
-
const S& mFind;
};
/**
* Functor to find a matching property name
*/
-template <typename T>
+template<typename T>
struct PropertyNameFinder
{
- PropertyNameFinder( const std::string& find )
- : mFind( find )
+ PropertyNameFinder(ConstString find)
+ : mFind(find)
{
}
- bool operator()(const T &p) const
+ bool operator()(const T& p) const
{
return p.second.name == mFind;
}
private:
-
- const std::string& mFind;
+ ConstString mFind;
};
/**
* Functor to find a matching property component index
*/
-template <typename T>
+template<typename T>
struct PropertyComponentFinder
{
- PropertyComponentFinder( Property::Index basePropertyIndex, const int find )
- : mBasePropertyIndex( basePropertyIndex ),
- mFind( find )
+ PropertyComponentFinder(Property::Index basePropertyIndex, const int find)
+ : mBasePropertyIndex(basePropertyIndex),
+ mFind(find)
{
}
- bool operator()(const T &p) const
+ bool operator()(const T& p) const
{
- return ( p.second.basePropertyIndex == mBasePropertyIndex && p.second.componentIndex == mFind );
+ return (p.second.basePropertyIndex == mBasePropertyIndex && p.second.componentIndex == mFind);
}
private:
-
Property::Index mBasePropertyIndex;
- const int mFind;
+ const int mFind;
};
/**
* Helper function to find the right default property with given index and return the desired detail of it
*/
-template< typename Parameter, typename Member >
-inline bool GetDefaultPropertyField( const Dali::PropertyDetails* propertyTable, Property::Index count, Property::Index index, Member member, Parameter& parameter )
+template<typename Parameter, typename Member>
+inline bool GetDefaultPropertyField(const Dali::PropertyDetails* propertyTable, Property::Index count, Property::Index index, Member member, Parameter& parameter)
{
bool found = false;
// is index inside this table (bigger than first index but smaller than first + count)
- if( ( index >= propertyTable->enumIndex ) && ( index < ( propertyTable->enumIndex + count ) ) )
+ if((index >= propertyTable->enumIndex) && (index < (propertyTable->enumIndex + count)))
{
// return the match. we're assuming here that there is no gaps between the indices in a table
- parameter = propertyTable[ index - propertyTable->enumIndex ].*member;
- found = true;
+ parameter = propertyTable[index - propertyTable->enumIndex].*member;
+ found = true;
}
// should never really get here
return found;
// static pointer value to mark that a base class address has not been resolved
// 0x01 is not a valid pointer but used here to differentiate from nullptr
// unfortunately it cannot be constexpr as C++ does not allow them to be initialised with reinterpret_cast
-Internal::TypeInfo* const UNRESOLVED = reinterpret_cast<Internal::TypeInfo*>( 0x1 );
+Internal::TypeInfo* const UNRESOLVED = reinterpret_cast<Internal::TypeInfo*>(0x1);
/**
* Helper function to resolve and return the pointer to the base type info
* @param[in] baseTypeName string name of the base type
* @return true is base type exists
*/
-inline bool GetBaseType( Internal::TypeInfo*& baseType, TypeRegistry& typeRegistry, const std::string& baseTypeName )
+inline bool GetBaseType(Internal::TypeInfo*& baseType, TypeRegistry& typeRegistry, const std::string& baseTypeName)
{
// if greater than unresolved means we have a base type, null means no base
- bool baseExists = ( baseType > UNRESOLVED );
+ bool baseExists = (baseType > UNRESOLVED);
// base only needs to be resolved once
- if( UNRESOLVED == baseType )
+ if(UNRESOLVED == baseType)
{
- TypeRegistry::TypeInfoPointer base = typeRegistry.GetTypeInfo( baseTypeName );
- if( base )
+ TypeRegistry::TypeInfoPointer base = typeRegistry.GetTypeInfo(baseTypeName);
+ if(base)
{
- baseType = base.Get(); // dont pass ownership, just return raw pointer
+ baseType = base.Get(); // dont pass ownership, just return raw pointer
baseExists = true;
}
else
} // unnamed namespace
-TypeInfo::TypeInfo( const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator,
- const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount )
-: mTypeRegistry( *TypeRegistry::Get() ), mBaseType( UNRESOLVED ),
- mTypeName( name ), mBaseTypeName( baseTypeName ), mCreate( creator ), mDefaultProperties( defaultProperties ),
- mDefaultPropertyCount( defaultPropertyCount ), mCSharpType( false )
+TypeInfo::TypeInfo(const std::string& name, const std::string& baseTypeName, Dali::TypeInfo::CreateFunction creator, const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount)
+: mTypeRegistry(*TypeRegistry::Get()),
+ mBaseType(UNRESOLVED),
+ mTypeName(name),
+ mBaseTypeName(baseTypeName),
+ mCreate(creator),
+ mDefaultProperties(defaultProperties),
+ mDefaultPropertyCount(defaultPropertyCount),
+ mCSharpType(false)
{
DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name");
DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
}
-TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dali::CSharpTypeInfo::CreateFunction creator)
-: mTypeRegistry( *TypeRegistry::Get() ), mBaseType( UNRESOLVED ),
- mTypeName( name ), mBaseTypeName( baseTypeName ), mCSharpCreate( creator ), mCSharpType( true )
+TypeInfo::TypeInfo(const std::string& name, const std::string& baseTypeName, Dali::CSharpTypeInfo::CreateFunction creator)
+: mTypeRegistry(*TypeRegistry::Get()),
+ mBaseType(UNRESOLVED),
+ mTypeName(name),
+ mBaseTypeName(baseTypeName),
+ mCSharpCreate(creator),
+ mCSharpType(true)
{
DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name");
DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
}
-TypeInfo::~TypeInfo()
-{
-}
+TypeInfo::~TypeInfo() = default;
BaseHandle TypeInfo::CreateInstance() const
{
if(mCreate)
{
- if ( mCSharpType )
+ if(mCSharpType)
{
// CSharp currently only registers one create function for all custom controls
// it uses the type name to decide which one to create
- ret = *mCSharpCreate( mTypeName.c_str() );
+ ret = *mCSharpCreate(mTypeName.c_str());
}
else
{
ret = mCreate();
}
- if ( ret )
+ if(ret)
{
BaseObject& handle = ret.GetBaseObject();
- Object *object = dynamic_cast<Internal::Object*>(&handle);
+ Object* object = dynamic_cast<Internal::Object*>(&handle);
- if ( object )
+ if(object)
{
- object->SetTypeInfo( this );
+ object->SetTypeInfo(this);
}
}
}
return ret;
}
-bool TypeInfo::DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties)
+bool TypeInfo::DoActionTo(BaseObject* object, const std::string& actionName, const Property::Map& properties)
{
bool done = false;
- ActionContainer::iterator iter = find_if(mActions.begin(), mActions.end(), PairFinder<std::string, ActionPair>(actionName));
-
- if( iter != mActions.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ auto iter = mActions.Get(ConstString(actionName));
+#else
+ ActionContainer::iterator iter = find_if(mActions.begin(), mActions.end(), PairFinder<std::string, ActionPair>(actionName));
+#endif
+ if(iter != mActions.end())
{
done = (iter->second)(object, actionName, properties);
}
- if( !done )
+ if(!done)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- done = mBaseType->DoActionTo( object, actionName, properties );
+ done = mBaseType->DoActionTo(object, actionName, properties);
}
}
return done;
}
-bool TypeInfo::ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
+bool TypeInfo::ConnectSignal(BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( false );
-
- ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
- PairFinder<std::string, ConnectionPair>(signalName) );
+ bool connected(false);
- if( iter != mSignalConnectors.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ auto iter = mSignalConnectors.Get(ConstString(signalName));
+#else
+ ConnectorContainer::iterator iter = find_if(mSignalConnectors.begin(), mSignalConnectors.end(), PairFinder<std::string, ConnectionPair>(signalName));
+#endif
+ if(iter != mSignalConnectors.end())
{
- connected = (iter->second)( object, connectionTracker, signalName, functor );
+ connected = (iter->second)(object, connectionTracker, signalName, functor);
}
- if( !connected )
+ if(!connected)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- connected = mBaseType->ConnectSignal( object, connectionTracker, signalName, functor );
+ connected = mBaseType->ConnectSignal(object, connectionTracker, signalName, functor);
}
}
return mCreate;
}
-size_t TypeInfo::GetActionCount() const
+uint32_t TypeInfo::GetActionCount() const
{
- size_t count = mActions.size();
+ uint32_t count = static_cast<uint32_t>(mActions.size());
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
count += mBaseType->GetActionCount();
return count;
}
-std::string TypeInfo::GetActionName(size_t index) const
+std::string TypeInfo::GetActionName(uint32_t index) const
{
- std::string name;
- const size_t count = mActions.size();
+ std::string name;
+ const uint32_t count = static_cast<uint32_t>(mActions.size());
- if( index < count )
+ if(index < count)
{
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ name = std::string(mActions.GetKeyByIndex(index).GetStringView());
+#else
name = mActions[index].first;
+#endif
}
else
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetActionName( index - count );
+ return mBaseType->GetActionName(index - count);
}
}
return name;
}
-size_t TypeInfo::GetSignalCount() const
+uint32_t TypeInfo::GetSignalCount() const
{
- size_t count = mSignalConnectors.size();
+ uint32_t count = static_cast<uint32_t>(mSignalConnectors.size());
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
count += mBaseType->GetSignalCount();
return count;
}
-std::string TypeInfo::GetSignalName(size_t index) const
+std::string TypeInfo::GetSignalName(uint32_t index) const
{
- std::string name;
- const size_t count = mSignalConnectors.size();
+ std::string name;
+ const uint32_t count = static_cast<uint32_t>(mSignalConnectors.size());
- if( index < count )
+ if(index < count)
{
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ name = std::string(mSignalConnectors.GetKeyByIndex(index).GetStringView());
+#else
name = mSignalConnectors[index].first;
+#endif
}
else
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetSignalName( index - count );
+ return mBaseType->GetSignalName(index - count);
}
}
return name;
}
-void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const
+void TypeInfo::GetPropertyIndices(Property::IndexContainer& indices) const
{
// Default Properties
- if( mDefaultProperties )
+ if(mDefaultProperties)
{
- indices.Reserve( indices.Size() + mDefaultPropertyCount );
- for( Property::Index index = 0; index < mDefaultPropertyCount; ++index )
+ indices.Reserve(indices.Size() + mDefaultPropertyCount);
+ for(Property::Index index = 0; index < mDefaultPropertyCount; ++index)
{
- indices.PushBack( mDefaultProperties[ index ].enumIndex );
+ indices.PushBack(mDefaultProperties[index].enumIndex);
}
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- mBaseType->GetPropertyIndices( indices );
+ mBaseType->GetPropertyIndices(indices);
}
- AppendProperties( indices, mRegisteredProperties );
+ AppendProperties(indices, mRegisteredProperties);
}
-void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
+void TypeInfo::GetChildPropertyIndices(Property::IndexContainer& indices) const
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- mBaseType->GetChildPropertyIndices( indices );
+ mBaseType->GetChildPropertyIndices(indices);
}
- AppendProperties( indices, mRegisteredChildProperties );
+ AppendProperties(indices, mRegisteredChildProperties);
}
/**
* Append the indices in RegisteredProperties to the given index container.
*/
-void TypeInfo::AppendProperties( Dali::Property::IndexContainer& indices,
- const TypeInfo::RegisteredPropertyContainer& registeredProperties ) const
+void TypeInfo::AppendProperties(Dali::Property::IndexContainer& indices,
+ const TypeInfo::RegisteredPropertyContainer& registeredProperties) const
{
- if ( ! registeredProperties.empty() )
+ if(!registeredProperties.empty())
{
- indices.Reserve( indices.Size() + registeredProperties.size() );
+ indices.Reserve(indices.Size() + registeredProperties.size());
- for( auto&& elem : registeredProperties )
+ for(auto&& elem : registeredProperties)
{
- indices.PushBack( elem.first );
+ indices.PushBack(elem.first);
}
}
}
-const std::string& TypeInfo::GetRegisteredPropertyName( Property::Index index ) const
+std::string_view TypeInfo::GetRegisteredPropertyName(Property::Index index) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetRegisteredPropertyName( index );
+ return mBaseType->GetRegisteredPropertyName(index);
}
static std::string empty;
return empty;
}
-std::string TypeInfo::GetPropertyName( Property::Index index ) const
+std::string_view TypeInfo::GetPropertyName(Property::Index index) const
{
- std::string propertyName;
+ std::string_view propertyName;
// default or custom
- if ( mDefaultProperties && ( index < DEFAULT_PROPERTY_MAX_COUNT ) )
+ if(mDefaultProperties && (index < DEFAULT_PROPERTY_MAX_COUNT))
{
- const char* name = nullptr;
- if( GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::name, name ) )
+ std::string_view name;
+ if(GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::name, name))
{
propertyName = name;
}
}
else
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
}
// if not our property, go to parent
- if( propertyName.empty() )
+ if(propertyName.empty())
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetPropertyName( index );
+ return mBaseType->GetPropertyName(index);
}
}
return propertyName;
}
-void TypeInfo::AddActionFunction( const std::string &actionName, Dali::TypeInfo::ActionFunction function )
+void TypeInfo::AddActionFunction(std::string actionName, Dali::TypeInfo::ActionFunction function)
{
- if( NULL == function)
+ if(nullptr == function)
{
DALI_LOG_WARNING("Action function is empty\n");
}
else
{
- ActionContainer::iterator iter = std::find_if(mActions.begin(), mActions.end(),
- PairFinder<std::string, ActionPair>(actionName));
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mActions.Register(ConstString(actionName), function))
+ {
+ DALI_LOG_WARNING("Action already exists in TypeRegistry Type\n", actionName.c_str());
+ }
+#else
+ ActionContainer::iterator iter = std::find_if(mActions.begin(), mActions.end(), PairFinder<std::string, ActionPair>(actionName));
- if( iter == mActions.end() )
+ if(iter == mActions.end())
{
- mActions.push_back( ActionPair( actionName, function ) );
+ mActions.push_back(ActionPair(std::move(actionName), function));
}
else
{
DALI_LOG_WARNING("Action already exists in TypeRegistry Type\n", actionName.c_str());
}
+#endif
}
}
-void TypeInfo::AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunction function )
+void TypeInfo::AddConnectorFunction(std::string signalName, Dali::TypeInfo::SignalConnectorFunction function)
{
- if( NULL == function)
+ if(nullptr == function)
{
DALI_LOG_WARNING("Connector function is empty\n");
}
else
{
- ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
- PairFinder<std::string, ConnectionPair>(signalName) );
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mSignalConnectors.Register(ConstString(signalName), function))
+ {
+ DALI_LOG_WARNING("Signal name already exists in TypeRegistry Type for signal connector function\n", signalName.c_str());
+ }
+#else
+ ConnectorContainer::iterator iter = find_if(mSignalConnectors.begin(), mSignalConnectors.end(), PairFinder<std::string, ConnectionPair>(signalName));
- if( iter == mSignalConnectors.end() )
+ if(iter == mSignalConnectors.end())
{
- mSignalConnectors.push_back( ConnectionPair( signalName, function ) );
+ mSignalConnectors.push_back(ConnectionPair(std::move(signalName), function));
}
else
{
DALI_LOG_WARNING("Signal name already exists in TypeRegistry Type for signal connector function\n", signalName.c_str());
}
+#endif
}
}
-void TypeInfo::AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc )
+void TypeInfo::AddProperty(std::string name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc)
{
// The setter can be empty as a property can be read-only.
- if ( NULL == getFunc )
+ if(nullptr == getFunc)
{
- DALI_ASSERT_ALWAYS( ! "GetProperty Function is empty" );
+ DALI_ASSERT_ALWAYS(!"GetProperty Function is empty");
}
else
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
-
- if ( iter == mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)))
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
+ }
+#else
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter == mRegisteredProperties.end())
+ {
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
+#endif
}
}
-void TypeInfo::AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc)
+void TypeInfo::AddProperty(std::string name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc)
{
-
// The setter can be empty as a property can be read-only.
- if ( NULL == getFunc )
+ if(nullptr == getFunc)
{
- DALI_ASSERT_ALWAYS( ! "GetProperty Function is empty" );
+ DALI_ASSERT_ALWAYS(!"GetProperty Function is empty");
}
else
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
-
- if ( iter == mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)))
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
+ }
+#else
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter == mRegisteredProperties.end())
+ {
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
+#endif
}
-
}
-
-void TypeInfo::AddAnimatableProperty( const std::string& name, Property::Index index, Property::Type type )
+void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Type type)
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
-
- if ( iter == mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)))
+ {
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
+ }
+#else
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter == mRegisteredProperties.end())
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
+#endif
}
-void TypeInfo::AddAnimatableProperty( const std::string& name, Property::Index index, const Property::Value& defaultValue )
+void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Value defaultValue)
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
-
- if ( iter == mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(defaultValue.GetType(), ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)))
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( defaultValue.GetType(), name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
- mPropertyDefaultValues.push_back( PropertyDefaultValuePair( index, defaultValue ) );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ mPropertyDefaultValues.Register(static_cast<std::uint32_t>(index), std::move(defaultValue));
}
+#else
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter == mRegisteredProperties.end())
+ {
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(defaultValue.GetType(), ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
+ mPropertyDefaultValues.push_back(PropertyDefaultValuePair(index, std::move(defaultValue)));
+ }
+ else
+ {
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
+ }
+#endif
}
-void TypeInfo::AddAnimatablePropertyComponent( const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex )
+void TypeInfo::AddAnimatablePropertyComponent(std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex)
{
- Property::Type type = GetPropertyType( baseIndex );
- DALI_ASSERT_ALWAYS( ( type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4 ) && "Base property does not support component" );
+ Property::Type type = GetPropertyType(baseIndex);
+ DALI_ASSERT_ALWAYS((type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4) && "Base property does not support component");
bool success = false;
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(mRegisteredProperties.Get(static_cast<std::uint32_t>(index)) == mRegisteredProperties.end())
+ {
+ const auto& iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyComponentFinder<RegisteredPropertyPair>(baseIndex, componentIndex));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
+ {
+ mRegisteredProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, ConstString(name), baseIndex, componentIndex));
+ success = true;
+ }
+ }
+#else
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter == mRegisteredProperties.end())
{
- iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyComponentFinder< RegisteredPropertyPair >( baseIndex, componentIndex ) );
+ iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyComponentFinder<RegisteredPropertyPair>(baseIndex, componentIndex));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, name, baseIndex, componentIndex ) ) );
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), baseIndex, componentIndex)));
success = true;
}
}
+#endif
- DALI_ASSERT_ALWAYS( success && "Property component already registered" );
+ DALI_ASSERT_ALWAYS(success && "Property component already registered");
}
-void TypeInfo::AddChildProperty( const std::string& name, Property::Index index, Property::Type type )
+void TypeInfo::AddChildProperty(std::string name, Property::Index index, Property::Type type)
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
-
- if ( iter == mRegisteredChildProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ if(!mRegisteredChildProperties.Register(static_cast<std::uint32_t>(index), RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)))
+#else
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter == mRegisteredChildProperties.end())
{
- mRegisteredChildProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+ mRegisteredChildProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
+#endif
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
}
uint32_t TypeInfo::GetPropertyCount() const
{
- uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>( mRegisteredProperties.size() );
+ uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>(mRegisteredProperties.size());
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
count += mBaseType->GetPropertyCount();
return count;
}
-Property::Index TypeInfo::GetPropertyIndex( const std::string& name ) const
+Property::Index TypeInfo::GetPropertyIndex(ConstString name) const
{
Property::Index index = Property::INVALID_INDEX;
- bool found = false;
+ bool found = false;
// check default properties
- if( mDefaultProperties )
+ if(mDefaultProperties)
{
- for( Property::Index tableIndex = 0; tableIndex < mDefaultPropertyCount; ++tableIndex )
+ auto stringView = name.GetStringView();
+ for(Property::Index tableIndex = 0; tableIndex < mDefaultPropertyCount; ++tableIndex)
{
- if( 0 == name.compare( mDefaultProperties[ tableIndex ].name ) )
+ if(mDefaultProperties[tableIndex].name == stringView)
{
- index = mDefaultProperties[ tableIndex ].enumIndex;
+ index = mDefaultProperties[tableIndex].enumIndex;
found = true;
break;
}
}
}
- if( !found )
+ if(!found)
{
// Slow but should not be done that often
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
- if ( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(name));
+ if(iter != mRegisteredProperties.end())
{
index = iter->first;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- index = mBaseType->GetPropertyIndex( name );
+ index = mBaseType->GetPropertyIndex(name);
}
}
return index;
}
-Property::Index TypeInfo::GetBasePropertyIndex( Property::Index index ) const
+Property::Index TypeInfo::GetBasePropertyIndex(Property::Index index) const
{
Property::Index basePropertyIndex = Property::INVALID_INDEX;
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
-
- if ( iter != mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
{
basePropertyIndex = iter->second.basePropertyIndex;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- basePropertyIndex = mBaseType->GetBasePropertyIndex( index );
+ basePropertyIndex = mBaseType->GetBasePropertyIndex(index);
}
return basePropertyIndex;
}
-int TypeInfo::GetComponentIndex( Property::Index index ) const
+int32_t TypeInfo::GetComponentIndex(Property::Index index) const
{
int componentIndex = Property::INVALID_COMPONENT_INDEX;
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
-
- if ( iter != mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
{
componentIndex = iter->second.componentIndex;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- componentIndex = mBaseType->GetComponentIndex( index );
+ componentIndex = mBaseType->GetComponentIndex(index);
}
return componentIndex;
}
-Property::Index TypeInfo::GetChildPropertyIndex( const std::string& name ) const
+Property::Index TypeInfo::GetChildPropertyIndex(ConstString name) const
{
Property::Index index = Property::INVALID_INDEX;
// Slow but should not be done that often
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(name));
- if ( iter != mRegisteredChildProperties.end() )
+ if(iter != mRegisteredChildProperties.end())
{
index = iter->first;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- index = mBaseType->GetChildPropertyIndex( name );
+ index = mBaseType->GetChildPropertyIndex(name);
}
return index;
}
-const std::string& TypeInfo::GetChildPropertyName( Property::Index index ) const
+std::string_view TypeInfo::GetChildPropertyName(Property::Index index) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
-
- if ( iter != mRegisteredChildProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredChildProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredChildProperties.end())
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetChildPropertyName( index );
+ return mBaseType->GetChildPropertyName(index);
}
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
- static std::string empty;
- return empty;
+ return {};
}
-Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const
+Property::Type TypeInfo::GetChildPropertyType(Property::Index index) const
{
- Property::Type type( Property::NONE );
+ Property::Type type(Property::NONE);
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
-
- if ( iter != mRegisteredChildProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredChildProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredChildProperties.end())
{
type = iter->second.type;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- type = mBaseType->GetChildPropertyType( index );
+ type = mBaseType->GetChildPropertyType(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
return type;
}
-bool TypeInfo::IsPropertyWritable( Property::Index index ) const
+bool TypeInfo::IsPropertyWritable(Property::Index index) const
{
bool writable = false;
- bool found = false;
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::writable, writable );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::writable, writable);
}
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
writable = true; // animatable property is writable
- found = true;
+ found = true;
}
else
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
{
writable = iter->second.setFunc ? true : false;
- found = true;
+ found = true;
}
}
// if not found, continue to base
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- writable = mBaseType->IsPropertyWritable( index );
+ writable = mBaseType->IsPropertyWritable(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return writable;
}
-bool TypeInfo::IsPropertyAnimatable( Property::Index index ) const
+bool TypeInfo::IsPropertyAnimatable(Property::Index index) const
{
bool animatable = false;
- bool found = false;
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::animatable, animatable );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::animatable, animatable);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
// Type Registry event-thread only properties are not animatable.
animatable = false;
- found = true;
+ found = true;
}
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
animatable = true;
- found = true;
+ found = true;
}
// if not found, continue to base
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- animatable = mBaseType->IsPropertyAnimatable( index );
+ animatable = mBaseType->IsPropertyAnimatable(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return animatable;
}
-bool TypeInfo::IsPropertyAConstraintInput( Property::Index index ) const
+bool TypeInfo::IsPropertyAConstraintInput(Property::Index index) const
{
bool constraintInput = false;
- bool found = false;
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::constraintInput, constraintInput );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::constraintInput, constraintInput);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
// Type Registry event-thread only properties cannot be used as constraint input
constraintInput = false;
- found = true;
+ found = true;
}
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
constraintInput = true;
- found = true;
+ found = true;
}
// if not found, continue to base
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- constraintInput = mBaseType->IsPropertyAConstraintInput( index );
+ constraintInput = mBaseType->IsPropertyAConstraintInput(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return constraintInput;
}
-
-Property::Type TypeInfo::GetPropertyType( Property::Index index ) const
+Property::Type TypeInfo::GetPropertyType(Property::Index index) const
{
- Property::Type type( Property::NONE );
- bool found = false;
+ Property::Type type(Property::NONE);
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::type, type );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::type, type);
}
else
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
-
- if ( iter != mRegisteredProperties.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
{
- if( iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX )
+ if(iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX)
{
- type = iter->second.type;
+ type = iter->second.type;
found = true;
}
else
{
// If component index is set, then we should return FLOAT
- type = Property::FLOAT;
+ type = Property::FLOAT;
found = true;
}
}
}
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- type = mBaseType->GetPropertyType( index );
+ type = mBaseType->GetPropertyType(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return type;
}
-Property::Value TypeInfo::GetPropertyDefaultValue( Property::Index index ) const
+Property::Value TypeInfo::GetPropertyDefaultValue(Property::Index index) const
{
- PropertyDefaultValueContainer::const_iterator iter = find_if( mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(),
- PairFinder< Property::Index, PropertyDefaultValuePair >( index ) );
- if( iter != mPropertyDefaultValues.end() )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mPropertyDefaultValues.Get(static_cast<std::uint32_t>(index));
+#else
+ PropertyDefaultValueContainer::const_iterator iter = find_if(mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(), PairFinder<Property::Index, PropertyDefaultValuePair>(index));
+#endif
+ if(iter != mPropertyDefaultValues.end())
{
return iter->second;
}
// we didn't have a value so ask base
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetPropertyDefaultValue( index );
+ return mBaseType->GetPropertyDefaultValue(index);
}
return Property::Value(); // return none
}
-void TypeInfo::SetProperty( BaseObject *object, Property::Index index, const Property::Value& value ) const
+void TypeInfo::SetProperty(BaseObject* object, Property::Index index, Property::Value value) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
- {
- if( iter->second.setFunc )
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
+ {
+ if(iter->second.setFunc)
{
- if( mCSharpType )
+ if(mCSharpType)
{
// CSharp wants a property name not an index
- const std::string& name = (iter->second).name;
+ auto name = (iter->second).name;
- iter->second.cSharpSetFunc( object,name.c_str(), const_cast< Property::Value* >(&value) );
+ iter->second.cSharpSetFunc(object, name.GetCString(), const_cast<Property::Value*>(&value));
}
else
{
- iter->second.setFunc( object, index, value );
+ iter->second.setFunc(object, index, std::move(value));
}
}
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- mBaseType->SetProperty( object, index, value );
+ mBaseType->SetProperty(object, index, std::move(value));
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
-void TypeInfo::SetProperty( BaseObject *object, const std::string& name, const Property::Value& value ) const
+void TypeInfo::SetProperty(BaseObject* object, const std::string& name, Property::Value value) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
- if ( iter != mRegisteredProperties.end() )
+ // Slow but should not be done that often
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(ConstString(name)));
+ if(iter != mRegisteredProperties.end())
{
- DALI_ASSERT_ALWAYS( iter->second.setFunc && "Trying to write to a read-only property" );
+ DALI_ASSERT_ALWAYS(iter->second.setFunc && "Trying to write to a read-only property");
- if( mCSharpType )
+ if(mCSharpType)
{
// CSharp wants a property name not an index
- iter->second.cSharpSetFunc( object,name.c_str(), const_cast< Property::Value* >(&value ));
+ iter->second.cSharpSetFunc(object, name.c_str(), const_cast<Property::Value*>(&value));
}
else
{
- iter->second.setFunc( object, iter->first, value );
+ iter->second.setFunc(object, iter->first, std::move(value));
}
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- mBaseType->SetProperty( object, name, value );
+ mBaseType->SetProperty(object, name, std::move(value));
}
else
{
- DALI_LOG_ERROR( "Property %s not found", name.c_str() );
+ DALI_LOG_ERROR("Property %s not found", name.c_str());
}
}
-Property::Value TypeInfo::GetProperty( const BaseObject *object, Property::Index index ) const
+Property::Value TypeInfo::GetProperty(const BaseObject* object, Property::Index index) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if( iter != mRegisteredProperties.end() )
- {
- if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
+#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO
+ const auto& iter = mRegisteredProperties.Get(static_cast<std::uint32_t>(index));
+#else
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+#endif
+ if(iter != mRegisteredProperties.end())
+ {
+ if(mCSharpType) // using csharp property get which returns a pointer to a Property::Value
{
// CSharp wants a property name not an index
// CSharp callback can't return an object by value, it can only return a pointer
// CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
- const std::string& name = (iter->second).name;
-
- return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), name.c_str()) );
+ auto name = (iter->second).name;
+ return *(iter->second.cSharpGetFunc(const_cast<BaseObject*>(object), name.GetCString()));
}
else
{
// Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
- return iter->second.getFunc( const_cast< BaseObject* >( object ), index );
+ return iter->second.getFunc(const_cast<BaseObject*>(object), index);
}
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetProperty( object, index );
+ return mBaseType->GetProperty(object, index);
}
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
return Property::Value();
}
-Property::Value TypeInfo::GetProperty( const BaseObject *object, const std::string& name ) const
+Property::Value TypeInfo::GetProperty(const BaseObject* object, const std::string& name) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
-
-
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(ConstString(name)));
- if( iter != mRegisteredProperties.end() )
+ if(iter != mRegisteredProperties.end())
{
- if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
+ if(mCSharpType) // using csharp property get which returns a pointer to a Property::Value
{
- // CSharp wants a property name not an index
- // CSharp callback can't return an object by value, it can only return a pointer
- // CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
- return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), name.c_str() ));
-
+ // CSharp wants a property name not an index
+ // CSharp callback can't return an object by value, it can only return a pointer
+ // CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
+ return *(iter->second.cSharpGetFunc(const_cast<BaseObject*>(object), name.c_str()));
}
else
{
// Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
- return iter->second.getFunc( const_cast< BaseObject* >( object ), iter->first );
+ return iter->second.getFunc(const_cast<BaseObject*>(object), iter->first);
}
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetProperty( object, name );
+ return mBaseType->GetProperty(object, name);
}
- DALI_LOG_ERROR( "Property %s not found", name.c_str() );
+ DALI_LOG_ERROR("Property %s not found", name.c_str());
return Property::Value();
}