Optimize type-info-impl and type-registry-impl
[platform/core/uifw/dali-core.git] / dali / public-api / object / base-object.cpp
index 3baa7fe..362bde2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -25,8 +25,6 @@
 #include <dali/internal/event/common/stage-impl.h>
 #include <dali/internal/event/common/type-registry-impl.h>
 
-using namespace std;
-
 namespace Dali
 {
 
@@ -40,22 +38,24 @@ BaseObject::~BaseObject()
 
 void BaseObject::RegisterObject()
 {
-  if( Internal::Stage::IsInstalled() )
+  Internal::Stage* stage = Internal::Stage::GetCurrent();
+  if( stage )
   {
-    Internal::Stage::GetCurrent()->GetObjectRegistry().RegisterObject( this );
+    stage->RegisterObject( this );
   }
 }
 
 void BaseObject::UnregisterObject()
 {
   // Guard to allow handle destruction after Core has been destroyed
-  if( Internal::Stage::IsInstalled() )
+  Internal::Stage* stage = Internal::Stage::GetCurrent();
+  if( stage )
   {
-    Internal::Stage::GetCurrent()->GetObjectRegistry().UnregisterObject( this );
+    stage->UnregisterObject( this );
   }
 }
 
-bool BaseObject::DoAction(const std::string& actionName, const std::vector<Property::Value>& attributes)
+bool BaseObject::DoAction(const std::string& actionName, const Property::Map& attributes)
 {
   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
 
@@ -73,16 +73,33 @@ const std::string& BaseObject::GetTypeName() const
 
   if( registry )
   {
-    Dali::TypeInfo typeInfo = registry->GetTypeInfo(this);
+    Internal::TypeRegistry::TypeInfoPointer typeInfo = registry->GetTypeInfo(this);
     if( typeInfo )
     {
-      return typeInfo.GetName();
+      return typeInfo->GetName();
     }
   }
 
   // Return an empty string if type-name not found.
   DALI_LOG_WARNING( "TypeName Not Found\n" );
-  return String::EMPTY;
+  static std::string empty;
+  return empty;
+}
+
+bool BaseObject::GetTypeInfo(Dali::TypeInfo& typeInfo) const
+{
+  Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
+
+  Internal::TypeRegistry::TypeInfoPointer info = registry->GetTypeInfo(this);
+  if(info)
+  {
+    typeInfo = Dali::TypeInfo( info.Get() );
+    return true;
+  }
+  else
+  {
+    return false;
+  }
 }
 
 bool BaseObject::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )