Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / signals / callback.cpp
index 841b1df..5b78b74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
 // CLASS HEADER
 #include <dali/public-api/signals/callback.h>
 
-
 namespace Dali
 {
-
 // CallbackBase
 
 CallbackBase::CallbackBase()
-: mImpl( NULL ),
-  mFunction( NULL )
+: mFunction(nullptr)
 {
 }
 
@@ -35,72 +32,40 @@ CallbackBase::~CallbackBase()
   Reset();
 }
 
-CallbackBase::CallbackBase( Function function )
-: mImpl( NULL ),
-  mFunction( function )
+CallbackBase::CallbackBase(Function function)
+: mFunction(function)
 {
 }
 
-CallbackBase::CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher )
-: mMemberFunction( function )
+CallbackBase::CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher)
+: mMemberFunction(function)
 {
-  mImpl = new CallbackBase::Impl;
-  mImpl->mObjectPointer = object;
-  mImpl->mMemberFunctionDispatcher = dispatcher;
-  mImpl->mDestructorDispatcher = NULL; // object is not owned
+  mImpl.mObjectPointer            = object;
+  mImpl.mMemberFunctionDispatcher = dispatcher;
+  mImpl.mDestructorDispatcher     = nullptr; // object is not owned
 }
 
-CallbackBase::CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor )
-: mMemberFunction( function )
+CallbackBase::CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor)
+: mMemberFunction(function)
 {
-  mImpl = new CallbackBase::Impl;
-  mImpl->mObjectPointer = object;
-  mImpl->mMemberFunctionDispatcher = dispatcher;
-  mImpl->mDestructorDispatcher = destructor; // object is owned
+  mImpl.mObjectPointer            = object;
+  mImpl.mMemberFunctionDispatcher = dispatcher;
+  mImpl.mDestructorDispatcher     = destructor; // object is owned
 }
 
 void CallbackBase::Reset()
 {
-  if( mImpl )
+  // if destructor function is set it means we own this object
+  if(mImpl.mObjectPointer &&
+     mImpl.mDestructorDispatcher)
   {
-    // if destructor function is set it means we own this object
-    if ( mImpl->mObjectPointer &&
-         mImpl->mDestructorDispatcher )
-    {
-      // call the destructor dispatcher
-      (*mImpl->mDestructorDispatcher)( mImpl->mObjectPointer );
-    }
-
-    delete mImpl;
-    mImpl = NULL;
+    // call the destructor dispatcher
+    (*mImpl.mDestructorDispatcher)(mImpl.mObjectPointer);
   }
 
-  mFunction = NULL;
-}
-
-// CallbackBase::Impl
-
-CallbackBase::Impl::Impl()
-: mObjectPointer( NULL ),
-  mMemberFunctionDispatcher( NULL ),
-  mDestructorDispatcher( NULL )
-{
-}
-
-// Non-member equality operator
+  mImpl = {};
 
-bool operator==( const CallbackBase& lhs, const CallbackBase& rhs )
-{
-  if( lhs.mImpl )
-  {
-    // check it's the same member function / object
-    return ( lhs.mFunction == rhs.mFunction ) &&  ( lhs.mImpl->mObjectPointer == rhs.mImpl->mObjectPointer );
-  }
-  else
-  {
-    // check if it the same C function or a static member function
-    return ( lhs.mFunction == rhs.mFunction );
-  }
+  mFunction = nullptr;
 }
 
-} // namespace DALI
+} // namespace Dali