Realm C++ SDK Version v2.2.0

notifications.hpp

1
2//
3// Copyright 2022 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef notifications_hpp
20#define notifications_hpp
21
22#include <cpprealm/thread_safe_reference.hpp>
23#include <cpprealm/internal/bridge/dictionary.hpp>
24#include <cpprealm/internal/bridge/list.hpp>
25#include <cpprealm/internal/bridge/set.hpp>
26
27#include <any>
28#include <future>
29#include <utility>
30
31namespace realm {
32template <typename T>
34
39 notification_token(const notification_token &nt) noexcept = delete;
40 notification_token &operator=(const notification_token &) = delete;
41 notification_token(notification_token&& other) noexcept {
42 m_token = std::move(other.m_token);
43 m_dictionary = std::move(other.m_dictionary);
44 m_list = std::move(other.m_list);
45 m_set = std::move(other.m_set);
46 m_results = std::move(other.m_results);
47 m_realm = std::move(other.m_realm);
48 };
49 notification_token &operator=(notification_token &&other) {
50 m_token = std::move(other.m_token);
51 m_dictionary = std::move(other.m_dictionary);
52 m_list = std::move(other.m_list);
53 m_set = std::move(other.m_set);
54 m_results = std::move(other.m_results);
55 m_realm = std::move(other.m_realm);
56 return *this;
57 };
58 notification_token() = default;
59 ~notification_token() = default;
60
62 : m_token(std::move(token)) {}
63 void unregister() {
64 m_token.unregister();
65 }
66
68 std::shared_ptr<internal::bridge::dictionary> m_dictionary;
69 std::shared_ptr<internal::bridge::list> m_list;
70 std::shared_ptr<internal::bridge::set> m_set;
71 std::shared_ptr<internal::bridge::results> m_results;
73};
74
75// MARK: PropertyChange
79template <typename T>
84 std::string name;
85
97 std::optional<typename decltype(T::schema)::variant_t> old_value;
98
103 std::optional<typename decltype(T::schema)::variant_t> new_value;
104};
105
106} // namespace realm
107
108#endif /* notifications_hpp */
Definition: notifications.hpp:33
Definition: notifications.hpp:80
std::optional< typename decltype(T::schema)::variant_t > old_value
Definition: notifications.hpp:97
std::optional< typename decltype(T::schema)::variant_t > new_value
Definition: notifications.hpp:103
std::string name
Definition: notifications.hpp:84
Definition: realm.hpp:67
Definition: notifications.hpp:38