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(); }
|
||||
|
||||
@@ -35,6 +35,12 @@ public:
|
||||
return primary_key_info_;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
static primary_key_info resolve_object(const Type& obj) {
|
||||
primary_key_resolver resolver;
|
||||
return resolver.resolve(obj);
|
||||
}
|
||||
|
||||
template < class Type >
|
||||
void on_primary_key(const char *id, Type &pk, std::enable_if_t<std::is_integral_v<Type> && !std::is_same_v<bool, Type>>* = nullptr) {
|
||||
primary_key_info_.pk_column_name = id;
|
||||
|
||||
Reference in New Issue
Block a user