#ifndef QUERY_FOREIGN_HPP #define QUERY_FOREIGN_HPP #include "matador/utils/identifiable.hpp" namespace matador::sql { template < class Type > class foreign : public utils::identifiable { public: foreign() = default; explicit foreign(Type *obj) : obj_(obj) {} void reset(const utils::identifier &id) override { id_ = id; } [[nodiscard]] bool has_primary_key() const override { return true; } [[nodiscard]] const utils::identifier &primary_key() const override { return id_; } utils::identifier &primary_key() override { return id_; } [[nodiscard]] utils::identifier create_identifier() const override { return {id_}; } Type* operator->() { return obj_.get(); } const Type* operator->() const { return obj_.get(); } Type& operator*() { return *obj_; } const Type& operator*() const { return *obj_; } private: utils::identifier id_; std::unique_ptr obj_; }; template [[maybe_unused]] foreign make_foreign(Args&&... args) { return foreign(new Type(std::forward(args)...)); } } #endif //QUERY_FOREIGN_HPP