diff options
author | crupest <crupest@outlook.com> | 2024-01-01 20:18:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2024-01-01 20:18:57 +0800 |
commit | cf436157c81f0339b0da2ef0b1eb366f8bcb27d2 (patch) | |
tree | 9f5a9a3cf4d7bb60d14b534ebf6d8685b1006090 /include/cru | |
parent | c4641cadc0070b38f4efec740023a9300a7602d1 (diff) | |
download | cru-cf436157c81f0339b0da2ef0b1eb366f8bcb27d2.tar.gz cru-cf436157c81f0339b0da2ef0b1eb366f8bcb27d2.tar.bz2 cru-cf436157c81f0339b0da2ef0b1eb366f8bcb27d2.zip |
Improve self resolvable.
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/common/SelfResolvable.h | 14 |
1 files changed, 14 insertions, 0 deletions
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<T*> 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 <typename T> class SelfResolvable { public: |