Tizen Native API
Dali::TypeRegistry Class Reference

The TypeRegistry allows registration of type instance creation functions. More...

Inheritance diagram for Dali::TypeRegistry:
Dali::BaseHandle

Public Member Functions

 TypeRegistry ()
 Allows the creation of an empty typeRegistry handle.
 ~TypeRegistry ()
 destructor.
 TypeRegistry (const TypeRegistry &handle)
 This copy constructor is required for (smart) pointer semantics.
TypeRegistryoperator= (const TypeRegistry &rhs)
 This assignment operator is required for (smart) pointer semantics.
TypeInfo GetTypeInfo (const std::string &uniqueTypeName)
 Get TypeInfo for a registered type.
TypeInfo GetTypeInfo (const std::type_info &registerType)
 Get TypeInfo for a registered type.
size_t GetTypeNameCount () const
 Get type name count.
std::string GetTypeName (size_t index) const
 Get type names by index.

Static Public Member Functions

static TypeRegistry Get ()
 Get Type Registry handle.

Detailed Description

The TypeRegistry allows registration of type instance creation functions.

These can then be created later by name and down cast to the appropriate type.

Usage: (Registering)

In my-actor.cpp

 // Note: object construction in namespace scope is defined in a translation unit as being
 //       in appearance order (C++ standard 3.6/2). So TypeRegistration is declared first in
 //       the cpp file below. Signal, action and property declarations follow in any order.
 namespace
 {
   TypeRegistration myActorType(typeid(MyActor), typeid(Actor), CreateMyActor );

   SignalConnectorType( myActorType, "highlighted", ConnectSignalForMyActor );
   TypeAction( myActorType, "open", DoMyActorAction );
   TypeAction( myActorType, "close", DoMyActorAction );
   PropertyRegistration( myActorType, "status", PropertyRegistration::START_INDEX, Property::BOOLEAN, SetPropertyFunction, GetPropertyFunction );
 }

Usage: (Creation)

   TypeRegistry::TypeInfo type = TypeRegistry::Get().GetTypeInfo("MyActor");
   MyActor a = MyActor::DownCast(type.CreateInstance());
   if(a)
   {
     ...
   }

CustomActor

Actors that inherit from the CustomActor framework must ensure the implementation class has an identical name to the Actor class. This is to ensure the class can be found at runtime for signals and actions. Otherwise these will silently fail.

As namespaces are discarded the convention is to use a namespace ie

'class MyActor {}; namespace Internal { class MyActor {}; }'

Warning: this arrangement will silently fail

'class MyActor {}; class MyActorImpl {};'

Naming Conventions

Signal and action names follow properties and are by convention lower case hyphen separated ie 'next-page'. This maintains consistency with the scripted interface.

Since :
2.4

Constructor & Destructor Documentation

Allows the creation of an empty typeRegistry handle.

Since :
2.4

destructor.

Since :
2.4

This copy constructor is required for (smart) pointer semantics.

Since :
2.4
Parameters:
[in]handleA reference to the copied handle

Member Function Documentation

Get Type Registry handle.

Since :
2.4
Returns:
TypeRegistry handle
TypeInfo Dali::TypeRegistry::GetTypeInfo ( const std::string &  uniqueTypeName)

Get TypeInfo for a registered type.

Since :
2.4
Parameters:
[in]uniqueTypeNameA unique type name
Returns:
TypeInfo if the type exists otherwise an empty handle
TypeInfo Dali::TypeRegistry::GetTypeInfo ( const std::type_info &  registerType)

Get TypeInfo for a registered type.

Since :
2.4
Parameters:
[in]registerTypeThe registered type info
Returns:
TypeInfo if the type exists otherwise an empty handle
std::string Dali::TypeRegistry::GetTypeName ( size_t  index) const

Get type names by index.

Since :
2.4
Returns:
The type name or an empty string when index is not valid

Get type name count.

Since :
2.4
Returns:
The count
TypeRegistry& Dali::TypeRegistry::operator= ( const TypeRegistry rhs)

This assignment operator is required for (smart) pointer semantics.

Since :
2.4
Parameters:
[in]rhsA reference to the copied handle
Returns:
A reference to this