Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
MockArchive.h
Go to the documentation of this file.
1 //===-- serialbox/core/archive/MockArchive.h ----------------------------------------*- C++ -*-===//
2 //
3 // S E R I A L B O X
4 //
5 // This file is distributed under terms of BSD license.
6 // See LICENSE.txt for more information
7 //
8 //===------------------------------------------------------------------------------------------===//
9 //
13 //===------------------------------------------------------------------------------------------===//
14 
15 #ifndef SERIALBOX_CORE_ARCHIVE_MOCKARCHIVE_H
16 #define SERIALBOX_CORE_ARCHIVE_MOCKARCHIVE_H
17 
19 #include <random>
20 
21 namespace serialbox {
22 
33 class MockArchive : public Archive {
34 public:
36  static const std::string Name;
37 
40 
44  virtual FieldID write(const StorageView& storageView, const std::string& fieldID,
45  const std::shared_ptr<FieldMetainfoImpl> info) override;
46 
47  virtual void read(StorageView& storageView, const FieldID& fieldID,
48  std::shared_ptr<FieldMetainfoImpl> info) const override;
49 
50  virtual void updateMetaData() override {}
51 
52  virtual OpenModeKind mode() const override { return mode_; }
53 
54  virtual std::string directory() const override { return directory_; }
55 
56  virtual std::string prefix() const override { return prefix_; }
57 
58  virtual std::string name() const override { return MockArchive::Name; }
59 
60  virtual std::string metaDataFile() const override { return metaDataFile_; }
61 
62  virtual std::ostream& toStream(std::ostream& stream) const override;
63 
64  virtual void clear() override {}
65 
66  virtual bool isReadingThreadSafe() const override { return true; }
67 
68  virtual bool isWritingThreadSafe() const override { return true; }
69 
70  virtual bool isSlicedReadingSupported() const override { return false; }
72 
73 private:
74  OpenModeKind mode_;
75  std::string directory_;
76  std::string prefix_;
77  std::string metaDataFile_;
78 };
79 
80 } // namespace serialbox
81 
82 #endif
virtual bool isReadingThreadSafe() const override
Indicate whether it&#39;s safe for multiple threads to call Archive::read.
Definition: MockArchive.h:66
virtual void updateMetaData() override
Update the meta-data on disk.
Definition: MockArchive.h:50
virtual void read(StorageView &storageView, const FieldID &fieldID, std::shared_ptr< FieldMetainfoImpl > info) const override
Read the field identified by fieldID and given by storageView from disk.
Definition: MockArchive.cpp:80
virtual std::string metaDataFile() const override
Full file path to the meta-data file.
Definition: MockArchive.h:60
Represent a mutable view to a multi-dimensional storage.
Definition: StorageView.h:33
Namespace of the serialbox library.
Definition: Archive.h:25
Mock archive.
Definition: MockArchive.h:33
Uniquely identifiy a field.
Definition: FieldID.h:27
virtual std::ostream & toStream(std::ostream &stream) const override
Convert the archive to stream.
virtual bool isWritingThreadSafe() const override
Indicate whether it&#39;s safe for multiple threads to call Archive::write.
Definition: MockArchive.h:68
virtual FieldID write(const StorageView &storageView, const std::string &fieldID, const std::shared_ptr< FieldMetainfoImpl > info) override
Write the field given by storageView to disk.
Definition: MockArchive.cpp:74
virtual std::string name() const override
Name of the archive.
Definition: MockArchive.h:58
OpenModeKind
Policy for opening files in the Serializer and Archive.
Definition: Type.h:40
static const std::string Name
Name of the Mock archive.
Definition: MockArchive.h:36
virtual bool isSlicedReadingSupported() const override
Indicate whether the archive supports StorageViews with attached slices.
Definition: MockArchive.h:70
virtual void clear() override
Clear the archive i.e remove all data from disk and reset the internal data-structures.
Definition: MockArchive.h:64
virtual std::string directory() const override
Directory to write/read files.
Definition: MockArchive.h:54
virtual OpenModeKind mode() const override
Open-policy of the archive.
Definition: MockArchive.h:52
virtual std::string prefix() const override
Prefix of all files.
Definition: MockArchive.h:56
MockArchive(OpenModeKind mode)
Initialize the archive.
Definition: MockArchive.cpp:71
Abstract interface for Archives.
Definition: Archive.h:30