aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/SelfResolvable.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/common/SelfResolvable.h')
-rw-r--r--include/cru/common/SelfResolvable.h14
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: