Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
serialbox::MockArchive Class Reference

Mock archive. More...

#include <MockArchive.h>

Inheritance diagram for serialbox::MockArchive:
serialbox::Archive

Public Member Functions

 MockArchive (OpenModeKind mode)
 Initialize the archive.
 
Archive implementation
See also
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. 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 Attributes

static const std::string Name = "Mock"
 Name of the Mock archive.
 

Detailed Description

Mock archive.

This archive does not actually write or read any data from disk, instead it fills the fields with random data. A simple multiplicative congruential pseudo-random number generator (std::minstd_rand) is used and seeded with current time. The returned random variables range from -1.0 to 1.0 (floating point) or 0 to 100 for integers.

This archive is only supported in OpenModeKind::Read.

Definition at line 33 of file MockArchive.h.

Member Function Documentation

◆ read()

void serialbox::MockArchive::read ( StorageView storageView,
const FieldID fieldID,
std::shared_ptr< FieldMetainfoImpl info 
) const
overridevirtual

Read the field identified by fieldID and given by storageView from disk.

Parameters
storageViewAbstract StorageView of the underlying data
fieldIDName and and Id of the field
infoField meta-information (can be a nullptr)

Implements serialbox::Archive.

Definition at line 80 of file MockArchive.cpp.

◆ write()

FieldID serialbox::MockArchive::write ( const StorageView storageView,
const std::string &  field,
const std::shared_ptr< FieldMetainfoImpl info 
)
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.

Parameters
storageViewAbstract StorageView of the underlying data
fieldName of the field
infoField meta-information (can be a nullptr)
Returns
Unique identidier of the field

Implements serialbox::Archive.

Definition at line 74 of file MockArchive.cpp.


The documentation for this class was generated from the following files: