19#ifndef CPPREALM_BRIDGE_REALM_HPP
20#define CPPREALM_BRIDGE_REALM_HPP
22#include <cpprealm/internal/bridge/utils.hpp>
41 enum class client_reset_mode: uint8_t {
53namespace realm::internal::bridge {
54 template<
typename T>
struct client_reset_mode_base;
60 struct thread_safe_reference;
63 struct async_open_task;
68 enum class sync_session_stop_policy: uint8_t {
71 after_changes_uploaded,
77 using port_type = std::uint_fast16_t;
81 std::optional<std::pair<std::string, std::string>> username_password;
88 operator std::shared_ptr<SyncConfig>()
const;
89 void set_stop_policy(sync_session_stop_policy &&);
93 std::shared_ptr<SyncConfig> m_config;
99 enum class schema_mode : uint8_t {
185 config(
const RealmConfig&);
186 config(
const std::string& path,
187 const std::shared_ptr<struct scheduler>&
scheduler);
188 [[nodiscard]] std::string path()
const;
190 [[nodiscard]] std::shared_ptr<struct scheduler>
scheduler()
const;
191 operator RealmConfig()
const;
192 void set_path(
const std::string&);
193 void set_schema(
const std::vector<object_schema>&);
194 void set_schema_mode(schema_mode);
195 void set_scheduler(
const std::shared_ptr<struct scheduler>&);
196 void set_sync_config(
const std::optional<struct sync_config>&);
197 void set_custom_http_headers(
const std::map<std::string, std::string>& headers);
199 void set_schema_version(uint64_t version);
200 void set_encryption_key(
const std::array<char, 64>&);
201 void should_compact_on_launch(std::function<
bool(uint64_t total_bytes, uint64_t unused_bytes)>&& fn);
202 std::optional<schema> get_schema();
206 before_client_reset([fn = std::move(handler.m_before)](
realm local_realm) {
207 fn(local_realm.freeze());
209 after_client_reset([fn = std::move(handler.m_after)](
realm local_realm,
realm remote_realm) {
210 fn(local_realm.freeze(), remote_realm);
212 set_client_reset_mode(handler.m_mode);
214 enum client_reset_mode get_client_reset_mode()
const;
216 void set_client_reset_mode(
enum client_reset_mode mode);
217 void before_client_reset(std::function<
void(
realm old_realm)> callback);
218 void after_client_reset(std::function<
void(
realm local_realm,
realm remote_realm)> callback);
219 inline RealmConfig* get_config();
220 inline const RealmConfig* get_config()
const;
221#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
222 storage::Realm_Config m_config[1];
224 std::shared_ptr<RealmConfig> m_config;
230 realm(std::shared_ptr<Realm>);
232 operator std::shared_ptr<Realm>()
const;
234 [[nodiscard]]
config get_config()
const;
236 void begin_transaction()
const;
237 void commit_transaction()
const;
238 table table_for_object_type(
const std::string& object_type);
239 table get_table(
const uint32_t &);
240 [[nodiscard]] std::shared_ptr<struct scheduler>
scheduler()
const;
243 bool is_frozen()
const;
249 obj import_copy_of(
const obj&)
const;
250 [[nodiscard]] std::optional<sync_session> get_sync_session()
const;
252 std::shared_ptr<Realm> m_realm;
259 std::function<void(T local)> m_before;
260 std::function<void(T local, T remote)> m_after;
261 ::realm::client_reset_mode m_mode;
265 template <
typename T>
Definition: async_open_task.hpp:31
Definition: realm.hpp:257
Definition: dictionary.hpp:138
Definition: schema.hpp:32
Definition: sync_error.hpp:40
Definition: sync_session.hpp:33
Definition: thread_safe_reference.hpp:32
Definition: scheduler.hpp:27