From: Adrian Szyndela Date: Tue, 27 Oct 2020 11:32:03 +0000 (+0100) Subject: serialization: add SerializationBackend type X-Git-Tag: accepted/tizen/unified/20201105.124409~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c68a65507bb78b99f267169b28bca93a01fbc25f;p=platform%2Fcore%2Fsystem%2Flibdbuspolicy.git serialization: add SerializationBackend type Add SerializationBackend type, which is a customization point for choosing serialization backend. At the moment it is set to Flatbuffers. It is the place to select another backend, when it shows up. Change-Id: I2a54f643d5c5bda065fcd193c51ca928f20df203 --- diff --git a/src/internal/serialization_backend.hpp b/src/internal/serialization_backend.hpp new file mode 100644 index 0000000..2b3395a --- /dev/null +++ b/src/internal/serialization_backend.hpp @@ -0,0 +1,37 @@ +#pragma once + +/* MIT License + * + * Copyright (c) 2020 Samsung Electronics Co., Ltd + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ + +#include "serializer_flatbuffers.hpp" +#include "storage_backend_flatbuffers.hpp" + +namespace ldp_serialization { + +struct SerializationBackendFlatbuffers { + typedef ldp_serialized::StorageBackendFlatbuffers Storage; + typedef ldp_serializer::SerializerFlatbuffers Serializer; +}; + +typedef SerializationBackendFlatbuffers SerializationBackend; + +} diff --git a/src/internal/serializer.hpp b/src/internal/serializer.hpp index 34c8c9f..e087017 100644 --- a/src/internal/serializer.hpp +++ b/src/internal/serializer.hpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "serializer_flatbuffers.hpp" +#include "serialization_backend.hpp" #include #include @@ -33,7 +33,7 @@ namespace ldp_serializer { class Serializer { - SerializerFlatbuffers impl; + ldp_serialization::SerializationBackend::Serializer impl; public: auto serialize(const ldp_xml::StorageBackendXML &db, size_t &size) { return impl.serialize(db, size); diff --git a/src/internal/storage_backend_serialized.hpp b/src/internal/storage_backend_serialized.hpp index dc3a861..9a498b5 100644 --- a/src/internal/storage_backend_serialized.hpp +++ b/src/internal/storage_backend_serialized.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "policy.hpp" -#include "storage_backend_flatbuffers.hpp" +#include "serialization_backend.hpp" #include "serializer.hpp" #include #include @@ -66,7 +66,7 @@ public: { return impl.existsPolicyForGroup(gid); } private: - typedef StorageBackendFlatbuffers Backend; + typedef typename ldp_serialization::SerializationBackend::Storage Backend; Backend impl; // Set max size of serialized file to prevent mmap with unexpected memory size.