19#ifndef CPPREALM_BRIDGE_LINK_HPP
20#define CPPRALM_BRIDGE_LINK_HPP
22#include <cpprealm/accessors.hpp>
23#include <cpprealm/macros.hpp>
24#include <cpprealm/rbool.hpp>
26#include <cpprealm/internal/type_info.hpp>
29 템플릿 <
typename,
typename>
36 managed<T> m(m_obj->is_null(m_key) ? *m_obj : m_obj->get_linking_object(m_key), *m_realm);
37 자동 할당 = [&m, &v](
자동& 쌍) {
38 (*v).*(std::decay_t<
decltype(pair.first)>::ptr) = (m.*(pair.second)).ttach();
41 std:: 적용([&v, &m, &assign](
auto && ...pair) {
48 명시적 ref_type(
managed<T>&& value) : m_managed(std::move(value)) { }
64 if ( this->m_managed.m_realm != *rhs.m_realm) {
67 return this->m_managed.m_obj.get_key() == rhs.m_obj->get_key();
70 if (This->m_managed.m_realm != rhs.m_realm) {
73 return this->m_managed.m_obj.get_table() == rhs.m_obj.get_table() &&
74 this->m_managed.m_obj.get_key() == rhs.m_obj.get_key();
76 bool 연산자 ==(
const ref_type& rhs)
const {
77 if ( this->m_managed.m_realm != rhs.m_managed.m_realm) {
80 return this->m_managed.m_obj.get_table() == rhs.m_managed.m_obj.get_table() &&
81 this->m_managed.m_obj.get_key() == rhs.m_managed.m_obj.get_key();
84 return ! this-> 연산자==(rhs);
87 return ! this-> 연산자==(rhs);
89 bool 연산자 !=(
const ref_type& rhs)
const {
90 return ! this-> 연산자==(rhs);
95 ref_type 연산자 ->()
const {
96 if (This->m_rbool_query) {
97 this->m_rbool_query->add_link_chain(m_key);
100 return ref_type(
managed<T>(m_obj->get_linking_object(m_key), *m_realm));
103 if (m_obj && m_key) {
104 return !m_obj->is_null(m_key);
108 managed &operator=(
const managed<T>& obj) {
109 m_obj->set(m_key, obj.m_obj.get_key());
112 managed &operator=(
const managed<T*> &obj) {
113 m_obj->set(m_key, obj.m_obj->get_key());
116 managed &operator=(std::nullptr_t) {
117 m_obj->set_null(m_key);
120 managed &operator=(T* o) {
121 자동 테이블 = m_realm->table_for_object_type(managed<T>:: 스키마.name);
122 internal::bridge::obj obj;
124 m_obj->set_null(m_key);
126 }
other if constexpr (managed::<T> 스키마.HasPrimaryKeyProperty ) {
127 auto pk = (*o).*(managed<T>:: 스키마.primary_key().ptr);
129 m_obj->set(m_key, obj.get_key());
130 }
other if (managed::<T> 스키마.is_embedded ()) {
131 obj = m_obj->create_and_set_linking_object(m_key);
133 obj = table.create_object();
134 m_obj->set(m_key, obj.get_key());
137 std:: 적용([&obj, &o, 영역 = *m_realm](
auto && ...p) {
138 (접근자<
typename std::decay_t<
decltype(p)>::Result>:: 설정하다(
139 obj, obj.get_table().get_column_key(p.name), 영역, (*o).*(std::decay_t<
decltype(p)>::ptr)
141 }, managed<T>:: 스키마.ps);
145 rbool 연산자 ==(std::nullptr_t)
const {
147 return m_rbool_query->link_equal(m_key, std::nullopt);
149 return !m_obj->get_linked_object(m_key).is_valid();
151 rbool 연산자 ==(
const managed<T>& rhs)
const {
153 return m_rbool_query->link_equal(m_key, rhs.m_obj);
155 if (* this->m_realm != rhs.m_realm)
157 return m_obj->get_linking_object(m_key).get_key() == rhs.m_obj.get_key();
160 rbool 연산자 ==(
const managed<T*>& rhs)
const {
162 return m_rbool_query->link_equal(m_key, *rhs.m_obj);
164 if (* this->m_realm != *rhs.m_realm)
166 return m_obj->get_linking_object(m_key).get_key() == rhs.m_obj->get_key();
169 rbool 연산자 !=(std::nullptr_t)
const {
171 return m_rbool_query->link_not_equal(m_key, std::nullopt);
173 return m_obj->get_linking_object(m_key).is_valid();
175 rbool 연산자 !=(
const managed<T>& rhs)
const {
177 return m_rbool_query->link_not_equal(m_key, rhs.m_obj);
179 return m_obj->get_linking_object(m_key).is_valid();
182 rbool 연산자 !=(
const managed<T*>& rhs)
const {
184 return m_rbool_query->link_not_equal(m_key, *rhs.m_obj);
186 return m_obj->get_linking_object(m_key).is_valid();
191 템플릿<
typename,
typename>