15 #ifndef SERIALBOX_CORE_ARCHIVE_NETCDFARCHIVE_H 16 #define SERIALBOX_CORE_ARCHIVE_NETCDFARCHIVE_H 19 #ifdef SERIALBOX_HAS_NETCDF 25 #include <unordered_map> 38 static const std::string
Name;
67 const std::shared_ptr<FieldMetainfoImpl> info)
override;
70 std::shared_ptr<FieldMetainfoImpl> info)
const override;
76 virtual std::string
directory()
const override {
return directory_.string(); }
78 virtual std::string
prefix()
const override {
return prefix_; }
82 virtual std::string
metaDataFile()
const override {
return metaDatafile_.string(); }
84 virtual std::ostream&
toStream(std::ostream& stream)
const override;
86 virtual void clear()
override;
98 const std::string&
prefix);
107 const std::string& field);
117 const std::string& field);
121 filesystem::path directory_;
123 filesystem::path metaDatafile_;
125 std::unordered_map<std::string, int> fieldMap_;
131 #endif // SERIALBOX_HAS_NETCDF virtual void updateMetaData() override
Update the meta-data on disk.
virtual bool isSlicedReadingSupported() const override
Indicate whether the archive supports StorageViews with attached slices.
virtual OpenModeKind mode() const override
Open-policy of the archive.
static const int Version
Revision of the NetCDF archive.
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.
virtual void clear() override
Clear the archive i.e remove all data from disk and reset the internal data-structures.
virtual std::string directory() const override
Directory to write/read files.
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.
static const std::string Name
Name of the NetCDF archive.
Represent a mutable view to a multi-dimensional storage.
Namespace of the serialbox library.
static void writeToFile(std::string filename, const StorageView &storageView, const std::string &field)
Directly write field (given by storageView) to file.
void writeMetaDataToJson()
Convert meta-data to JSON and serialize to file.
Uniquely identifiy a field.
virtual std::ostream & toStream(std::ostream &stream) const override
Convert the archive to stream.
virtual std::string name() const override
Name of the archive.
virtual bool isReadingThreadSafe() const override
Indicate whether it's safe for multiple threads to call Archive::read.
void readMetaDataFromJson()
Load meta-data from JSON file.
static void readFromFile(std::string filename, StorageView &storageView, const std::string &field)
Directly read field (given by storageView) from file.
OpenModeKind
Policy for opening files in the Serializer and Archive.
NetCDFArchive(OpenModeKind mode, const std::string &directory, const std::string &prefix)
Initialize the archive.
static std::unique_ptr< Archive > create(OpenModeKind mode, const std::string &directory, const std::string &prefix)
Create a NetCDFArchive.
virtual std::string metaDataFile() const override
Full file path to the meta-data file.
virtual std::string prefix() const override
Prefix of all files.
virtual bool isWritingThreadSafe() const override
Indicate whether it's safe for multiple threads to call Archive::write.
Abstract interface for Archives.