diff --git a/src/kiwano/base/RefPtr.h b/src/kiwano/base/RefPtr.h index e684d05e..93a184f5 100644 --- a/src/kiwano/base/RefPtr.h +++ b/src/kiwano/base/RefPtr.h @@ -26,8 +26,8 @@ namespace kiwano { /// \~chinese -/// @brief 默认的智能指针引用计数代理 -struct DefaultRefPtrRefProxy +/// @brief 默认的智能指针引用计数策略 +struct DefaultRefPtrPolicy { static inline void Retain(RefObject* ptr) { @@ -45,7 +45,7 @@ struct DefaultRefPtrRefProxy /// \~chinese /// @brief 引用计数对象智能指针 template -using RefPtr = RefBasePtr<_Ty, DefaultRefPtrRefProxy>; +using RefPtr = RefBasePtr<_Ty, DefaultRefPtrPolicy>; /// \~chinese /// @brief 构造引用计数对象智能指针 diff --git a/src/kiwano/core/RefBasePtr.hpp b/src/kiwano/core/RefBasePtr.hpp index 2f8650df..cc049a06 100644 --- a/src/kiwano/core/RefBasePtr.hpp +++ b/src/kiwano/core/RefBasePtr.hpp @@ -30,8 +30,8 @@ namespace kiwano * \~chinese * @brief 引用计数智能指针 */ -template -class RefBasePtr +template +class RefBasePtr : protected _RefPolicy { public: using value_type = _Ty; @@ -53,13 +53,13 @@ public: RefBasePtr(pointer_type p) : ptr_(p) { - _ProxyTy::Retain(ptr_); + _RefPolicy::Retain(ptr_); } RefBasePtr(const RefBasePtr& other) : ptr_(other.ptr_) { - _ProxyTy::Retain(ptr_); + _RefPolicy::Retain(ptr_); } RefBasePtr(RefBasePtr&& other) noexcept @@ -74,10 +74,10 @@ public: } template ::value, int>::type = 0> - RefBasePtr(const RefBasePtr<_UTy, _ProxyTy>& other) + RefBasePtr(const RefBasePtr<_UTy, _RefPolicy>& other) { ptr_ = dynamic_cast(other.Get()); - _ProxyTy::Retain(ptr_); + _RefPolicy::Retain(ptr_); } inline pointer_type Get() const noexcept @@ -165,7 +165,7 @@ public: } template ::value, int>::type = 0> - inline RefBasePtr& operator=(const RefBasePtr<_UTy, _ProxyTy>& other) + inline RefBasePtr& operator=(const RefBasePtr<_UTy, _RefPolicy>& other) { if (other.Get() != ptr_) RefBasePtr(dynamic_cast(other.Get())).Swap(*this); @@ -181,7 +181,7 @@ public: private: void Tidy() { - _ProxyTy::Release(ptr_); + _RefPolicy::Release(ptr_); ptr_ = nullptr; } @@ -189,76 +189,76 @@ private: pointer_type ptr_; }; -template -inline bool operator==(const RefBasePtr<_Ty, _ProxyTy>& lhs, const RefBasePtr<_UTy, _ProxyTy>& rhs) noexcept +template +inline bool operator==(const RefBasePtr<_Ty, _RefPolicy>& lhs, const RefBasePtr<_UTy, _RefPolicy>& rhs) noexcept { return lhs.Get() == rhs.Get(); } -template -inline bool operator==(const RefBasePtr<_Ty, _ProxyTy>& lhs, _Ty* rhs) noexcept +template +inline bool operator==(const RefBasePtr<_Ty, _RefPolicy>& lhs, _Ty* rhs) noexcept { return lhs.Get() == rhs; } -template -inline bool operator==(_Ty* lhs, const RefBasePtr<_Ty, _ProxyTy>& rhs) noexcept +template +inline bool operator==(_Ty* lhs, const RefBasePtr<_Ty, _RefPolicy>& rhs) noexcept { return lhs == rhs.Get(); } -template -inline bool operator==(const RefBasePtr<_Ty, _ProxyTy>& lhs, std::nullptr_t) noexcept +template +inline bool operator==(const RefBasePtr<_Ty, _RefPolicy>& lhs, std::nullptr_t) noexcept { return !static_cast(lhs); } -template -inline bool operator==(std::nullptr_t, const RefBasePtr<_Ty, _ProxyTy>& rhs) noexcept +template +inline bool operator==(std::nullptr_t, const RefBasePtr<_Ty, _RefPolicy>& rhs) noexcept { return !static_cast(rhs); } -template -inline bool operator!=(const RefBasePtr<_Ty, _ProxyTy>& lhs, const RefBasePtr<_UTy, _ProxyTy>& rhs) noexcept +template +inline bool operator!=(const RefBasePtr<_Ty, _RefPolicy>& lhs, const RefBasePtr<_UTy, _RefPolicy>& rhs) noexcept { return !(lhs == rhs); } -template -inline bool operator!=(const RefBasePtr<_Ty, _ProxyTy>& lhs, _Ty* rhs) noexcept +template +inline bool operator!=(const RefBasePtr<_Ty, _RefPolicy>& lhs, _Ty* rhs) noexcept { return lhs.Get() != rhs; } -template -inline bool operator!=(_Ty* lhs, const RefBasePtr<_Ty, _ProxyTy>& rhs) noexcept +template +inline bool operator!=(_Ty* lhs, const RefBasePtr<_Ty, _RefPolicy>& rhs) noexcept { return lhs != rhs.Get(); } -template -inline bool operator!=(const RefBasePtr<_Ty, _ProxyTy>& lhs, std::nullptr_t) noexcept +template +inline bool operator!=(const RefBasePtr<_Ty, _RefPolicy>& lhs, std::nullptr_t) noexcept { return static_cast(lhs); } -template -inline bool operator!=(std::nullptr_t, const RefBasePtr<_Ty, _ProxyTy>& rhs) noexcept +template +inline bool operator!=(std::nullptr_t, const RefBasePtr<_Ty, _RefPolicy>& rhs) noexcept { return static_cast(rhs); } -template -inline bool operator<(const RefBasePtr<_Ty, _ProxyTy>& lhs, const RefBasePtr<_UTy, _ProxyTy>& rhs) noexcept +template +inline bool operator<(const RefBasePtr<_Ty, _RefPolicy>& lhs, const RefBasePtr<_UTy, _RefPolicy>& rhs) noexcept { return lhs.Get() < rhs.Get(); } // template class cannot specialize std::swap, // so implement a swap function in kiwano namespace -template -inline void swap(RefBasePtr<_Ty, _ProxyTy>& lhs, RefBasePtr<_Ty, _ProxyTy>& rhs) noexcept +template +inline void swap(RefBasePtr<_Ty, _RefPolicy>& lhs, RefBasePtr<_Ty, _RefPolicy>& rhs) noexcept { lhs.Swap(rhs); } diff --git a/src/kiwano/platform/win32/ComPtr.hpp b/src/kiwano/platform/win32/ComPtr.hpp index c019b950..72879900 100644 --- a/src/kiwano/platform/win32/ComPtr.hpp +++ b/src/kiwano/platform/win32/ComPtr.hpp @@ -26,7 +26,7 @@ namespace kiwano { -struct ComPtrProxy +struct ComPtrPolicy { static inline void Retain(IUnknown* ptr) { @@ -43,6 +43,6 @@ struct ComPtrProxy // ComPtr<> is a smart pointer for COM template ::value, int>::type> -using ComPtr = RefBasePtr<_Ty, ComPtrProxy>; +using ComPtr = RefBasePtr<_Ty, ComPtrPolicy>; } // namespace kiwano diff --git a/src/kiwano/utils/Logger.h b/src/kiwano/utils/Logger.h index 7e363831..443ea54a 100644 --- a/src/kiwano/utils/Logger.h +++ b/src/kiwano/utils/Logger.h @@ -112,7 +112,7 @@ public: * \~chinese * @brief 日志流缓冲 */ -class LogBuffer : public std::streambuf +class KGE_API LogBuffer : public std::streambuf { public: LogBuffer(size_t buffer_size);