has many fetch progress
This commit is contained in:
@@ -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(); }
|
||||
|
||||
Reference in New Issue
Block a user