summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Szyndela <adrian.s@samsung.com>2020-10-27 12:32:03 +0100
committerAdrian Szyndela <adrian.s@samsung.com>2020-10-30 12:17:42 +0100
commitc68a65507bb78b99f267169b28bca93a01fbc25f (patch)
treefd2fdf855620462b89d973e68913d95a08479b7a
parentca1b3b3078202c243a890fcb75e60591ac2f2315 (diff)
downloadlibdbuspolicy-c68a65507bb78b99f267169b28bca93a01fbc25f.tar.gz
libdbuspolicy-c68a65507bb78b99f267169b28bca93a01fbc25f.tar.bz2
libdbuspolicy-c68a65507bb78b99f267169b28bca93a01fbc25f.zip
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
-rw-r--r--src/internal/serialization_backend.hpp37
-rw-r--r--src/internal/serializer.hpp4
-rw-r--r--src/internal/storage_backend_serialized.hpp4
3 files changed, 41 insertions, 4 deletions
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 <iostream>
#include <string>
@@ -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 <memory>
#include <sys/types.h>
@@ -66,7 +66,7 @@ public:
{ return impl.existsPolicyForGroup<MatchItem>(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.