ad_map_access
StorageFile.hpp
Go to the documentation of this file.
1 // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 //
3 // Copyright (C) 2018-2021 Intel Corporation
4 //
5 // SPDX-License-Identifier: MIT
6 //
7 // ----------------- END LICENSE BLOCK -----------------------------------
12 #pragma once
13 
14 #include <stdio.h>
16 
18 namespace ad {
20 namespace map {
22 namespace serialize {
23 
27 class StorageFile : protected virtual IStorage
28 {
29 protected: // Constructor/Destructor
30  StorageFile();
31  virtual ~StorageFile();
32 
33 public: // IStorage Implementation
34  const char *getStorageType() override
35  {
36  return "File";
37  }
38 
39 protected: // IStorage Implementation
40  bool doOpenForRead(std::string const &config) override
41  {
42  return doOpen(config, "rb");
43  };
44 
45  bool doOpenForWrite(std::string const &config) override
46  {
47  return doOpen(config, "wb");
48  }
49 
50  bool doCloseForRead() override
51  {
52  return doClose();
53  }
54 
55  bool doCloseForWrite() override
56  {
57  return doClose();
58  }
59 
60  bool doWrite(const void *x, size_t bytes) override;
61  bool doRead(void *x, size_t bytes) override;
62 
63 private: // Aux Methods
64  bool doOpen(std::string const &config, std::string const &flags);
65  bool doClose();
66 
67 private: // Data Members
68  FILE *file_;
69 };
70 
71 } // namespace serialize
72 } // namespace map
73 } // namespace ad
ad
namespace ad
Definition: GeometryStoreItem.hpp:28
ad::map::serialize::IStorage
Storage Interface.
Definition: IStorage.hpp:26
ad::map::serialize::StorageFile
File Storage implementation.
Definition: StorageFile.hpp:27
IStorage.hpp