28 #ifndef CASA_MULTIFILEBASE_H
29 #define CASA_MULTIFILEBASE_H
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/IO/ByteIO.h>
34 #include <casacore/casa/BasicSL/String.h>
35 #include <casacore/casa/Utilities/CountedPtr.h>
36 #include <casacore/casa/vector.h>
37 #include <casacore/casa/ostream.h>
89 std::shared_ptr<MultiFileBuffer>
buffer;
237 const vector<MultiFileInfo>&
info()
const
268 const void* buffer) = 0;
Referenced counted pointer for constant data.
Abstract base class to combine multiple files in a single one.
Int64 blockSize() const
Get the block size used.
virtual void extend(MultiFileInfo &info, Int64 lastblk)=0
Extend the virtual file to fit lastblk.
virtual void writeHeader()=0
Write the header info.
MultiFileBase(const String &name, Int blockSize, Bool useODirect)
Open or create a MultiFileBase with the given name.
virtual void fsync()=0
Fsync the file (i.e., force the data to be physically written).
virtual void readHeader(Bool always=True)=0
Read the header info.
Int64 write(Int fileId, const void *buffer, Int64 size, Int64 offset)
Write a block at the given offset.
void resync()
Resync with another process by clearing the buffers and rereading the header.
vector< Int64 > itsFreeBlocks
vector< MultiFileInfo > itsInfo
Int addFile(const String &name)
Add a file to the MultiFileBase object.
Int fileId(const String &name, Bool throwExcp=True) const
Return the file id of a file in the MultiFileBase object.
Int64 size() const
Get the total nr of data blocks used.
void deleteFile(Int fileId)
Delete a file.
Int64 read(Int fileId, void *buffer, Int64 size, Int64 offset)
Read a block at the given offset.
String fileName() const
Get the file name of the MultiFileBase.
Bool useODirect() const
Will O_DIRECT be used?
virtual ~MultiFileBase()
The destructor flushes and closes the file.
Bool isWritable() const
Is the file writable?
virtual void doDeleteFile(MultiFileInfo &)=0
Do the class-specific actions on deleting a file.
virtual void writeBlock(MultiFileInfo &info, Int64 blknr, const void *buffer)=0
Write a data block.
virtual void reopenRW()=0
Reopen the underlying file for read/write access.
virtual void readBlock(MultiFileInfo &info, Int64 blknr, void *buffer)=0
Read a data block.
virtual void flushFile()=0
Flush the file itself.
const vector< MultiFileInfo > & info() const
Get the info object (for test purposes mainly).
virtual void close()=0
Flush and close the file.
void setNewFile()
Set the flags and blockSize for a new MultiFile/HDF5.
virtual void doAddFile(MultiFileInfo &)=0
Do the class-specific actions on adding a file.
void flush()
Flush the file by writing all dirty data and all header info.
const vector< Int64 > & freeBlocks() const
Get the free blocks (for test purposes mainly).
uInt nfile() const
Get the nr of virtual files.
std::shared_ptr< MultiFileBuffer > itsBuffer
void writeDirty(MultiFileInfo &info)
String: the storage and methods of handling collections of characters.
this file contains all the compiler specific defines
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
bool Bool
Define the standard types used by Casacore.
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
AipsIO & operator>>(AipsIO &os, Record &rec)
MultiFileBuffer(const MultiFileBuffer &)
MultiFileBuffer(size_t bufSize, Bool useODirect)
MultiFileBuffer & operator=(const MultiFileBuffer &)
Helper class for MultiFileBase containing info per internal file.
void allocBuffer(Int64 bufSize, Bool useODirect=False)
Allocate the buffer.
std::shared_ptr< MultiFileBuffer > buffer
CountedPtr< HDF5Group > group
MultiFileInfo(Int64 bufSize=0, Bool useODirect=False)
Initialize the object and create the buffer with the proper size.
CountedPtr< HDF5DataSet > dataSet