X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fobject%2Fbase-handle.h;h=e275473fa41cc740358284fc53731779226a029f;hb=b8153c3ab592e6ebeaeebf31137538f972c27653;hp=c4720c65642e8bb32ab6f3dcfcc74b4330512521;hpb=da2e24f853c2f463df2f4b743c3b2241a537cefd;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/object/base-handle.h b/dali/public-api/object/base-handle.h index c4720c6..e275473 100644 --- a/dali/public-api/object/base-handle.h +++ b/dali/public-api/object/base-handle.h @@ -1,8 +1,8 @@ -#ifndef __DALI_BASE_HANDLE_H__ -#define __DALI_BASE_HANDLE_H__ +#ifndef DALI_BASE_HANDLE_H +#define DALI_BASE_HANDLE_H /* - * 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. @@ -56,10 +56,9 @@ class TypeInfo; * * @SINCE_1_0.0 */ -class DALI_IMPORT_API BaseHandle +class DALI_CORE_API BaseHandle { public: - /** * @brief This constructor is used by Dali New() methods. * @@ -111,6 +110,23 @@ public: BaseHandle& operator=(const BaseHandle& rhs); /** + * @brief Move constructor. + * + * @SINCE_1_9.22 + * @param[in] rhs A reference to the moved handle + */ + BaseHandle(BaseHandle&& rhs); + + /** + * @brief Move assignment operator. + * + * @SINCE_1_9.22 + * @param[in] rhs A reference to the moved handle + * @return A reference to this handle + */ + BaseHandle& operator=(BaseHandle&& rhs); + + /** * @brief Connects a void() functor to a specified signal. * * @SINCE_1_0.0 @@ -120,10 +136,10 @@ public: * @return True if the signal was available * @pre The signal must be available in this object. */ - template - bool ConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor ) + template + bool ConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor) { - return DoConnectSignal( connectionTracker, signalName, FunctorDelegate::New( functor ) ); + return DoConnectSignal(connectionTracker, signalName, FunctorDelegate::New(functor)); } /** @@ -158,13 +174,12 @@ public: * @brief Returns the type info for the Handle. * * @SINCE_1_0.0 - * @param[in] info The type information - * @return The type info + * @param[out] info The type information + * @return true if the type info exists */ bool GetTypeInfo(Dali::TypeInfo& info) const; public: - // BaseHandle accessors /** @@ -190,27 +205,21 @@ public: /** * @brief Resets the handle. * - * If no other handle copies exist, the internal Dali resouce will be deleted. + * If no other handle copies exist, the internal Dali resource will be deleted. * Calling this is not required i.e. it will happen automatically when a Dali::BaseHandle is destroyed. * @SINCE_1_0.0 */ void Reset(); - // BaseHandle comparisons - This is a variation of the safe bool idiom - - /** - * @brief Pointer-to-member type. - * Objects can be implicitly converted to this for validity checks. - */ - typedef void (BaseHandle::*BooleanType)() const; + // BaseHandle comparisons /** - * @brief Converts an handle to a BooleanType. + * @brief Converts an handle to a bool. * * This is useful for checking whether the handle is empty. * @SINCE_1_0.0 */ - operator BooleanType() const; + explicit operator bool() const; /** * @brief Equality operator overload. @@ -239,7 +248,6 @@ public: Dali::RefObject* GetObjectPtr() const; private: - /** * @brief Not intended for application developers. * @@ -249,23 +257,10 @@ private: * @param[in] functorDelegate A newly allocated functor delegate (takes ownership) * @return True if the signal was available */ - bool DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate ); - -protected: - - /** - * @brief Used by the safe bool idiom. - * - * The safe bool idiom basically provides a Boolean test for classes. It validates objects - * in a boolean context without the usual harmful side effects. - * @SINCE_1_0.0 - */ - void ThisIsSaferThanReturningVoidStar() const {} + bool DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate); private: - IntrusivePtr mObjectHandle; ///< Object this handle points at. - }; /** @@ -276,14 +271,12 @@ private: * @return Handle pointer to either a valid deriving handle or an uninitialized handle * @pre The BaseHandle has been initialized. */ -template< class T > -inline T DownCast( BaseHandle handle ) +template +inline T DownCast(BaseHandle handle) { - return T::DownCast( handle ); + return T::DownCast(handle); } -// See also BaseHandle::BooleanType() conversion - /** * @brief Equality operator. * @SINCE_1_0.0 @@ -291,10 +284,9 @@ inline T DownCast( BaseHandle handle ) * @param[in] rhs A reference to compare to * @return True if the handle handles point to the same Dali resource, or if both are NULL */ -template +template inline bool operator==(const BaseHandle& lhs, const T& rhs) { - // We depart from the safe bool idiom to allow Dali::BaseHandle derived classes to be compared return lhs == static_cast(rhs); } @@ -305,10 +297,9 @@ inline bool operator==(const BaseHandle& lhs, const T& rhs) * @param[in] rhs A reference to compare to * @return True if the handle handles point to the different Dali resources */ -template +template inline bool operator!=(const BaseHandle& lhs, const T& rhs) { - // We depart from the safe bool idiom to allow Dali::BaseHandle derived classes to be compared return lhs != static_cast(rhs); } @@ -329,4 +320,4 @@ inline bool operator<(const BaseHandle& lhs, const BaseHandle& rhs) */ } // namespace Dali -#endif // __DALI_BASE_HANDLE_H__ +#endif // DALI_BASE_HANDLE_H