19#ifndef CPPREALM_MANAGED_SET_HPP
20#define CPPRALM_MANAGED_SET_HPP
22#include <cpprealm/macros.hpp>
23#include <cpprealm/notifications.hpp>
24#include <cpprealm/observation.hpp>
25#include <cpprealm/types.hpp>
32 구조체 managed<std:: 설정하다<T>, std::enable_if_t<internal::type_info::is_primitive<T>::value>> :
managed_base {
33 사용 managed<std:: 설정하다<T>>::managed_base:: 연산자=;
40 차등 유형
사용 = std::ptrdiff_t;
43 iterator_category = std::
forward_iterator_tag ;
45 bool 연산자!=(
const iterator& other)
const
47 return !(*
this == other);
50 bool 연산자==(
const iterator& other)
const
52 return (m_parent == other.m_parent) && (m_i == other.m_i);
55 T 연산자*()
const noException
58 return deserialize<T>(s.get_any(m_i));
61 iterator& operator++()
67 const iterator& operator++(
int i)
73 템플릿<
typename,
typename>
76 iterator(
size_t i,
관리되는<std::set<T>>* parent)
77 : m_i(i), m_parent(parent)
85 return iterator(0,
this);
90 return iterator(size(),
this);
92 [[nodiscard]] std:: 설정하다<T> fetch()
const {
94 auto ret = std::set<T>();
95 for(
size_t i = 0; i < 설정하다.size(); i++) {
96 ret.insert(deserialize<T>(set.get_any(i)));
102 auto set = std::make_shared<realm::internal::bridge::set>(*m_realm, *m_obj, m_key);
104 <realm::collection_callback_wrapper>std::make_shared(
107 token.m_realm = *m_realm;
112 무효 지우기(
const iterator& it)
114 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
115 설정하다. 제거(serialize(*it));
118 std::pair<iterator, bool> insert(
const T& v)
120 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
121 만약 constexpr (internal::type_info::MixedPersistableConcept<T>::value) {
122 std::pair<size_t, bool> res = 설정하다.insert(serialize<T>(v));
123 return std::pair<iterator, bool>(iterator(res.first,
this), res.second);
125 std::pair<size_t, bool> res = 설정하다.insert(v);
126 return std::pair<iterator, bool>(iterator(res.first,
this), res.second);
130 iterator insert(
const iterator&,
const T& v)
132 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
133 std::pair<size_t, bool> res = 설정하다.insert(v);
134 return iterator(res.first,
this);
139 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
140 size_t idx = 설정하다.find(serialize(v));
141 if (idx == 영역::not_in_collection)
142 return iterator(size(),
this);
143 return iterator(idx,
this);
146 internal::bridge::set(*m_realm, *m_obj, m_key).remove_all();
151 return internal::bridge:: 설정하다(*m_realm, *m_obj, m_key).size();
156 managed(
const managed&) =
delete;
157 managed(managed &&) =
삭제;
158 managed& 연산자=(
const managed&) =
삭제;
159 managed& operator=(managed&&) =
delete;
160 템플릿<
typename,
typename>
166 사용 managed<std:: 설정하다<T*>>::managed_base:: 연산자=;
173 차등 유형
사용 = std::ptrdiff_t;
176 iterator_category = std::
forward_iterator_tag ;
178 bool 연산자!=(
const iterator& other)
const
180 return !(*
this == other);
183 bool 연산자==(
const iterator& other)
const
185 return (m_parent == other.m_parent) && (m_i == other.m_i);
191 managed<T> m(s.get_obj(m_i), *m_parent->m_realm);
192 {std::move(m)}를
반환 합니다.
195 iterator& operator++()
201 const iterator& operator++(
int i)
207 템플릿<
typename,
typename>
210 iterator(
size_t i,
관리되는<std::set<T*>>* parent)
211 : m_i(i), m_parent(parent)
219 return iterator(0,
this);
224 return iterator(size(),
this);
226 [[nodiscard]] std:: 설정하다<T*> fetch()
const {
228 size_t count = s.size();
230 return std:: 설정하다<T*>();
231 auto ret = std::set<T*>();
232 for(
size_t i = 0; i < count; i++) {
233 managed<T> m(s.get_obj(i), *m_realm);
235 자동 할당 = [&m, &v](
자동& 쌍) {
236 (*v).*(std::decay_t<
decltype(pair.first)>::ptr) = (m.*(pair.second)).ttach();
238 auto zipped = internal::zip_tuples(managed<T>:: 스키마.ps, managed<T>::managed_pointers());
239 std:: 적용([&v, &m, &assign](
auto && ...pair) {
249 auto set = std::make_shared<realm::internal::bridge::set>(*m_realm, *m_obj, m_key);
251 <realm::collection_callback_wrapper>std::make_shared(
254 token.m_realm = *m_realm;
259 무효 지우기(
const iterator& it)
261 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
262 set.remove(it.operator*().m_obj.get_key());
265 std::pair<iterator, bool> insert(T* 값)
267 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
268 auto table = m_obj->get_target_table(m_key);
269 internal::bridge::obj m_obj;
270 만약 constexpr (managed<T>:: 스키마.HasPrimaryKeyProperty) {
271 auto pk = (*value).*(managed<T>::schema.primary_key().ptr);
274 m_obj = table.create_object();
276 std:: 적용([&m_obj, &value, 영역 = *m_realm](
auto && ...p) {
277 (접근자<
typename std::decay_t<
decltype(p)>::Result>:: 설정하다(
278 m_obj, m_obj.get_table().get_column_key(p.name), Realm,
279 (*value).*(std::decay_t<
decltype(p)>::ptr)), ...);
280 }, managed<T, 무효>:: 스키마.ps);
281 if (!managed<T>::schema.is_embedded()) {
282 set.insert(m_obj.get_key());
284 std::pair<size_t, bool> res = 설정하다.insert(m_obj.get_key());
285 return std::pair<iterator, bool>(iterator(res.first,
this), res.second);
288 iterator insert(
const iterator&, T* 값)
290 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
291 auto table = m_obj->get_target_table(m_key);
292 internal::bridge::obj m_obj;
293 만약 constexpr (managed<T>:: 스키마.HasPrimaryKeyProperty) {
294 auto pk = (*value).*(managed<T>::schema.primary_key().ptr);
297 m_obj = table.create_object();
299 std:: 적용([&m_obj, &value, 영역 = *m_realm](
auto && ...p) {
300 (접근자<
typename std::decay_t<
decltype(p)>::Result>:: 설정하다(
301 m_obj, m_obj.get_table().get_column_key(p.name), Realm,
302 (*value).*(std::decay_t<
decltype(p)>::ptr)), ...);
303 }, managed<T, 무효>:: 스키마.ps);
304 std::pair<size_t, bool> res = 설정하다.insert(m_obj.get_key());
305 return iterator(res.first,
this);
308 std::pair<iterator, bool> insert(
const managed<T>& value)
310 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
311 std::pair<size_t, bool> res = 설정하다.insert(value.m_obj.get_key());
312 return std::pair<iterator, bool>(iterator(res.first,
this), res.second);
316 iterator insert(
const iterator&,
const managed<T>& value)
318 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
319 std::pair<size_t, bool> res = 설정하다.insert(value.m_obj.get_key());
320 return iterator(res.first,
this);
323 std::pair<iterator, bool> insert(
const managed<T*>& value)
325 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
326 std::pair<size_t, bool> res = 설정하다.insert(value.m_obj.get_key());
327 return std::pair<iterator, bool>(iterator(res.first,
this), res.second);
331 iterator insert(
const iterator&,
const managed<T*>& value)
333 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
334 std::pair<size_t, bool> res = 설정하다.insert(value.m_obj.get_key());
335 return iterator(res.first,
this);
338 iterator find(
const managed<T>& v)
340 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
341 size_t idx = 설정하다.find(v.m_obj.get_key());
342 if (idx == 영역::not_in_collection)
343 return iterator(size(),
this);
344 return iterator(idx,
this);
347 반복자 find(
const managed<T*>& v)
349 auto 설정하다 = internal::bridge:: 설정하다(*m_realm, *m_obj, m_key);
350 size_t idx = 설정하다.find(v.m_obj->get_key());
351 if (idx == 영역::not_in_collection)
352 return iterator(size(),
this);
353 return iterator(idx,
this);
356 internal::bridge::set(*m_realm, *m_obj, m_key).remove_all();
361 return internal::bridge:: 설정하다(*m_realm, *m_obj, m_key).size();
366 managed(
const managed&) =
delete;
367 managed(managed &&) =
삭제;
368 managed& 연산자=(
const managed&) =
삭제;
369 managed& operator=(managed&&) =
delete;
370 템플릿<
typename,
typename>