From cf436157c81f0339b0da2ef0b1eb366f8bcb27d2 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 1 Jan 2024 20:18:57 +0800 Subject: [PATCH] Improve self resolvable. --- include/cru/common/SelfResolvable.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/cru/common/SelfResolvable.h b/include/cru/common/SelfResolvable.h index c0ca9326..ce5b1628 100644 --- a/include/cru/common/SelfResolvable.h +++ b/include/cru/common/SelfResolvable.h @@ -28,6 +28,11 @@ class ObjectResolver { return *this->shared_object_ptr_; } + /** + * @remarks So this class can be used as a functor. + */ + T* operator()() const { return Resolve(); } + private: void SetResolvedObject(T* o) { assert(IsValid()); @@ -38,6 +43,15 @@ class ObjectResolver { std::shared_ptr shared_object_ptr_; }; +/** + * @remarks + * This class is not copyable and movable since subclass is polymorphic and + * copying is then nonsense. However, you can even delete move capability in + * subclass because it may also be nonsense for subclass. The move capability is + * optional. + * + * Whether this class needs to be thread-safe still has to be considered. + */ template class SelfResolvable { public: