C3D Toolkit  Kernel - 117982, Vision - 2.9.2.2
iobuf Class Reference

Stream buffer. More...

#include <io_buffer.h>

+ Inheritance diagram for iobuf:
+ Collaboration diagram for iobuf:

Public Member Functions

 iobuf (uint16 clusterSize)
 Constructor.
 
virtual ~iobuf ()
 Destructor.
 
virtual bool open (FileSpace &file, uint8 om, const VersionContainer &, bool fullCheck=true)
 Open the file if it is one's own file. The flag fullCheck == false switches off excessive checks (for the sake of performance).
 
bool del (FileSpace &file)
 Free space allocated for the file.
 
bool truncate (FileSpace &file, size_t from)
 Truncate the file. More...
 
bool speedOnClose () const
 Is to be ordered while closing.
 
void speedOnClose (bool s)
 Set the flag of ordering while closing.
 
virtual void free (size_t c)
 Free the cluster.
 
- Public Member Functions inherited from iobuf_Seq
 iobuf_Seq (uint16 clusterSize)
 Constructor.
 
virtual ~iobuf_Seq ()
 Destructor.
 
void Reserve (size_t n, bool addAdditionalSpace=true)
 < Reserve space for a given number of elements. More...
 
void Flush ()
 Free the whole memory.
 
void HardFlush ()
 Free the unnecessary memory.
 
void Adjust ()
 Add an element to the end of the array.
 
ClusterAdd ()
 Add a given element to the end of the array.
 
ClusterAdd (const Cluster &e)
 Get the number of elements in array.
 
Clusteroperator[] (size_t loc) const
 Access by index operator. More...
 
int gc ()
 Get the next byte from the buffer.
 
size_t getn (void *, size_t)
 Get the next n bytes from the buffer elementwise.
 
size_t getln (void *, size_t)
 Get the next n bytes from the buffer by copying the storage area.
 
int pc (uint8 c)
 Get the next byte from the buffer but don't shift the pointer to the next one. More...
 
size_t putn (const void *, size_t)
 Put the next n bytes to the buffer elementwise.
 
size_t putln (const void *, size_t)
 Put the next n bytes to the buffer by copying the storage area.
 
void advance ()
 If current buffer exhausted, advance pointer to the next one.
 
bool good () const
 Whether the buffer state is correct.
 
bool eof () const
 Is the end of file reached?
 
uint32 state () const
 Get the buffer state.
 
void setState (io::state add)
 Add the buffer state.
 
void clearState (io::state sub)
 Remove the buffer state.
 
io::pos size () const
 Calculate the current file size.
 
io::pos tell () const
 Returns the current position in the file.
 
void lseek (size_t pos=SYS_MAX_T)
 Set current position in the buffer.
 
bool attach (FileSpace &file, bool check=true)
 Attach the file to the buffer with or without checking.
 
bool openSys (uint8 om)
 Open the system file.
 
virtual void close ()
 Close the file.
 
virtual void closeBuff ()
 Close the buffer.
 
virtual FileSpaceenterFileSpace (uint8)
 Set FileSpace with given index for writing (create if necessary).
 
virtual FileSpaceenterFileSpace (const ClusterReference &, bool)
 Set position for for writing/reading by given ClusterReference. If saveCurr = true, save previous position.
 
virtual FileSpaceenterFileSpace (const ClusterReference &, FileSpace *, bool)
 Set position for writing/reading by given FileSpace and ClusterReference. Warning: in this function, ClusterReference.clusterIndex should contain an index in array of cluster indices in FileSpace! If saveCurr = true, save previous position.
 
virtual FileSpacereturnToPreviousFileSpace ()
 Set previous FileSpace for writing/reading.
 
ClusterReference getCurrentClusterPos ()
 Get current position in the buffer.
 
FileSpacesysFile ()
 Get access to the system file.
 
FileSpaceopenedFile () const
 Get access to the open file.
 
virtual size_t DOSFileLen () const
 The storage data size (of the file on the disk).
 
virtual const TCHAR * DOSFileName () const
 Storage name (of file on the disk).
 
bool fresh () const
 Is the buffer fresh?
 
void fresh (bool f)
 Set the state of buffer freshness.
 
bool modified () const
 Is the buffer modified?
 
void modified (bool m)
 Set the state of modified buffer.
 
uint8 mode () const
 Get the buffer mode.
 
void mode (uint8 m)
 Set the buffer mode.
 
bool IsInMode () const
 Is in the reading mode?
 
bool IsOutMode () const
 Is in the writing mode?
 
bool IsInOrOutMode () const
 Is in the reading or writing mode?
 
bool deleteIfEmpty () const
 Is the empty file to be deleted?
 
void deleteIfEmpty (bool s)
 Set the flag of deleting the empty file.
 
bool deleteOnClose () const
 Is the file to be deleted while closing the buffer?
 
void deleteOnClose (bool s)
 Set the flag of deleting the file while closing the buffer.
 
void SetVersionsByStorage ()
 Set the current version to be equal to the storage version.
 
VERSION MathVersion () const
 Return the main version (of the mathematical kernel).
 
VERSION AppVersion (size_t ind=-1) const
 Return the additional version (of the target application).
 
const VersionContainerGetVersionsContainer () const
 Get the buffer versions.
 
VERSION GetStorageVersion ()
 Get the storage version.
 
VERSION GetFormatVersion () const
 Get the format version.
 
void SetFormatVersion (VERSION version)
 Set the format version.
 

Protected Attributes

FileSpace freed
 List of released clusters.
 
- Protected Attributes inherited from iobuf_Seq
uint8 * base
 Pointer to the beginning of the buffer.
 
uint8 * ptr
 Pointer to the next byte.
 
uint8 * end
 Pointer to the end of the file.
 
VERSION storageVers
 The storage version (must be before 'curFileVers').
 
VersionContainer curFileVers
 Version of the current open file (stream).
 
VERSION formatVersion
 The format version.
 
FileSpace sys
 System file.
 
PArray< FileSpacefiles
 List of files contained in iobuf_Seq (the first element is the address of 'sys').
 
FileSpacecurr
 Current open file (stream).
 
size_t part
 Current cluster in the current open file.
 
uint16 clusterSize
 Cluster size.
 
uint8 bufferMode
 Buffer mode.
 
uint8 curFileMode
 Mode of opening the current file.
 
bool modifiedFlag
 The buffer has been modified.
 
bool freshFlag
 Is the buffer fresh.
 

Friends

class tape
 

Additional Inherited Members

- Protected Member Functions inherited from iobuf_Seq
int underflow ()
 Called when the whole buffer are read, but it is necessary to continue reading.
 
int overflow (uint8 ch)
 Called when the buffer is full but it is necessary to continue writing.
 
virtual int setup ()=0
 Set the next buffer.
 
virtual int flush ()=0
 Flush the buffer.
 
void checkEof ()
 Set the end of file if necessary.
 
size_t avail () const
 Get the number of unprocessed bytes in the buffer.
 
size_t waiting () const
 Get the number of processed bytes in the buffer.
 
bool mine (FileSpace &)
 Check if the file is mine.
 
void SetVersionsContainer (const VersionContainer &vers)
 Set the version of open file.
 
VERSION SetStorageVersion (VERSION)
 Set the storage version.
 

Detailed Description

Stream buffer.

Stream buffer - the base class.
FileSpace freed - the list of freed clusters. When the file is deleted, all its clusters are moved here. When the modified Catalog is being closed, all the clusters are deleted from 'freed' which physically lie after the last used cluster. After that the contents of 'freed' is written to 'sys'. While writing, when it is necessary to allocate the new cluster, this array is firstly checked for availability of free clusters. Clusters in 'freed' are always ordered by shift from the beginning of the file.

Member Function Documentation

◆ truncate()

bool iobuf::truncate ( FileSpace file,
size_t  from 
)

Truncate the file.

Detach file from the buffer.


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