Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / object / base-object.cpp
index 362bde2..98ed327 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 #include <dali/public-api/object/base-object.h>
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
 #include <dali/integration-api/debug.h>
+#include <dali/internal/event/common/base-object-impl.h>
 #include <dali/internal/event/common/object-registry-impl.h>
 #include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/thread-local-storage.h>
 #include <dali/internal/event/common/type-registry-impl.h>
+#include <dali/public-api/object/type-registry.h>
 
 namespace Dali
 {
-
 BaseObject::BaseObject()
+: mImpl(new Impl(*this))
 {
 }
 
-BaseObject::~BaseObject()
-{
-}
+BaseObject::~BaseObject() = default;
 
 void BaseObject::RegisterObject()
 {
-  Internal::Stage* stage = Internal::Stage::GetCurrent();
-  if( stage )
+  Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
+  if(tls)
   {
-    stage->RegisterObject( this );
+    tls->GetEventThreadServices().RegisterObject(this);
   }
 }
 
 void BaseObject::UnregisterObject()
 {
+  Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
+
   // Guard to allow handle destruction after Core has been destroyed
-  Internal::Stage* stage = Internal::Stage::GetCurrent();
-  if( stage )
+  if(tls)
   {
-    stage->UnregisterObject( this );
+    tls->GetEventThreadServices().UnregisterObject(this);
   }
 }
 
@@ -59,7 +60,7 @@ bool BaseObject::DoAction(const std::string& actionName, const Property::Map& at
 {
   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
 
-  if( registry )
+  if(registry)
   {
     return registry->DoActionTo(this, actionName, attributes);
   }
@@ -71,17 +72,17 @@ const std::string& BaseObject::GetTypeName() const
 {
   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
 
-  if( registry )
+  if(registry)
   {
     Internal::TypeRegistry::TypeInfoPointer typeInfo = registry->GetTypeInfo(this);
-    if( typeInfo )
+    if(typeInfo)
     {
       return typeInfo->GetName();
     }
   }
 
   // Return an empty string if type-name not found.
-  DALI_LOG_WARNING( "TypeName Not Found\n" );
+  DALI_LOG_WARNING("TypeName Not Found\n");
   static std::string empty;
   return empty;
 }
@@ -93,7 +94,7 @@ bool BaseObject::GetTypeInfo(Dali::TypeInfo& typeInfo) const
   Internal::TypeRegistry::TypeInfoPointer info = registry->GetTypeInfo(this);
   if(info)
   {
-    typeInfo = Dali::TypeInfo( info.Get() );
+    typeInfo = Dali::TypeInfo(info.Get());
     return true;
   }
   else
@@ -102,17 +103,16 @@ bool BaseObject::GetTypeInfo(Dali::TypeInfo& typeInfo) const
   }
 }
 
-bool BaseObject::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
+bool BaseObject::DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor)
 {
   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
 
-  if( registry )
+  if(registry)
   {
-    return registry->ConnectSignal( this, connectionTracker, signalName, functor );
+    return registry->ConnectSignal(this, connectionTracker, signalName, functor);
   }
 
   return false;
 }
 
 } // namespace Dali
-