has many fetch progress

This commit is contained in:
Sascha Kühl
2025-02-18 16:19:48 +01:00
parent 901d9c071a
commit 784f6e768d
5 changed files with 57 additions and 22 deletions
+10 -2
View File
@@ -3,6 +3,8 @@
#include "matador/utils/identifier.hpp"
#include "matador/object/primary_key_resolver.hpp"
#include <memory>
namespace matador::object {
@@ -10,11 +12,13 @@ template <typename Type>
class object_ptr {
public:
object_ptr() = default;
object_ptr(Type *obj) : ptr_(obj) {}
explicit object_ptr(Type *obj)
: ptr_(obj)
, pk_(primary_key_resolver::resolve_object(*obj).pk) {}
explicit object_ptr(std::shared_ptr<Type> obj) : ptr_(obj) {}
object_ptr(const object_ptr &other) : ptr_(other.ptr_) {}
object_ptr(object_ptr &&other) noexcept : ptr_(std::move(other.ptr_)) {}
object_ptr &operator=(const object_ptr &other) = default;
object_ptr &operator=(const object_ptr &other) = default;
object_ptr &operator=(object_ptr &&other) = default;
using value_type = Type;
@@ -22,6 +26,10 @@ public:
Type& operator*() const { return *ptr_; }
[[nodiscard]] bool empty() const { return ptr_ == nullptr; }
void reset(Type *obj) {
ptr_.reset(obj);
pk_ = primary_key_resolver::resolve_object(*obj).pk;
}
Type* get() { return ptr_.get(); }
const Type* get() const { return ptr_.get(); }