fixed backend test compilation
This commit is contained in:
@@ -1,16 +1,38 @@
|
||||
#ifndef OBJECT_PTR_HPP
|
||||
#define OBJECT_PTR_HPP
|
||||
|
||||
#include "matador/utils/identifier.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace matador::object {
|
||||
template <typename Type>
|
||||
class object_ptr {
|
||||
public:
|
||||
using value_type = Type;
|
||||
Type* operator->() { return ptr; };
|
||||
Type& operator*() { return *ptr; };
|
||||
object_ptr() = default;
|
||||
object_ptr(Type *obj) : ptr_(obj) {}
|
||||
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=(object_ptr &&other) = default;
|
||||
|
||||
using value_type = Type;
|
||||
Type* operator->() { return ptr_.get(); }
|
||||
Type& operator*() const { return *ptr_; }
|
||||
|
||||
[[nodiscard]] bool empty() const { return ptr_ == nullptr; }
|
||||
|
||||
Type* get() { return ptr_.get(); }
|
||||
const Type* get() const { return ptr_.get(); }
|
||||
operator bool() { return valid(); }
|
||||
bool valid() { return ptr_ != nullptr; }
|
||||
|
||||
[[nodiscard]] const utils::identifier& primary_key() const { return pk_; }
|
||||
void primary_key(const utils::identifier &pk) { pk_ = pk; }
|
||||
private:
|
||||
Type* ptr{nullptr};
|
||||
std::shared_ptr<Type> ptr_{};
|
||||
utils::identifier pk_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user