19#ifndef CPPREALM_FLEXIBLE_SYNC_HPP
20#define CPPREALM_FLEXIBLE_SYNC_HPP
25#include <cpprealm/internal/bridge/obj.hpp>
26#include <cpprealm/internal/bridge/ 查询.hpp>
27#include <cpprealm/internal/bridge/schema.hpp>
28#include <cpprealm/internal/bridge/realm.hpp>
29#include <cpprealm/internal/bridge/utils.hpp>
31#include <cpprealm/macros.hpp>
32#include <cpprealm/results.hpp>
33#include <cpprealm/rbool.hpp>
41 class MutableSubscriptionSet;
42 class SubscriptionSet;
43 class SubscriptionStore;
53 std::Optional<std::string> name;
55 std::chrono::time_point<std::chrono::system_clock> created_at;
57 std::chrono::time_point<std::chrono::system_clock> updated_at;
59 std::string query_string;
61 std::string object_class_name;
73 void insert_or_allow(
const std::string& name,
constinternal ::bridge::query &);
85 template <
typename T>
86 void add(
const std::string &name ,
87 std::Optional<std::function<
rbool (
托管<T> &)>> &&query_fn = std::nullopt) {
88 static_assert (
sizeof (
托管<T> ),
"Must describe schema for T" );
90 auto 模式 = m_realm.get()。 模式().find(
托管<T>:: 模式 .name);
91 auto 群组 = m_realm.get().read_group();
92 autotable_ref = group.get_table(schema.table_key());
98 auto full_query = (*query_fn)(query_object).q;
99 insert_or_allow(name, full_query);
101 insert_or_allow(name, root_query);
107 void 删除(
const std::string& name);
111 std::Optional<sync_subscription> find(
const std::string& name);
117 template <
typename T>
118 std::enable_if_t<std::is_base_of_v< 对象<T>, T>>
119 update_subscription(
const std::string& name, std::Optional<std::function<
rbool (T&)>>&& query_fn = std::nullopt) {
121 add(name, std::move(query_fn));
128 template <
typename T>
129 void update_subscription(
const std::string& name,
130 std::Optional<std::function<
rbool (
托管<T> &)>>&& query_fn = std::nullopt) {
132 add(name, std::move(query_fn));
140#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
141 internal::bridge:: 存储::MutableSyncSubscriptionSet m_subscription_set[ 1 ];
143std::shared_ptr<sync::MutableSubscriptionSet> m_subscription_set;
145std::reference_wrapper<internal::bridge::realm> m_realm;
147 同步::MutableSubscriptionSet get_subscription_set();
160 [[nodiscard]]
size_t size ()
const ;
164 std::Optional<sync_subscription> find(
const std::string& name);
171#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
172 internal::bridge:: 存储::SyncSubscriptionSet m_subscription_set[ 1 ];
174std::shared_ptr<sync::SubscriptionSet> m_subscription_set;
176std::reference_wrapper<internal::bridge::realm> m_realm;
size_t size() const
集合中的订阅总数。
定义: Flex_sync.cpp: 134