Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / common / type-registry-impl.cpp
index be5ef41..5d61e49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -99,18 +99,27 @@ Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
   return ret;
 }
 
-Dali::TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const
+size_t TypeRegistry::GetTypeNameCount() const
 {
-  Dali::TypeRegistry::NameContainer ret;
+  return mRegistryLut.size();
+}
+
+
+std::string TypeRegistry::GetTypeName(size_t index) const
+{
+  std::string name;
 
-  for(RegistryMap::const_iterator iter = mRegistryLut.begin(); iter != mRegistryLut.end(); ++iter)
+  if( index < mRegistryLut.size() )
   {
-    ret.push_back(iter->first);
+    RegistryMap::const_iterator iter = mRegistryLut.begin();
+    std::advance(iter, index);
+    name = iter->first;
   }
 
-  return ret;
+  return name;
 }
 
+
 bool TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
                              Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
 {
@@ -148,6 +157,32 @@ bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_
   return ret;
 }
 
+bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo,
+    Dali::CSharpTypeInfo::CreateFunction createInstance )
+{
+
+  bool ret = false;
+
+  std::string baseTypeName    = DemangleClassName(baseTypeInfo.name());
+
+  RegistryMap::iterator iter = mRegistryLut.find(uniqueTypeName);
+
+  if( iter == mRegistryLut.end() )
+  {
+    mRegistryLut[uniqueTypeName] = Dali::TypeInfo(new Internal::TypeInfo(uniqueTypeName, baseTypeName, createInstance));
+    ret = true;
+    DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str());
+  }
+  else
+  {
+    DALI_LOG_WARNING("Duplicate name for TypeRegistry for '%s'\n", + uniqueTypeName.c_str());
+    DALI_ASSERT_ALWAYS(!"Duplicate type name for Type Registation");
+  }
+
+  return ret;
+
+}
+
 void TypeRegistry::CallInitFunctions(void) const
 {
   for( InitFunctions::const_iterator iter = mInitFunctions.begin(); iter != mInitFunctions.end(); ++iter)
@@ -207,6 +242,24 @@ bool TypeRegistry::RegisterProperty( TypeRegistration& registered, const std::st
   return false;
 }
 
+bool TypeRegistry::RegisterProperty( const std::string& objectName, const std::string& name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc )
+{
+  RegistryMap::iterator iter = mRegistryLut.find( objectName );
+
+  if( iter != mRegistryLut.end() )
+  {
+    DALI_ASSERT_DEBUG(iter->second);
+
+    GetImplementation(iter->second).AddProperty( name, index, type, setFunc, getFunc );
+
+    return true;
+  }
+
+  return false;
+
+}
+
+
 bool TypeRegistry::RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type )
 {
   RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() );
@@ -223,7 +276,55 @@ bool TypeRegistry::RegisterAnimatableProperty( TypeRegistration& registered, con
   return false;
 }
 
-bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string &actionName, const std::vector<Property::Value> &properties)
+bool TypeRegistry::RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& value )
+{
+  RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() );
+
+  if( iter != mRegistryLut.end() )
+  {
+    DALI_ASSERT_DEBUG(iter->second);
+
+    GetImplementation(iter->second).AddAnimatableProperty( name, index, value );
+
+    return true;
+  }
+
+  return false;
+}
+
+bool TypeRegistry::RegisterAnimatablePropertyComponent( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex )
+{
+  RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() );
+
+  if( iter != mRegistryLut.end() )
+  {
+    DALI_ASSERT_DEBUG(iter->second);
+
+    GetImplementation(iter->second).AddAnimatablePropertyComponent( name, index, baseIndex, componentIndex );
+
+    return true;
+  }
+
+  return false;
+}
+
+bool TypeRegistry::RegisterChildProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type )
+{
+  RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() );
+
+  if( iter != mRegistryLut.end() )
+  {
+    DALI_ASSERT_DEBUG(iter->second);
+
+    GetImplementation(iter->second).AddChildProperty( name, index, type );
+
+    return true;
+  }
+
+  return false;
+}
+
+bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string &actionName, const Property::Map &properties)
 {
   bool done = false;
 
@@ -276,7 +377,8 @@ Dali::TypeInfo TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObj
 
   if(pCustom)
   {
-    type = GetTypeInfo( typeid( pCustom->GetImplementation() ) );
+    const Dali::CustomActorImpl& custom = pCustom->GetImplementation();
+    type = GetTypeInfo( typeid( custom ) );
   }
   else
   {