From 6e6836e7885259b731651ae172bd6313edae7cdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roman=20Smr=C5=BE?= <roman.smrz@seznam.cz>
Date: Mon, 8 Jan 2024 21:52:29 +0100
Subject: Storage: add storage() accessor to Head<T>

---
 include/erebos/storage.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'include/erebos')

diff --git a/include/erebos/storage.h b/include/erebos/storage.h
index 48bedd7..96a27d4 100644
--- a/include/erebos/storage.h
+++ b/include/erebos/storage.h
@@ -649,6 +649,7 @@ public:
 	UUID id() const { return mid; }
 	const Stored<T> & stored() const { return mstored; }
 	const Ref & ref() const { return mstored.ref(); }
+	const Storage & storage() const { return mstored.ref().storage(); }
 
 	optional<Head<T>> reload() const;
 	std::optional<Head<T>> update(const std::function<Stored<T>(const Stored<T> &)> &) const;
@@ -769,7 +770,7 @@ Head<T> Storage::storeHead(const Stored<T> & val) const
 template<typename T>
 optional<Head<T>> Head<T>::reload() const
 {
-	return ref().storage().template head<T>(id());
+	return storage().template head<T>(id());
 }
 
 template<typename T>
@@ -789,7 +790,7 @@ std::optional<Head<T>> Head<T>::update(const std::function<Stored<T>(const Store
 template<typename T>
 WatchedHead<T> Head<T>::watch(const std::function<void(const Head<T> &)> & watcher) const
 {
-	int wid = stored().ref().storage().watchHead(T::headTypeId, id(), [id = id(), watcher] (const Ref & ref) {
+	int wid = storage().watchHead(T::headTypeId, id(), [id = id(), watcher] (const Ref & ref) {
 		watcher(Head<T>(id, ref));
 	});
 	return WatchedHead<T>(*this, wid);
@@ -808,7 +809,7 @@ template<class T>
 WatchedHead<T>::~WatchedHead()
 {
 	if (watcherId >= 0)
-		Head<T>::stored().ref().storage().unwatchHead(
+		Head<T>::storage().unwatchHead(
 				T::headTypeId, Head<T>::id(), watcherId);
 }
 
-- 
cgit v1.2.3