22#include <cpprealm/accessors.hpp>
23#include <cpprealm/macros.hpp>
24#include <cpprealm/results.hpp>
25#include <cpprealm/scheduler.hpp>
26#include <cpprealm/schema.hpp>
27#include <cpprealm/types.hpp>
29#include <cpprealm/internal/bridge/sync_session.hpp>
30#include <cpprealm/internal/bridge/thread_safe_reference.hpp>
31#include <cpprealm/internal/bridge/sync_session.hpp>
41 using is_Optional = Internal::type_info::is_Optional<T>;
44 템플릿 <
typename class,
typename 속성>
46 템플릿 <auto Ptr,
bool IsPrimaryKey>
50 sync_config
사용 = Internal::bridge::영역::sync_config;
51 db_config
사용 = Internal::bridge::영역::config;
52 using sync_session = Internal::bridge::sync_session;
53 sync_error
사용 = Internal::bridge::sync_error;
55 struct sync_subscription_set;
64 static 인라인 std::vector<internal::bridge::object_schema> 스키마;
68 if (!config.get_schema())
69 config.set_schema(db::schemas);
73 시작_쓰기
무효화 ()
const { m_realm.begin_transaction(); }
74 void commit_write()
const { m_realm.commit_transaction(); }
77 std::invoke_result_t<Fn> 쓰기 (write)(Fn&& fn)
const {
79 만약 constexpr (!std::is_void_v<std::invoke_result_t<Fn>) {
90 using T = std::remove_const_t<U>;
91 static_assert(
sizeof(
managed<T>),
"Must explain schema for T");
92 자동 테이블 = m_realm.table_for_object_type(
managed<std::remove_const_t<T>>::schema.name);
98 m_obj = table.create_object();
101 std:: 적용([&m_obj, &v,
this](
auto && ...p) {
102 (
접근자 <
typename std::decay_t<
decltype(p)>::Result>::set(
103 m_obj, m_obj.get_table().get_column_key(p.name), m_realm, v.*(std::decay_t<
decltype(p)>::ptr)
111 자동 테이블 = m_realm.table_for_object_type(T::schema.name);
112 table.remove_object(
객체.m_obj.get_key());
115 void insert(
const std::vector<T> &v) {
116 static_assert(
sizeof(
managed<T>),
"Must explain schema for T");
118 for (
auto& obj : v) {
124 m_obj = table.create_object();
126 std:: 적용([&m_obj, &obj](
auto && ...p) {
127 (
접근자 <
typename std::decay_t<
decltype(p)>::Result>::set(
128 m_obj, m_obj.get_table().get_column_key(p.name), obj.*(std::decay_t<
decltype(p)>::ptr)
135 template <
size_t N,
typename Tpl,
typename ...Ts>
auto v_add(
const Tpl& tpl,
const std::tuple<Ts...>& vs) {
136 만약 constexpr (N + 1 ==
sizeof...(Typescript)) {
137 자동 managed = add(std::move(std::get<N>(vs)));
138 return std::tuple_cat(tpl, std::ake_tuple(std::move(
managed)));
140 자동 managed = add(std::move(std::get<N>(vs)));
141 return v_add<N + 1>(std::tuple_cat(tpl, std::ake_tuple(std::move(
managed))), vs);
146 std::tuple<managed<Ts>...> insert(Ts&&... v) {
148 return v_add<0>(tpl, std::ake_tuple(v...));
156 [[maybe_unused]]
bool refresh()
158 return m_realm.refresh();
163 std::optional<sync_session> get_sync_session()
const {
164 return m_realm.get_sync_session();
170 자동 객체 = Internal::bridge::resolve<internal::bridge::object>(m_realm, std::move(tsr.m_tsr));
175 bool is_frozen()
const;
181 친구 구조체::영역::thread_safe_reference<db>;
182 템플릿 <
typename,
typename>
친구 구조체 managed;
184 친구 void internal::bridge::영역::config::set_client_reset_handler(
const client_reset_mode_base<T>&);
188 m_realm = std::move(r);
196 bool 연산자==(
const db&,
const db&);
197 bool 연산자!=(
const db&,
const db&);
201 auto config_copy = config;
202 만약 constexpr (
sizeof...(Typescript) == 0) {
203 config_copy.set_schema(db::schemas);
205 std::vector<internal::bridge::object_schema> 스키마;
206 (스키마.push_back(managed<Ts>:: 스키마.to_core_schema()), ...);
207 config_copy.set_schema(스키마);
209 return db(config_copy);
212 [[deprecated(
"이 함수는 더 이상 사용되지 않으며 `db::open(const db_config& config)`으로 대체되었습니다.")]]
213 인라인 db open(
const std::string& 경로,
const std::shared_ptr<scheduler>& 스케줄러) {
214 return open<Ts...>(db_config(path, 스케줄러));
218 인라인 std::ostream& 연산자<< (std::ostream& stream,
const T*&
객체)
220 스트림 <<
"link:" <<
object << std::endl;