Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
Archive.h
Go to the documentation of this file.
1 //===-- serialbox/core/archive/Archive.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_ARCHIVE_H
16 #define SERIALBOX_CORE_ARCHIVE_ARCHIVE_H
17 
19 #include "serialbox/core/FieldID.h"
22 #include "serialbox/core/Type.h"
23 #include <iosfwd>
24 
25 namespace serialbox {
26 
30 class Archive {
31 public:
33  virtual ~Archive() {}
34 
44  virtual FieldID write(const StorageView& storageView, const std::string& field,
45  const std::shared_ptr<FieldMetainfoImpl> info) = 0;
46 
52  virtual void read(StorageView& storageView, const FieldID& fieldID,
53  std::shared_ptr<FieldMetainfoImpl> info) const = 0;
54 
56  virtual void updateMetaData() = 0;
57 
59  virtual std::string name() const = 0;
60 
62  virtual OpenModeKind mode() const = 0;
63 
65  virtual std::string directory() const = 0;
66 
68  virtual std::string prefix() const = 0;
69 
71  virtual std::string metaDataFile() const = 0;
72 
74  virtual void clear() = 0;
75 
77  virtual bool isReadingThreadSafe() const { return false; }
78 
80  virtual bool isWritingThreadSafe() const { return false; }
81 
83  virtual bool isSlicedReadingSupported() const { return false; }
84 
86  virtual std::ostream& toStream(std::ostream& stream) const = 0;
87 
89  friend std::ostream& operator<<(std::ostream& stream, const Archive& archive) {
90  return archive.toStream(stream);
91  }
92 };
93 
94 } // namespace serialbox
95 
96 #endif
virtual std::ostream & toStream(std::ostream &stream) const =0
Convert the archive to stream.
virtual void read(StorageView &storageView, const FieldID &fieldID, std::shared_ptr< FieldMetainfoImpl > info) const =0
Read the field identified by fieldID and given by storageView from disk.
virtual std::string prefix() const =0
Prefix of all files.
virtual void updateMetaData()=0
Update the meta-data on disk.
friend std::ostream & operator<<(std::ostream &stream, const Archive &archive)
Convert to stream.
Definition: Archive.h:89
virtual std::string directory() const =0
Directory to write/read files.
Represent a mutable view to a multi-dimensional storage.
Definition: StorageView.h:33
Namespace of the serialbox library.
Definition: Archive.h:25
virtual std::string metaDataFile() const =0
Full file path to the meta-data file.
Uniquely identifiy a field.
Definition: FieldID.h:27
virtual bool isWritingThreadSafe() const
Indicate whether it&#39;s safe for multiple threads to call Archive::write.
Definition: Archive.h:80
virtual bool isReadingThreadSafe() const
Indicate whether it&#39;s safe for multiple threads to call Archive::read.
Definition: Archive.h:77
virtual std::string name() const =0
Name of the archive.
virtual FieldID write(const StorageView &storageView, const std::string &field, const std::shared_ptr< FieldMetainfoImpl > info)=0
Write the field given by storageView to disk.
virtual ~Archive()
Vritual destructor.
Definition: Archive.h:33
virtual bool isSlicedReadingSupported() const
Indicate whether the archive supports StorageViews with attached slices.
Definition: Archive.h:83
OpenModeKind
Policy for opening files in the Serializer and Archive.
Definition: Type.h:40
virtual void clear()=0
Clear the archive i.e remove all data from disk and reset the internal data-structures.
virtual OpenModeKind mode() const =0
Open-policy of the archive.
Abstract interface for Archives.
Definition: Archive.h:30