Implement Storage::save() using StorageSerializer and clean up 30/24730/2
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 18 Jul 2014 19:34:49 +0000 (21:34 +0200)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 21 Jul 2014 10:46:29 +0000 (12:46 +0200)
There was a lot of mess in #includes directives and forward
declarations of classes. It was cleaned out.
InMemoryStorageBackend::Buckets were moved to separate file
in order not to make a cyclic dependency.

New exception class CannotCreateFile was added.

Change-Id: I32b234ba0f4872791a9f931690c58e623de7096f

13 files changed:
src/common/exceptions/CannotCreateFileException.h [new file with mode: 0644]
src/service/storage/BucketDeserializer.cpp
src/service/storage/BucketDeserializer.h
src/service/storage/Buckets.h [new file with mode: 0644]
src/service/storage/InMemoryStorageBackend.cpp
src/service/storage/InMemoryStorageBackend.h
src/service/storage/Storage.cpp
src/service/storage/Storage.h
src/service/storage/StorageBackend.h
src/service/storage/StorageDeserializer.cpp
src/service/storage/StorageDeserializer.h
src/service/storage/StorageSerializer.cpp
src/service/storage/StorageSerializer.h

diff --git a/src/common/exceptions/CannotCreateFileException.h b/src/common/exceptions/CannotCreateFileException.h
new file mode 100644 (file)
index 0000000..bb3f937
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/*
+ * @file        CannotCreateFileException.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file defines exception thrown when database file cannot be created
+ */
+
+#ifndef SRC_COMMON_EXCEPTIONS_CANNOTCREATEFILEEXCEPTION_H_
+#define SRC_COMMON_EXCEPTIONS_CANNOTCREATEFILEEXCEPTION_H_
+
+#include <string>
+
+#include <exceptions/DatabaseException.h>
+
+namespace Cynara {
+
+class CannotCreateFileException : public DatabaseException {
+public:
+    CannotCreateFileException(const std::string &filename) : m_filename(filename) {};
+    virtual ~CannotCreateFileException() = default;
+
+    const std::string message(void) const {
+        if (m_message.empty()) {
+            m_message = "File " + filename() + " cannot be created";
+        }
+        return m_message;
+    }
+
+    const std::string &filename(void) const {
+        return m_filename;
+    }
+
+private:
+    mutable std::string m_message;
+    std::string m_filename;
+};
+
+} /* namespace Cynara */
+
+#endif /* SRC_COMMON_EXCEPTIONS_CANNOTCREATEFILEEXCEPTION_H_ */
index 914f766..1bfac50 100644 (file)
  * @brief       Methods implementation of Cynara::BucketDeserializer
  */
 
+#include <array>
+#include <memory>
+#include <string>
+#include <vector>
+
 #include <exceptions/BucketRecordCorruptedException.h>
-#include <storage/BucketDeserializer.h>
+#include <types/PolicyCollection.h>
+#include <types/PolicyResult.h>
+#include <types/PolicyType.h>
+
 #include <storage/StorageDeserializer.h>
 #include <storage/StorageSerializer.h>
-#include <types/Policy.h>
 
-#include <iostream>
-#include <memory>
-#include <string>
+#include "BucketDeserializer.h"
 
 namespace Cynara {
 
@@ -36,7 +41,7 @@ PolicyCollection BucketDeserializer::loadPolicies(void) {
     PolicyCollection policies;
 
     // TODO: Get someone smart to do error checking on stream
-    for(std::size_t lineNum = 1; !m_inStream.eof(); ++lineNum) {
+    for (std::size_t lineNum = 1; !m_inStream.eof(); ++lineNum) {
         std::string line;
         std::getline(m_inStream, line, StorageSerializer::recordSeparator());
 
@@ -61,7 +66,7 @@ PolicyCollection BucketDeserializer::loadPolicies(void) {
 PolicyKey BucketDeserializer::parseKey(const std::string &line, std::size_t &beginToken) {
     std::array<std::string, 3> keyFeatures;
 
-    for(std::size_t tokenNum = 0; tokenNum < keyFeatures.size(); ++tokenNum) {
+    for (std::size_t tokenNum = 0; tokenNum < keyFeatures.size(); ++tokenNum) {
         auto endToken = line.find(StorageSerializer::fieldSeparator(), beginToken);
         if (endToken != std::string::npos) {
             keyFeatures[tokenNum] = line.substr(beginToken, endToken - beginToken);
index a9b7b8c..393991e 100644 (file)
 #ifndef SRC_SERVICE_STORAGE_BUCKETDESERIALIZER_H_
 #define SRC_SERVICE_STORAGE_BUCKETDESERIALIZER_H_
 
+#include <istream>
+#include <string>
+
 #include <types/PolicyCollection.h>
 #include <types/PolicyKey.h>
-#include <types/PolicyResult.h>
-#include <types/PolicyType.h>
-
-#include <istream>
 
 namespace Cynara {
 
diff --git a/src/service/storage/Buckets.h b/src/service/storage/Buckets.h
new file mode 100644 (file)
index 0000000..1fdc249
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/*
+ * @file        Buckets.h
+ * @author      Aleksander Zdyb <a.zdyb@partner.samsung.com>
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       Headers for Buckets
+ */
+
+#ifndef SRC_SERVICE_STORAGE_BUCKETS_H_
+#define SRC_SERVICE_STORAGE_BUCKETS_H_
+
+#include <unordered_map>
+
+#include <types/PolicyBucket.h>
+#include <types/PolicyBucketId.h>
+
+namespace Cynara {
+
+typedef std::unordered_map<PolicyBucketId, PolicyBucket> Buckets;
+
+} /* namespace Cynara */
+
+#endif /* SRC_SERVICE_STORAGE_BUCKETS_H_ */
index 1b7ae44..5d18219 100644 (file)
  * @brief       Implementation of InMemoryStorageBackend
  */
 
+#include <errno.h>
 #include <fstream>
 #include <functional>
+#include <string>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unordered_map>
+#include <vector>
 
 #include <log/log.h>
+#include <exceptions/BucketNotExistsException.h>
+#include <exceptions/CannotCreateFileException.h>
 #include <exceptions/FileNotFoundException.h>
+#include <exceptions/UnexpectedErrorException.h>
+#include <types/PolicyBucket.h>
+#include <types/PolicyResult.h>
+#include <types/PolicyType.h>
+
 #include <storage/BucketDeserializer.h>
 #include <storage/StorageDeserializer.h>
-#include <types/PolicyBucketId.h>
+#include <storage/StorageSerializer.h>
 
 #include "InMemoryStorageBackend.h"
 
 namespace Cynara {
 
 void InMemoryStorageBackend::load(void) {
-    std::string indexFilename = m_dbPath + "buckets";
+    std::string indexFilename = m_dbPath + m_indexFileName;
 
     try {
         std::ifstream indexStream;
@@ -49,12 +62,33 @@ void InMemoryStorageBackend::load(void) {
         LOGE("Reading cynara database failed.");
     }
 
-    if(!hasBucket(defaultPolicyBucketId)) {
+    if (!hasBucket(defaultPolicyBucketId)) {
             LOGN("Creating defaultBucket.");
             this->buckets().insert({ defaultPolicyBucketId, PolicyBucket() });
     }
 }
 
+void InMemoryStorageBackend::save(void) {
+
+    //create directory
+    int ret = mkdir(m_dbPath.c_str(), S_IRWXU);
+    if (ret < 0) {
+        int err = errno;
+        if (err != EEXIST) {
+            LOGE("Cannot create directory <%s>. Error [%d] : <%s>.",
+                 m_dbPath.c_str(), err, strerror(err));
+            throw UnexpectedErrorException(err, strerror(err));
+        }
+    }
+
+    std::ofstream indexStream;
+    openDumpFileStream(indexStream, m_dbPath + m_indexFileName);
+
+    StorageSerializer storageSerializer(indexStream);
+    storageSerializer.dump(buckets(), std::bind(&InMemoryStorageBackend::bucketDumpStreamOpener,
+                           this, std::placeholders::_1));
+}
+
 PolicyBucket InMemoryStorageBackend::searchDefaultBucket(const PolicyKey &key) {
     return searchBucket(defaultPolicyBucketId, key);
 }
@@ -116,7 +150,7 @@ void InMemoryStorageBackend::deletePolicy(const PolicyBucketId &bucketId, const
                 [key](PolicyPtr policy) -> bool {
                     return policy->key() == key;
             }), policies.end());
-    } catch(const std::out_of_range &) {
+    } catch (const std::out_of_range &) {
         throw BucketNotExistsException(bucketId);
     }
 }
@@ -133,7 +167,7 @@ void InMemoryStorageBackend::deleteLinking(const PolicyBucketId &bucketId) {
         return false;
     };
 
-    for(auto &bucketIter : buckets()) {
+    for (auto &bucketIter : buckets()) {
         // TODO: Move the erase code to PolicyCollection maybe?
         auto &bucket = bucketIter.second;
         auto &policies = bucket.policyCollection();
@@ -151,6 +185,16 @@ void InMemoryStorageBackend::openFileStream(std::ifstream &stream, const std::st
         throw FileNotFoundException(filename);
 }
 
+void InMemoryStorageBackend::openDumpFileStream(std::ofstream &stream,
+                                                const std::string &filename) {
+    stream.open(filename, std::ofstream::out | std::ofstream::trunc);
+
+    if (!stream.is_open()) {
+        throw CannotCreateFileException(filename);
+        return;
+    }
+}
+
 std::shared_ptr<BucketDeserializer> InMemoryStorageBackend::bucketStreamOpener(
         const PolicyBucketId &bucketId) {
     std::string bucketFilename = m_dbPath + "_" + bucketId;
@@ -163,4 +207,13 @@ std::shared_ptr<BucketDeserializer> InMemoryStorageBackend::bucketStreamOpener(
     }
 }
 
+std::shared_ptr<StorageSerializer> InMemoryStorageBackend::bucketDumpStreamOpener(
+        const PolicyBucketId &bucketId) {
+    std::string bucketFilename = m_dbPath + "_" + bucketId;
+    std::ofstream bucketStream;
+
+    openDumpFileStream(bucketStream, bucketFilename);
+    return std::make_shared<StorageSerializer>(bucketStream);
+}
+
 } /* namespace Cynara */
index 1791b00..5127bc6 100644 (file)
  * @brief       Headers for InMemoryStorageBackend
  */
 
-#ifndef INMEMORYSTORAGEBACKEND_H_
-#define INMEMORYSTORAGEBACKEND_H_
+#ifndef SRC_SERVICE_STORAGE_INMEMORYSTORAGEBACKEND_H_
+#define SRC_SERVICE_STORAGE_INMEMORYSTORAGEBACKEND_H_
 
-#include <algorithm>
 #include <fstream>
-#include <functional>
-#include <iostream>
-#include <unordered_map>
+#include <memory>
+#include <string>
 
-#include <exceptions/BucketNotExistsException.h>
-#include <exceptions/NotImplementedException.h>
-#include <storage/BucketDeserializer.h>
-#include <types/Policy.h>
+#include <types/pointers.h>
+#include <types/PolicyBucket.h>
+#include <types/PolicyBucketId.h>
+#include <types/PolicyKey.h>
+#include <types/PolicyResult.h>
 
-#include "StorageBackend.h"
+#include <storage/BucketDeserializer.h>
+#include <storage/Buckets.h>
+#include <storage/StorageBackend.h>
+#include <storage/StorageSerializer.h>
 
 namespace Cynara {
 
 class InMemoryStorageBackend : public StorageBackend {
 public:
-    typedef std::unordered_map<PolicyBucketId, PolicyBucket> Buckets;
-
     InMemoryStorageBackend(const std::string &path) : m_dbPath(path) {
     }
-
     virtual ~InMemoryStorageBackend() = default;
 
     virtual void load(void);
+    virtual void save(void);
 
     virtual PolicyBucket searchDefaultBucket(const PolicyKey &key);
     virtual PolicyBucket searchBucket(const PolicyBucketId &bucketId, const PolicyKey &key);
@@ -63,15 +63,20 @@ protected:
     void openFileStream(std::ifstream &stream, const std::string &filename);
     std::shared_ptr<BucketDeserializer> bucketStreamOpener(const PolicyBucketId &bucketId);
 
+    void openDumpFileStream(std::ofstream &stream, const std::string &filename);
+    std::shared_ptr<StorageSerializer> bucketDumpStreamOpener(const PolicyBucketId &bucketId);
+
 private:
     std::string m_dbPath;
     Buckets m_buckets;
+    const std::string m_indexFileName = "buckets";
 
 protected:
-    virtual Buckets &buckets() {
+    virtual Buckets &buckets(void) {
         return m_buckets;
     }
 };
 
 } /* namespace Cynara */
-#endif /* INMEMORYSTORAGEBACKEND_H_ */
+
+#endif /* SRC_SERVICE_STORAGE_INMEMORYSTORAGEBACKEND_H_ */
index 319dbda..cfbd82d 100644 (file)
  * @brief       This file implements policy rules storage procedures
  */
 
-#include "Storage.h"
-#include "StorageBackend.h"
-#include "types/pointers.h"
-#include "types/PolicyType.h"
-#include "exceptions/NotImplementedException.h"
-#include "exceptions/DefaultBucketDeletionException.h"
-
-#include <iostream>
 #include <memory>
+#include <vector>
 
+#include "exceptions/DefaultBucketDeletionException.h"
+#include <types/pointers.h>
+#include <types/Policy.h>
+#include <types/PolicyBucket.h>
+#include <types/PolicyBucketId.h>
+#include <types/PolicyCollection.h>
+#include <types/PolicyResult.h>
+#include <types/PolicyType.h>
+
+#include "Storage.h"
 
 namespace Cynara {
 
@@ -58,19 +61,17 @@ PolicyResult Storage::minimalPolicy(const PolicyBucket &bucket, const PolicyKey
         const auto &policyResult = policyRecord->result();
 
         switch (policyResult.policyType()) {
-        case PredefinedPolicyType::DENY:
-            return policyResult; // Do not expect lower value than DENY
-            break;
-        case PredefinedPolicyType::BUCKET: {
-                auto bucketResults = m_backend.searchBucket(policyResult.metadata(), key);
-                auto minimumOfBucket = minimalPolicy(bucketResults, key);
-                proposeMinimal(minimumOfBucket);
-                continue;
-            }
-            break;
-        case PredefinedPolicyType::ALLOW:
-        default:
-            break;
+            case PredefinedPolicyType::DENY:
+                return policyResult; // Do not expect lower value than DENY
+            case PredefinedPolicyType::BUCKET: {
+                    auto bucketResults = m_backend.searchBucket(policyResult.metadata(), key);
+                    auto minimumOfBucket = minimalPolicy(bucketResults, key);
+                    proposeMinimal(minimumOfBucket);
+                    continue;
+                }
+            case PredefinedPolicyType::ALLOW:
+            default:
+                break;
         }
 
         proposeMinimal(policyResult);
@@ -125,4 +126,8 @@ void Storage::load(void) {
     m_backend.load();
 }
 
+void Storage::save(void) {
+    m_backend.save();
+}
+
 } // namespace Cynara
index b1c7cb3..23955ff 100644 (file)
  * @brief       This file is the implementation file of log system
  */
 
-#ifndef CYNARA_SERVICE_STORAGE_STORAGE_H
-#define CYNARA_SERVICE_STORAGE_STORAGE_H
+#ifndef SRC_SERVICE_STORAGE_STORAGE_H_
+#define SRC_SERVICE_STORAGE_STORAGE_H_
 
 #include <map>
-#include <memory>
 #include <string>
-#include <tuple>
 #include <vector>
 
-#include "types/pointers.h"
-#include "types/PolicyBucketId.h"
-#include "types/PolicyResult.h"
-#include "types/PolicyKey.h"
+#include <types/Policy.h>
+#include <types/PolicyBucket.h>
+#include <types/PolicyBucketId.h>
+#include <types/PolicyKey.h>
+#include <types/PolicyResult.h>
 
-namespace Cynara {
+#include <storage/StorageBackend.h>
 
-class StorageBackend;
-class PolicyBucket;
+namespace Cynara {
 
 class Storage
 {
@@ -54,6 +52,7 @@ public:
     void deleteBucket(const PolicyBucketId &bucketId);
 
     void load(void);
+    void save(void);
 
 protected:
     PolicyResult minimalPolicy(const PolicyBucket &bucket, const PolicyKey &key);
@@ -64,4 +63,4 @@ private:
 
 } // namespace Cynara
 
-#endif /* CYNARA_SERVICE_STORAGE_STORAGE_H */
+#endif /* SRC_SERVICE_STORAGE_STORAGE_H_ */
index 97e0fd7..cc711f9 100644 (file)
  * @brief       Headers for StorageBackend base class
  */
 
-#ifndef STORAGEBACKEND_H_
-#define STORAGEBACKEND_H_
+#ifndef SRC_SERVICE_STORAGE_STORAGEBACKEND_H_
+#define SRC_SERVICE_STORAGE_STORAGEBACKEND_H_
 
+#include <string>
 
-#include "types/pointers.h"
-#include "types/PolicyBucket.h"
-#include "types/PolicyBucketId.h"
-
-#include <memory>
+#include <types/pointers.h>
+#include <types/PolicyBucket.h>
+#include <types/PolicyKey.h>
+#include <types/PolicyBucketId.h>
+#include <types/PolicyResult.h>
 
 namespace Cynara {
 
-class PolicyKey;
-
 class StorageBackend {
 public:
     virtual ~StorageBackend() {}
@@ -43,8 +42,10 @@ public:
 
     virtual void insertPolicy(const PolicyBucketId &bucket, PolicyPtr policy) = 0;
 
-    virtual void createBucket(const PolicyBucketId &bucketId, const PolicyResult &defaultPolicy) = 0;
-    virtual void updateBucket(const PolicyBucketId &bucketId, const PolicyResult &defaultPolicy) = 0;
+    virtual void createBucket(const PolicyBucketId &bucketId,
+                              const PolicyResult &defaultPolicy) = 0;
+    virtual void updateBucket(const PolicyBucketId &bucketId,
+                              const PolicyResult &defaultPolicy) = 0;
     virtual void deleteBucket(const PolicyBucketId &bucketId) = 0;
     virtual bool hasBucket(const PolicyBucketId &bucketId) = 0;
 
@@ -52,7 +53,9 @@ public:
     virtual void deleteLinking(const PolicyBucketId &bucket) = 0;
 
     virtual void load(void) = 0;
+    virtual void save(void) = 0;
 };
 
 } /* namespace Cynara */
-#endif /* STORAGEBACKEND_H_ */
+
+#endif /* SRC_SERVICE_STORAGE_STORAGEBACKEND_H_ */
index 0510670..66c8ff0 100644 (file)
  * @brief       Implementation for Cynara::StorageDeserializer
  */
 
-#include <iostream>
+#include <istream>
 #include <string>
 
 #include <exceptions/BucketDeserializationException.h>
 #include <exceptions/BucketRecordCorruptedException.h>
+#include <types/PolicyType.h>
+
 #include <storage/BucketDeserializer.h>
+#include <storage/Buckets.h>
 #include <storage/StorageSerializer.h>
 
-#include <storage/StorageDeserializer.h>
+#include "StorageDeserializer.h"
 
 namespace Cynara {
 
@@ -36,10 +39,10 @@ StorageDeserializer::StorageDeserializer(std::istream &inStream,
                                          BucketStreamOpener bucketStreamOpener)
         : m_inStream(inStream), m_bucketStreamOpener(bucketStreamOpener) {}
 
-void StorageDeserializer::initBuckets(InMemoryStorageBackend::Buckets &buckets) {
+void StorageDeserializer::initBuckets(Buckets &buckets) {
     buckets.clear();
 
-    for(std::size_t lineNum = 1; !m_inStream.eof(); ++lineNum) {
+    for (std::size_t lineNum = 1; !m_inStream.eof(); ++lineNum) {
         std::string line;
         std::getline(m_inStream, line, StorageSerializer::recordSeparator());
 
@@ -55,7 +58,7 @@ void StorageDeserializer::initBuckets(InMemoryStorageBackend::Buckets &buckets)
     }
 }
 
-void StorageDeserializer::loadBuckets(InMemoryStorageBackend::Buckets &buckets) {
+void StorageDeserializer::loadBuckets(Buckets &buckets) {
     for (auto &bucketIter : buckets) {
         const auto &bucketId = bucketIter.first;
         auto &bucket = bucketIter.second;
@@ -88,7 +91,7 @@ PolicyType StorageDeserializer::parsePolicyType(const std::string &line, std::si
         std::size_t newBegin = 0;
         policyType = std::stoi(line.substr(beginToken), &newBegin, 16);
         beginToken += newBegin;
-    } catch(...) {
+    } catch (...) {
         throw BucketRecordCorruptedException(line);
     }
 
index 2fd0341..c3680c4 100644 (file)
 #ifndef SRC_SERVICE_STORAGE_STORAGEDESERIALIZER_H_
 #define SRC_SERVICE_STORAGE_STORAGEDESERIALIZER_H_
 
-#include <storage/BucketDeserializer.h>
-#include <storage/InMemoryStorageBackend.h>
-
+#include <functional>
 #include <istream>
 #include <memory>
-#include <functional>
+#include <string>
+
+#include <types/PolicyBucketId.h>
+#include <types/PolicyResult.h>
+#include <types/PolicyType.h>
+
+#include <storage/BucketDeserializer.h>
+#include <storage/Buckets.h>
 
 namespace Cynara {
 
 class StorageDeserializer {
 public:
-    typedef std::function<std::shared_ptr<BucketDeserializer>(const std::string &)> BucketStreamOpener;
+    typedef std::function<std::shared_ptr<BucketDeserializer>(const std::string &)>
+                BucketStreamOpener;
     StorageDeserializer(std::istream &inStream, BucketStreamOpener m_bucketStreamOpener);
-    void initBuckets(InMemoryStorageBackend::Buckets &buckets);
-    void loadBuckets(InMemoryStorageBackend::Buckets &buckets);
+    void initBuckets(Buckets &buckets);
+    void loadBuckets(Buckets &buckets);
 
     static PolicyBucketId parseBucketId(const std::string &line, std::size_t &beginToken);
     static PolicyType parsePolicyType(const std::string &line, std::size_t &beginToken);
index be8b9d4..f46d48e 100644 (file)
  * @brief       Implementation of Cynara::StorageSerializer methods
  */
 
-#include <algorithm>
 #include <ios>
-#include <iostream>
+#include <ostream>
 
 #include <exceptions/BucketSerializationException.h>
-#include "types/PolicyBucket.h"
-#include "types/PolicyCollection.h"
+#include <types/Policy.h>
+#include <types/PolicyBucket.h>
+#include <types/PolicyBucketId.h>
+#include <types/PolicyCollection.h>
+#include <types/PolicyType.h>
 
 #include "StorageSerializer.h"
 
@@ -37,7 +39,7 @@ char StorageSerializer::m_recordSeparator = '\n';
 
 StorageSerializer::StorageSerializer(std::ostream &os) : m_outStream(os) {}
 
-void StorageSerializer::dump(const InMemoryStorageBackend::Buckets &buckets,
+void StorageSerializer::dump(const Buckets &buckets,
                              BucketStreamOpener streamOpener) {
 
     for (const auto bucketIter : buckets) {
index 789f263..80966e9 100644 (file)
 #ifndef SRC_SERVICE_STORAGE_STORAGESERIALIZER_H_
 #define SRC_SERVICE_STORAGE_STORAGESERIALIZER_H_
 
-#include "InMemoryStorageBackend.h"
-#include "types/PolicyBucketId.h"
-#include "types/PolicyCollection.h"
-#include "types/PolicyResult.h"
-
+#include <functional>
+#include <memory>
 #include <ostream>
 
-namespace Cynara {
+#include <types/PolicyBucket.h>
+#include <types/PolicyBucketId.h>
+#include <types/PolicyCollection.h>
+#include <types/PolicyKey.h>
+#include <types/PolicyResult.h>
+#include <types/PolicyType.h>
 
-class PolicyBucket;
-class PolicyKey;
+#include <storage/Buckets.h>
+
+namespace Cynara {
 
 class StorageSerializer {
 
@@ -44,7 +47,7 @@ public:
     StorageSerializer(std::ostream &os);
     virtual ~StorageSerializer() = default;
 
-    virtual void dump(const InMemoryStorageBackend::Buckets &buckets,
+    virtual void dump(const Buckets &buckets,
                       BucketStreamOpener streamOpener);
     virtual void dump(const PolicyBucket &bucket);