store base typeinfo pointer instead of resolving it every time a method is called.
this is safe as type info cannot change after registration.
store intrusive pointers to type-info-impl instead of handles as they are considerably cheaper
In dali-demo startup reduced the count of calls:
Before:
TypeRegistry::GetTypeInfo 2409
TypeInfo::TypeInfo 3006
Change-Id: Idd53378ca15cc0f690597dd7a5855cb5986a6785
// This uses a dynamic_cast so can be quite expensive so we only really want to do it once
// especially as the type-info does not change during the life-time of an application
// This uses a dynamic_cast so can be quite expensive so we only really want to do it once
// especially as the type-info does not change during the life-time of an application
- Dali::TypeInfo typeInfoHandle = TypeRegistry::Get()->GetTypeInfo( this );
+ TypeRegistry::TypeInfoPointer typeInfoHandle = TypeRegistry::Get()->GetTypeInfo( this );
- mTypeInfo = &GetImplementation( typeInfoHandle );
+ mTypeInfo = typeInfoHandle.Get(); // just a raw pointer to use, ownership is kept
void Object::RegisterAnimatableProperty( const TypeInfo& typeInfo,
Property::Index index,
void Object::RegisterAnimatableProperty( const TypeInfo& typeInfo,
Property::Index index,
- const Property::Value* value) const
+ const Property::Value* value ) const
{
// If the property is not a component of a base property, register the whole property itself.
const std::string& propertyName = typeInfo.GetPropertyName( index );
{
// If the property is not a component of a base property, register the whole property itself.
const std::string& propertyName = typeInfo.GetPropertyName( index );
+// 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 );
+/**
+ * Helper function to resolve and return the pointer to the base type info
+ * Not a member function to avoid having to #include additional headers and to make sure this gets inlined inside this cpp
+ * @param[in/out] baseType pointer to resolve and set
+ * @param[in] typeRegistry reference to the type registry
+ * @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 )
+ // if greater than unresolved means we have a base type, null means no base
+ bool baseExists = ( baseType > UNRESOLVED );
+ // base only needs to be resolved once
+ if( UNRESOLVED == baseType )
+ {
+ TypeRegistry::TypeInfoPointer base = typeRegistry.GetTypeInfo( baseTypeName );
+ if( base )
+ {
+ baseType = base.Get(); // dont pass ownership, just return raw pointer
+ baseExists = true;
+ }
+ else
+ {
+ // no type info found so assuming no base as all type registration is done in startup for now
+ baseType = nullptr;
+ }
+ }
+ return baseExists;
+}
+
+} // unnamed namespace
TypeInfo::TypeInfo( const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator,
const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount )
TypeInfo::TypeInfo( const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator,
const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount )
-: mTypeRegistry( *TypeRegistry::Get() ),
- mTypeName(name), mBaseTypeName(baseTypeName), mCreate(creator), mDefaultProperties( defaultProperties ),
- mDefaultPropertyCount( defaultPropertyCount ), mCSharpType(false)
+: 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)
{
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() ),
- mTypeName(name), mBaseTypeName(baseTypeName), mCSharpCreate(creator), mCSharpType(true)
+: 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");
{
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");
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- while( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- done = GetImplementation(base).DoActionTo(object, actionName, properties);
- if( done )
- {
- break;
- }
- base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
+ // call base type recursively
+ done = mBaseType->DoActionTo( object, actionName, properties );
connected = (iter->second)( object, connectionTracker, signalName, functor );
}
connected = (iter->second)( object, connectionTracker, signalName, functor );
}
+ if( !connected )
+ {
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ {
+ // call base type recursively
+ connected = mBaseType->ConnectSignal( object, connectionTracker, signalName, functor );
+ }
+ }
+
{
size_t count = mActions.size();
{
size_t count = mActions.size();
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- while( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- count += GetImplementation(base).mActions.size();
- base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
+ // call base type recursively
+ count += mBaseType->GetActionCount();
std::string TypeInfo::GetActionName(size_t index) const
{
std::string name;
std::string TypeInfo::GetActionName(size_t index) const
{
std::string name;
+ const size_t count = mActions.size();
- if( index < mActions.size() )
{
name = mActions[index].first;
}
else
{
{
name = mActions[index].first;
}
else
{
- size_t count = mActions.size();
-
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- while( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- size_t baseCount = GetImplementation(base).mActions.size();
-
- if( index < count + baseCount )
- {
- name = GetImplementation(base).mActions[ index - count ].first;
- break;
- }
-
- count += baseCount;
-
- base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
+ // call base type recursively
+ return mBaseType->GetActionName( index - count );
{
size_t count = mSignalConnectors.size();
{
size_t count = mSignalConnectors.size();
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- while( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- count += GetImplementation(base).mSignalConnectors.size();
- base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
+ // call base type recursively
+ count += mBaseType->GetSignalCount();
std::string TypeInfo::GetSignalName(size_t index) const
{
std::string name;
std::string TypeInfo::GetSignalName(size_t index) const
{
std::string name;
+ const size_t count = mSignalConnectors.size();
- if( index < mSignalConnectors.size() )
{
name = mSignalConnectors[index].first;
}
else
{
{
name = mSignalConnectors[index].first;
}
else
{
- size_t count = mSignalConnectors.size();
-
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- while( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- size_t baseCount = GetImplementation(base).mSignalConnectors.size();
-
- if( index < count + baseCount )
- {
- name = GetImplementation(base).mSignalConnectors[ index - count ].first;
- break;
- }
-
- count += baseCount;
-
- base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
+ // call base type recursively
+ return mBaseType->GetSignalName( index - count );
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- const TypeInfo& baseImpl( GetImplementation( base ) );
- baseImpl.GetPropertyIndices( indices );
+ // call base type recursively
+ mBaseType->GetPropertyIndices( indices );
}
AppendProperties( indices, mRegisteredProperties );
}
AppendProperties( indices, mRegisteredProperties );
void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
{
void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
{
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- const TypeInfo& baseImpl( GetImplementation( base ) );
- baseImpl.GetChildPropertyIndices( indices );
+ // call base type recursively
+ mBaseType->GetChildPropertyIndices( indices );
}
AppendProperties( indices, mRegisteredChildProperties );
}
AppendProperties( indices, mRegisteredChildProperties );
{
return iter->second.name;
}
{
return iter->second.name;
}
- Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- return GetImplementation(base).GetRegisteredPropertyName( index );
+ // call base type recursively
+ return mBaseType->GetRegisteredPropertyName( index );
}
static std::string empty;
return empty;
}
static std::string empty;
return empty;
// if not our property, go to parent
if( propertyName.empty() )
{
// if not our property, go to parent
if( propertyName.empty() )
{
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- return GetImplementation(base).GetPropertyName( index );
+ // call base type recursively
+ return mBaseType->GetPropertyName( index );
{
uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>( mRegisteredProperties.size() );
{
uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>( mRegisteredProperties.size() );
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- while ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- const TypeInfo& baseImpl( GetImplementation(base) );
- count += baseImpl.mDefaultPropertyCount + static_cast<uint32_t>( baseImpl.mRegisteredProperties.size() );
- base = mTypeRegistry.GetTypeInfo( baseImpl.mBaseTypeName );
+ // call base type recursively
+ count += mBaseType->GetPropertyCount();
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- index = GetImplementation(base).GetPropertyIndex( name );
- }
+ // call base type recursively
+ index = mBaseType->GetPropertyIndex( name );
{
basePropertyIndex = iter->second.basePropertyIndex;
}
{
basePropertyIndex = iter->second.basePropertyIndex;
}
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- basePropertyIndex = GetImplementation(base).GetBasePropertyIndex( index );
- }
+ // call base type recursively
+ basePropertyIndex = mBaseType->GetBasePropertyIndex( index );
}
return basePropertyIndex;
}
return basePropertyIndex;
{
componentIndex = iter->second.componentIndex;
}
{
componentIndex = iter->second.componentIndex;
}
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- componentIndex = GetImplementation(base).GetComponentIndex( index );
- }
+ // call base type recursively
+ componentIndex = mBaseType->GetComponentIndex( index );
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- index = GetImplementation(base).GetChildPropertyIndex( name );
- }
+ // call base type recursively
+ index = mBaseType->GetChildPropertyIndex( name );
return iter->second.name;
}
return iter->second.name;
}
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- return GetImplementation(base).GetChildPropertyName( index );
+ // call base type recursively
+ return mBaseType->GetChildPropertyName( index );
}
DALI_LOG_ERROR( "Property index %d not found\n", index );
}
DALI_LOG_ERROR( "Property index %d not found\n", index );
{
type = iter->second.type;
}
{
type = iter->second.type;
}
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ {
+ // call base type recursively
+ type = mBaseType->GetChildPropertyType( index );
+ }
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- type = GetImplementation(base).GetChildPropertyType( index );
- }
- else
- {
- DALI_LOG_ERROR( "Property index %d not found\n", index );
- }
+ DALI_LOG_ERROR( "Property index %d not found\n", index );
// if not found, continue to base
if( !found )
{
// if not found, continue to base
if( !found )
{
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- writable = GetImplementation(base).IsPropertyWritable( index );
+ // call base type recursively
+ writable = mBaseType->IsPropertyWritable( index );
// if not found, continue to base
if( !found )
{
// if not found, continue to base
if( !found )
{
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- animatable = GetImplementation(base).IsPropertyAnimatable( index );
+ // call base type recursively
+ animatable = mBaseType->IsPropertyAnimatable( index );
// if not found, continue to base
if( !found )
{
// if not found, continue to base
if( !found )
{
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- constraintInput = GetImplementation(base).IsPropertyAConstraintInput( index );
+ // call base type recursively
+ constraintInput = mBaseType->IsPropertyAConstraintInput( index );
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- type = GetImplementation(base).GetPropertyType( index );
+ // call base type recursively
+ type = mBaseType->GetPropertyType( index );
{
PropertyDefaultValueContainer::const_iterator iter = find_if( mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(),
PairFinder< Property::Index, PropertyDefaultValuePair >( index ) );
{
PropertyDefaultValueContainer::const_iterator iter = find_if( mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(),
PairFinder< Property::Index, PropertyDefaultValuePair >( index ) );
- if( iter != mPropertyDefaultValues.end() )
+ if( iter != mPropertyDefaultValues.end() )
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ {
+ // call base type recursively
+ mBaseType->SetProperty( object, index, value );
+ }
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- GetImplementation(base).SetProperty( object, index, value );
- }
- else
- {
- DALI_LOG_ERROR( "Property index %d not found\n", index );
- }
+ DALI_LOG_ERROR( "Property index %d not found\n", index );
iter->second.setFunc( object, iter->first, value );
}
}
iter->second.setFunc( object, iter->first, value );
}
}
+ else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ {
+ // call base type recursively
+ mBaseType->SetProperty( object, name, value );
+ }
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
- {
- GetImplementation(base).SetProperty( object, name, value );
- }
- else
- {
- DALI_LOG_ERROR( "Property %s not found", name.c_str() );
- }
+ DALI_LOG_ERROR( "Property %s not found", name.c_str() );
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- return GetImplementation( base ).GetProperty( object, index );
+ // call base type recursively
+ 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 );
- Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
- if ( base )
+ if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
- return GetImplementation( base ).GetProperty( object, name );
+ // call base type recursively
+ 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() );
private:
TypeRegistry& mTypeRegistry;
private:
TypeRegistry& mTypeRegistry;
+ mutable Internal::TypeInfo* mBaseType; // allow changing from const methods, initialised inside constructor
std::string mTypeName;
std::string mBaseTypeName;
union
std::string mTypeName;
std::string mBaseTypeName;
union
-Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string& uniqueTypeName )
+TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo( const std::string& uniqueTypeName )
{
for( auto&& iter : mRegistryLut )
{
// Note! mRegistryLut contains Dali::TypeInfo handles, so cannot call GetTypeName()
// as it calls us back resulting in infinite loop (GetTypeName is in BaseHandle part)
{
for( auto&& iter : mRegistryLut )
{
// Note! mRegistryLut contains Dali::TypeInfo handles, so cannot call GetTypeName()
// as it calls us back resulting in infinite loop (GetTypeName is in BaseHandle part)
- if( GetImplementation( iter ).GetName() == uniqueTypeName )
+ if( iter->GetName() == uniqueTypeName )
{
return iter;
}
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Cannot find requested type '%s'\n", uniqueTypeName.c_str() );
{
return iter;
}
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Cannot find requested type '%s'\n", uniqueTypeName.c_str() );
- return Dali::TypeInfo();
+ return TypeRegistry::TypeInfoPointer();
-Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
+TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo( const std::type_info& registerType )
{
std::string typeName = DemangleClassName( registerType.name() );
{
std::string typeName = DemangleClassName( registerType.name() );
if( index < mRegistryLut.size() )
{
if( index < mRegistryLut.size() )
{
- name = GetImplementation( mRegistryLut[ index ] ).GetName();
+ name = mRegistryLut[ index ]->GetName();
// check for duplicates using uniqueTypeName
for( auto&& iter : mRegistryLut )
{
// check for duplicates using uniqueTypeName
for( auto&& iter : mRegistryLut )
{
- if( GetImplementation( iter ).GetName() == uniqueTypeName )
+ if( iter->GetName() == uniqueTypeName )
{
DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() );
DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" );
{
DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() );
DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" );
- mRegistryLut.push_back( Dali::TypeInfo( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount ) ) );
+ mRegistryLut.push_back( TypeRegistry::TypeInfoPointer( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount ) ) );
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
if( callCreateOnInit )
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
if( callCreateOnInit )
// check for duplicates using uniqueTypeName
for( auto&& iter : mRegistryLut )
{
// check for duplicates using uniqueTypeName
for( auto&& iter : mRegistryLut )
{
- if( GetImplementation( iter ).GetName() == uniqueTypeName )
+ if( iter->GetName() == uniqueTypeName )
{
DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() );
DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" );
{
DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() );
DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" );
- mRegistryLut.push_back( Dali::TypeInfo( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance ) ) );
+ mRegistryLut.push_back( TypeRegistry::TypeInfoPointer( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance ) ) );
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
}
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
}
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == typeRegistration.RegisteredName() )
+ if( iter->GetName() == typeRegistration.RegisteredName() )
- impl.AddConnectorFunction( name, func );
+ iter->AddConnectorFunction( name, func );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == typeRegistration.RegisteredName() )
+ if( iter->GetName() == typeRegistration.RegisteredName() )
- impl.AddActionFunction( name, f );
+ iter->AddActionFunction( name, f );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == typeRegistration.RegisteredName() )
+ if( iter->GetName() == typeRegistration.RegisteredName() )
- impl.AddProperty( name, index, type, setFunc, getFunc );
+ iter->AddProperty( name, index, type, setFunc, getFunc );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == objectName )
+ if( iter->GetName() == objectName )
- impl.AddProperty( name, index, type, setFunc, getFunc );
+ iter->AddProperty( name, index, type, setFunc, getFunc );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == typeRegistration.RegisteredName() )
+ if( iter->GetName() == typeRegistration.RegisteredName() )
- impl.AddAnimatableProperty( name, index, type );
+ iter->AddAnimatableProperty( name, index, type );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == typeRegistration.RegisteredName() )
+ if( iter->GetName() == typeRegistration.RegisteredName() )
- impl.AddAnimatableProperty( name, index, value );
+ iter->AddAnimatableProperty( name, index, value );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == typeRegistration.RegisteredName() )
+ if( iter->GetName() == typeRegistration.RegisteredName() )
- impl.AddAnimatablePropertyComponent( name, index, baseIndex, componentIndex );
+ iter->AddAnimatablePropertyComponent( name, index, baseIndex, componentIndex );
{
for( auto&& iter : mRegistryLut )
{
{
for( auto&& iter : mRegistryLut )
{
- auto&& impl = GetImplementation( iter );
- if( impl.GetName() == registeredType )
+ if( iter->GetName() == registeredType )
- impl.AddChildProperty( name, index, type );
+ iter->AddChildProperty( name, index, type );
- Dali::TypeInfo type = GetTypeInfo( object );
+ auto&& type = GetTypeInfo( object );
- auto&& impl = GetImplementation( type );
// DoActionTo recurses through base classes
// DoActionTo recurses through base classes
- done = impl.DoActionTo( object, actionName, properties );
+ done = type->DoActionTo( object, actionName, properties );
- DALI_LOG_WARNING("Type '%s' cannot do action '%s'\n", type.GetName().c_str(), actionName.c_str());
+ DALI_LOG_WARNING("Type '%s' cannot do action '%s'\n", type->GetName().c_str(), actionName.c_str());
{
bool connected( false );
{
bool connected( false );
- Dali::TypeInfo type = GetTypeInfo( object );
+ auto&& type = GetTypeInfo( object );
- while( type )
- {
- auto&& impl = GetImplementation( type );
- connected = impl.ConnectSignal( object, connectionTracker, signalName, functor );
- if( connected )
- {
- break;
- }
- type = GetTypeInfo( impl.GetBaseName() );
- }
+ // Connect iterates through base classes
+ connected = type->ConnectSignal( object, connectionTracker, signalName, functor );
+ DALI_LOG_WARNING("Type '%s' signal '%s' connection failed \n", type->GetName().c_str(), signalName.c_str());
// Ownership of functor was not passed to Dali::CallbackBase, so clean-up now
delete functor;
}
// Ownership of functor was not passed to Dali::CallbackBase, so clean-up now
delete functor;
}
-Dali::TypeInfo TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObject)
+TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObject)
// test for custom actor which has another indirection to get to the type hiearchy we're after
const Dali::Internal::CustomActor * const pCustom = dynamic_cast<const Dali::Internal::CustomActor*>(pBaseObject);
// test for custom actor which has another indirection to get to the type hiearchy we're after
const Dali::Internal::CustomActor * const pCustom = dynamic_cast<const Dali::Internal::CustomActor*>(pBaseObject);
{
const Dali::CustomActorImpl& custom = pCustom->GetImplementation();
type = GetTypeInfo( typeid( custom ) );
{
const Dali::CustomActorImpl& custom = pCustom->GetImplementation();
type = GetTypeInfo( typeid( custom ) );
class TypeRegistry : public Dali::BaseObject
{
public:
class TypeRegistry : public Dali::BaseObject
{
public:
+
+ // using intrusive pointer instead of handles internally as they are considerably cheaper
+ using TypeInfoPointer = IntrusivePtr<Dali::Internal::TypeInfo>;
+
/**
* Get the TypeRegistry
*/
/**
* Get the TypeRegistry
*/
/**
* @copydoc Dali::TypeRegistry::GetTypeInfo
*/
/**
* @copydoc Dali::TypeRegistry::GetTypeInfo
*/
- Dali::TypeInfo GetTypeInfo( const std::string &uniqueTypeName );
+ TypeInfoPointer GetTypeInfo( const std::string &uniqueTypeName );
/**
* @copydoc Dali::TypeRegistry::GetTypeInfo
*/
/**
* @copydoc Dali::TypeRegistry::GetTypeInfo
*/
- Dali::TypeInfo GetTypeInfo( const std::type_info& registerType );
+ TypeInfoPointer GetTypeInfo( const std::type_info& registerType );
/**
* @copydoc Dali::TypeRegistry::GetTypeNameCount
/**
* @copydoc Dali::TypeRegistry::GetTypeNameCount
* @param [in] pBaseObject Pointer to a BaseObject
* @return TypeInfo for the BaseObject.
*/
* @param [in] pBaseObject Pointer to a BaseObject
* @return TypeInfo for the BaseObject.
*/
- Dali::TypeInfo GetTypeInfo(const Dali::BaseObject * const pBaseObject);
+ TypeInfoPointer GetTypeInfo(const Dali::BaseObject * const pBaseObject);
/**
* Calls any type creation functions that have been flagged as initialization functions
/**
* Calls any type creation functions that have been flagged as initialization functions
/*
* Mapping from type name to TypeInfo
*/
/*
* Mapping from type name to TypeInfo
*/
- std::vector< Dali::TypeInfo > mRegistryLut;
+ std::vector< TypeInfoPointer > mRegistryLut;
std::vector< Dali::TypeInfo::CreateFunction > mInitFunctions;
std::vector< Dali::TypeInfo::CreateFunction > mInitFunctions;
- Dali::TypeInfo typeInfo = registry->GetTypeInfo(this);
+ Internal::TypeRegistry::TypeInfoPointer typeInfo = registry->GetTypeInfo(this);
- return typeInfo.GetName();
+ return typeInfo->GetName();
{
Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
{
Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
- Dali::TypeInfo info = registry->GetTypeInfo(this);
+ Internal::TypeRegistry::TypeInfoPointer info = registry->GetTypeInfo(this);
+ typeInfo = Dali::TypeInfo( info.Get() );
Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
{
Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
{
- return GetImplementation(*this).GetTypeInfo( uniqueTypeName );
+ return Dali::TypeInfo( GetImplementation(*this).GetTypeInfo( uniqueTypeName ).Get() );
}
Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
{
}
Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
{
- return GetImplementation(*this).GetTypeInfo( registerType );
+ return Dali::TypeInfo( GetImplementation(*this).GetTypeInfo( registerType ).Get() );
}
size_t TypeRegistry::GetTypeNameCount() const
}
size_t TypeRegistry::GetTypeNameCount() const