X-Git-Url: https://git.mdrn.pl/wl-app.git/blobdiff_plain/53b27422d140022594fc241cca91c3183be57bca..48b2fe9f7c2dc3d9aeaaa6dbfb27c7da4f3235ff:/iOS/Pods/Realm/include/thread_safe_reference.hpp diff --git a/iOS/Pods/Realm/include/thread_safe_reference.hpp b/iOS/Pods/Realm/include/thread_safe_reference.hpp new file mode 100644 index 0000000..ca3cc19 --- /dev/null +++ b/iOS/Pods/Realm/include/thread_safe_reference.hpp @@ -0,0 +1,113 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2016 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +#ifndef REALM_THREAD_SAFE_REFERENCE_HPP +#define REALM_THREAD_SAFE_REFERENCE_HPP + + +#include + +namespace realm { +class LinkView; +class List; +class Object; +class Query; +class Realm; +class Results; +class TableView; +template class BasicRow; +typedef BasicRow Row; + +// Opaque type representing an object for handover +class ThreadSafeReferenceBase { +public: + ThreadSafeReferenceBase(const ThreadSafeReferenceBase&) = delete; + ThreadSafeReferenceBase& operator=(const ThreadSafeReferenceBase&) = delete; + ThreadSafeReferenceBase(ThreadSafeReferenceBase&&) = default; + ThreadSafeReferenceBase& operator=(ThreadSafeReferenceBase&&) = default; + ThreadSafeReferenceBase(); + virtual ~ThreadSafeReferenceBase(); + + bool is_invalidated() const { return m_source_realm == nullptr; }; + +protected: + // Precondition: The associated Realm is for the current thread and is not in a write transaction;. + ThreadSafeReferenceBase(std::shared_ptr source_realm); + + SharedGroup& get_source_shared_group() const; + + template + V invalidate_after_import(Realm& destination_realm, T construct_with_shared_group); + +private: + friend Realm; + + VersionID m_version_id; + std::shared_ptr m_source_realm; // Strong reference keeps alive so version stays pinned! Don't touch!! + + bool has_same_config(Realm& realm) const; + void invalidate(); +}; + +template +class ThreadSafeReference; + +template<> +class ThreadSafeReference: public ThreadSafeReferenceBase { + friend class Realm; + + std::unique_ptr> m_link_view; + std::unique_ptr> m_table; + + // Precondition: The associated Realm is for the current thread and is not in a write transaction;. + ThreadSafeReference(List const& value); + + // Precondition: Realm and handover are on same version. + List import_into_realm(std::shared_ptr realm) &&; +}; + +template<> +class ThreadSafeReference: public ThreadSafeReferenceBase { + friend class Realm; + + std::unique_ptr> m_row; + std::string m_object_schema_name; + + // Precondition: The associated Realm is for the current thread and is not in a write transaction;. + ThreadSafeReference(Object const& value); + + // Precondition: Realm and handover are on same version. + Object import_into_realm(std::shared_ptr realm) &&; +}; + +template<> +class ThreadSafeReference: public ThreadSafeReferenceBase { + friend class Realm; + + std::unique_ptr> m_query; + DescriptorOrdering::HandoverPatch m_ordering_patch; + + // Precondition: The associated Realm is for the current thread and is not in a write transaction;. + ThreadSafeReference(Results const& value); + + // Precondition: Realm and handover are on same version. + Results import_into_realm(std::shared_ptr realm) &&; +}; +} + +#endif /* REALM_THREAD_SAFE_REFERENCE_HPP */