Archive based on NetCDF. More...
#include <NetCDFArchive.h>
Public Member Functions | |
NetCDFArchive (OpenModeKind mode, const std::string &directory, const std::string &prefix) | |
Initialize the archive. More... | |
void | readMetaDataFromJson () |
Load meta-data from JSON file. | |
void | writeMetaDataToJson () |
Convert meta-data to JSON and serialize to file. | |
Archive implementation | |
| |
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. More... | |
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. More... | |
virtual void | updateMetaData () override |
Update the meta-data on disk. | |
virtual OpenModeKind | mode () const override |
Open-policy of the archive. | |
virtual std::string | directory () const override |
Directory to write/read files. | |
virtual std::string | prefix () const override |
Prefix of all files. | |
virtual std::string | name () const override |
Name of the archive. | |
virtual std::string | metaDataFile () const override |
Full file path to the meta-data file. | |
virtual std::ostream & | toStream (std::ostream &stream) const override |
Convert the archive to stream. | |
virtual void | clear () override |
Clear the archive i.e remove all data from disk and reset the internal data-structures. | |
virtual bool | isReadingThreadSafe () const override |
Indicate whether it's safe for multiple threads to call Archive::read. | |
virtual bool | isWritingThreadSafe () const override |
Indicate whether it's safe for multiple threads to call Archive::write. | |
virtual bool | isSlicedReadingSupported () const override |
Indicate whether the archive supports StorageViews with attached slices. | |
Public Member Functions inherited from serialbox::Archive | |
virtual | ~Archive () |
Vritual destructor. | |
Static Public Member Functions | |
static std::unique_ptr< Archive > | create (OpenModeKind mode, const std::string &directory, const std::string &prefix) |
Create a NetCDFArchive. | |
static void | writeToFile (std::string filename, const StorageView &storageView, const std::string &field) |
Directly write field (given by storageView ) to file. More... | |
static void | readFromFile (std::string filename, StorageView &storageView, const std::string &field) |
Directly read field (given by storageView ) from file. More... | |
Static Public Attributes | |
static const std::string | Name = "NetCDF" |
Name of the NetCDF archive. | |
static const int | Version = 0 |
Revision of the NetCDF archive. | |
Archive based on NetCDF.
Definition at line 35 of file NetCDFArchive.h.
serialbox::NetCDFArchive::NetCDFArchive | ( | OpenModeKind | mode, |
const std::string & | directory, | ||
const std::string & | prefix | ||
) |
Initialize the archive.
mode | Policy to open files in the archive |
directory | Directory to write/read files. If the archive is opened in ´Read´ mode, the directory is expected to supply an ´ArchiveMetaData-prefix.json´. In case the archive is opened in ´Write´ mode, the directory will be cleansed from all files matching the pattern ´prefix_*.nc´, if the directory is non-existent, it will be created. The ´Append´ mode will try to open ´ArchiveMetaData-prefix.json´ if the directory exists otherwise create it. |
prefix | Prefix of all files followed by an underscore ´_´ and fieldname |
skipMetaData | Do not read meta-data from disk |
Definition at line 168 of file NetCDFArchive.cpp.
|
overridevirtual |
Read the field identified by fieldID
and given by storageView
from disk.
storageView | Abstract StorageView of the underlying data |
fieldID | Name and and Id of the field |
info | Field meta-information (can be a nullptr ) |
Implements serialbox::Archive.
Definition at line 404 of file NetCDFArchive.cpp.
|
static |
Directly read field (given by storageView
) from file.
This function can be used to implement stateless deserialization methods.
filename | File to read from |
storageView | StorageView of the field |
field | Name of the field |
Definition at line 455 of file NetCDFArchive.cpp.
|
overridevirtual |
Write the field
given by storageView
to disk.
The returned FieldID
has to uniquely identify the field i.e it should be possible to read the exact same piece of data when later passing the FieldID
to the read method.
storageView | Abstract StorageView of the underlying data |
field | Name of the field |
info | Field meta-information (can be a nullptr ) |
Implements serialbox::Archive.
Definition at line 275 of file NetCDFArchive.cpp.
|
static |
Directly write field (given by storageView
) to file.
filename | Newly created file (if file already exists, it's contents will be discarded) |
storageView | StorageView of the field |
field | Name of the field |
Definition at line 361 of file NetCDFArchive.cpp.