template <typename T>
struct PropertyNameFinder
{
- PropertyNameFinder( const std::string& find )
- : mFind( find )
+ PropertyNameFinder(ConstString find)
+ : mFind(find)
{
}
}
private:
-
- const std::string& mFind;
+ ConstString mFind;
};
/**
DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
}
-TypeInfo::~TypeInfo()
-{
-}
+TypeInfo::~TypeInfo() = default;
BaseHandle TypeInfo::CreateInstance() const
{
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 ) )
{
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();
+ const uint32_t count = static_cast<uint32_t>( mActions.size() );
if( 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 ) )
{
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();
+ const uint32_t count = static_cast<uint32_t>( mSignalConnectors.size() );
if( index < count )
{
}
}
-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() )
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
{
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 ) )
{
- const char* name = nullptr;
+ std::string_view name;
if( GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::name, name ) )
{
propertyName = name;
PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
if ( iter != mRegisteredProperties.end() )
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
}
// if not our property, go to parent
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");
}
if( iter == mActions.end() )
{
- mActions.push_back( ActionPair( actionName, function ) );
+ mActions.push_back(ActionPair(std::move(actionName), function));
}
else
{
}
}
-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");
}
if( iter == mSignalConnectors.end() )
{
- mSignalConnectors.push_back( ConnectionPair( signalName, function ) );
+ mSignalConnectors.push_back(ConnectionPair(std::move(signalName), function));
}
else
{
}
}
-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" );
}
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
}
}
-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" );
}
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
}
-
-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() )
{
- 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
{
}
}
-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() )
{
- mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( defaultValue.GetType(), name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
- mPropertyDefaultValues.push_back( PropertyDefaultValuePair( index, defaultValue ) );
+ 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
{
}
}
-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" );
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;
}
}
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() )
{
- 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
{
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;
// check default properties
if( mDefaultProperties )
{
+ 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;
found = true;
return basePropertyIndex;
}
-int TypeInfo::GetComponentIndex( Property::Index index ) const
+int32_t TypeInfo::GetComponentIndex( Property::Index index ) const
{
int componentIndex = Property::INVALID_COMPONENT_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;
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() )
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
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
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( 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 ) )
{
// call base type recursively
- mBaseType->SetProperty( object, index, value );
+ mBaseType->SetProperty(object, index, std::move(value));
}
else
{
}
}
-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 ) );
+ 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" );
}
else
{
- iter->second.setFunc( object, iter->first, value );
+ iter->second.setFunc(object, iter->first, std::move(value));
}
}
else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
{
// call base type recursively
- mBaseType->SetProperty( object, name, value );
+ mBaseType->SetProperty(object, name, std::move(value));
}
else
{
// 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
{
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() )
{