X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fcommon%2Fintrusive-ptr.h;h=02e5bad363e41579d80cd96d10bcb1597204b363;hb=25c7ca5bc0a79e7aae41afec7796b8f9b0886e61;hp=cabf58d7fc49ca16827c8ba8d13890d0ec2c4750;hpb=e424c13b4dd452d36ce86a29e1e3c6943cd07714;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/common/intrusive-ptr.h b/dali/public-api/common/intrusive-ptr.h index cabf58d..02e5bad 100644 --- a/dali/public-api/common/intrusive-ptr.h +++ b/dali/public-api/common/intrusive-ptr.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTRUSIVE_PTR_H__ -#define __DALI_INTRUSIVE_PTR_H__ +#ifndef DALI_INTRUSIVE_PTR_H +#define DALI_INTRUSIVE_PTR_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -23,12 +23,17 @@ namespace Dali { +/** + * @addtogroup dali_core_common + * @{ + */ /** - * @brief Templated intrusive pointer class + * @brief Templated intrusive pointer class. * - * Uses the Dali:Refobject type supply actual reference counting - * The object is responsible for destroying itself + * Uses the Dali:RefObject type with actual reference counting. + * The object is responsible for destroying itself. + * @SINCE_1_0.0 */ template class IntrusivePtr @@ -38,13 +43,15 @@ public: /** * @brief Standard constructor to unassigned object. + * @SINCE_1_0.0 */ IntrusivePtr() : mPtr( 0 ) {} /** * @brief Constructor to attach existing object. * - * @param p pointer to object, + * @SINCE_1_0.0 + * @param[in] p Pointer to object */ IntrusivePtr( T* p ) : mPtr( p ) { @@ -57,8 +64,9 @@ public: /** * @brief Copy constructor. * - * @param rhs const reference to an IntrusivePtr - * @tparam U reference counter object type + * @SINCE_1_0.0 + * @param[in] rhs Const reference to an IntrusivePtr + * @tparam U Reference counter object type */ template IntrusivePtr( IntrusivePtr const& rhs ) : mPtr( rhs.Get() ) @@ -71,6 +79,8 @@ public: /** * @brief Copy constructor. + * @SINCE_1_0.0 + * @param[in] rhs Const reference to an IntrusivePtr */ IntrusivePtr( IntrusivePtr const& rhs ) : mPtr( rhs.mPtr ) { @@ -83,7 +93,8 @@ public: /** * @brief Destructor. * - * Object will self-destruct if reference count is zero + * Object will self-destruct if reference count is zero. + * @SINCE_1_0.0 */ ~IntrusivePtr() { @@ -94,9 +105,10 @@ public: } /** - * @brief Get pointer to reference counted object. + * @brief Gets pointer to reference counted object. * - * @return pointer to reference counted object + * @SINCE_1_0.0 + * @return Pointer to reference counted object */ T* Get() const { @@ -106,7 +118,8 @@ public: /** * @brief Pointer operator override. * - * @return pointer to reference counted object + * @SINCE_1_0.0 + * @return Pointer to reference counted object */ T* operator->() const { @@ -116,7 +129,8 @@ public: /** * @brief Dereference operator override. * - * @return reference to reference counted object + * @SINCE_1_0.0 + * @return Reference to reference counted object */ T& operator*() const { @@ -126,8 +140,9 @@ public: /** * @brief Assignment operator. * - * @param rhs const reference to intrusive pointer - * @return reference to reference counted object + * @SINCE_1_0.0 + * @param rhs Const reference to intrusive pointer + * @return Reference to reference counted object */ IntrusivePtr& operator=( IntrusivePtr const& rhs ) { @@ -138,8 +153,9 @@ public: /** * @brief Assignment operator. * - * @param rhs pointer to object to wrap - * @return A reference to this object + * @SINCE_1_0.0 + * @param rhs Pointer to object to wrap + * @return A Reference to this object */ IntrusivePtr& operator=( T* rhs ) { @@ -149,6 +165,7 @@ public: /** * @brief Reset intrusive pointer. + * @SINCE_1_0.0 */ void Reset() { @@ -158,7 +175,8 @@ public: /** * @brief Reset intrusive pointer with reference counted object. * - * @param rhs pointer to object + * @SINCE_1_0.0 + * @param[in] rhs Pointer to object */ void Reset( T* rhs ) { @@ -178,21 +196,38 @@ public: * @brief Converts an object handle to a BooleanType. * * This is useful for checking whether the handle is NULL. + * @SINCE_1_0.0 */ operator BooleanType() const { return mPtr ? &IntrusivePtr::ThisIsSaferThanReturningVoidStar : 0; } + /** + * @brief Detaches pointer from intrusive ptr counting. + * + * Use with care. + * @SINCE_1_0.0 + * @return Pointer to reference counted object + */ + T* Detach() + { + T* ptr = mPtr; + mPtr = 0; + return ptr; + } + private: /** * @brief Used by the safe bool idiom. + * @SINCE_1_0.0 */ void ThisIsSaferThanReturningVoidStar() const {} /** - * @brief Internal swap function + * @brief Internal swap function. + * @SINCE_1_0.0 */ void Swap( IntrusivePtr& rhs ) { @@ -207,9 +242,10 @@ private: /** * @brief Comparison overrides of objects wrapped by intrusive pointers. * - * @param lhs intrusive pointer to compare with - * @param rhs intrusive pointer to compare against - * @return true if the pointers point at the same object + * @SINCE_1_0.0 + * @param[in] lhs Intrusive pointer to compare with + * @param[in] rhs Intrusive pointer to compare against + * @return True if the pointers point at the same object */ template inline bool operator==( IntrusivePtrconst& lhs, IntrusivePtrconst& rhs ) @@ -220,9 +256,10 @@ inline bool operator==( IntrusivePtrconst& lhs, IntrusivePtrconst& rhs ) /** * @brief Comparison overrides of objects wrapped by intrusive pointers. * - * @param lhs intrusive pointer to compare with - * @param rhs intrusive pointer to compare against - * @return true if the pointers point at different objects + * @SINCE_1_0.0 + * @param[in] lhs Intrusive pointer to compare with + * @param[in] rhs Intrusive pointer to compare against + * @return True if the pointers point at different objects */ template inline bool operator!=( IntrusivePtrconst& lhs, IntrusivePtrconst &rhs) @@ -231,11 +268,12 @@ inline bool operator!=( IntrusivePtrconst& lhs, IntrusivePtrconst &rhs) } /** - * @brief Comparison overrides of objects wrapped by intrusive pointers + * @brief Comparison overrides of objects wrapped by intrusive pointers. * - * @param lhs intrusive pointer to compare with - * @param rhs object to compare against - * @return true if the intrusive pointer points at the specified object + * @SINCE_1_0.0 + * @param[in] lhs Intrusive pointer to compare with + * @param[in] rhs Object to compare against + * @return True if the intrusive pointer points at the specified object */ template inline bool operator==( IntrusivePtrconst& lhs, U* rhs ) @@ -246,9 +284,10 @@ inline bool operator==( IntrusivePtrconst& lhs, U* rhs ) /** * @brief Comparison overrides of objects wrapped by intrusive pointers. * - * @param lhs intrusive pointer to compare with - * @param rhs intrusive pointer to compare against - * @return true if the intrusive pointer doesn't point at the specified object + * @SINCE_1_0.0 + * @param[in] lhs Intrusive pointer to compare with + * @param[in] rhs Intrusive pointer to compare against + * @return True if the intrusive pointer doesn't point at the specified object */ template inline bool operator!=( IntrusivePtrconst& lhs, U* rhs ) @@ -257,11 +296,12 @@ inline bool operator!=( IntrusivePtrconst& lhs, U* rhs ) } /** - * @brief Comparison overrides of objects wrapped by intrusive pointers + * @brief Comparison overrides of objects wrapped by intrusive pointers. * - * @param lhs object to compare with - * @param rhs intrusive pointer to compare against - * @return true if the intrusive pointer points at the specified object + * @SINCE_1_0.0 + * @param[in] lhs Object to compare with + * @param[in] rhs Intrusive pointer to compare against + * @return True if the intrusive pointer points at the specified object */ template inline bool operator==( T* lhs, IntrusivePtrconst& rhs ) @@ -270,11 +310,12 @@ inline bool operator==( T* lhs, IntrusivePtrconst& rhs ) } /** - * @brief Comparison overrides of objects wrapped by intrusive pointers + * @brief Comparison overrides of objects wrapped by intrusive pointers. * - * @param lhs object to compare with - * @param rhs intrusive pointer to compare against - * @return true if the intrusive pointer doesn't point at the specified object + * @SINCE_1_0.0 + * @param[in] lhs Object to compare with + * @param[in] rhs Intrusive pointer to compare against + * @return True if the intrusive pointer doesn't point at the specified object */ template inline bool operator!=( T* lhs, IntrusivePtrconst& rhs ) @@ -282,6 +323,9 @@ inline bool operator!=( T* lhs, IntrusivePtrconst& rhs ) return lhs != rhs.Get(); } +/** + * @} + */ } // namespace Dali -#endif /* __DALI_INTRUSIVE_PTR_H__ */ +#endif // DALI_INTRUSIVE_PTR_H