Public Member Functions | Static Public Member Functions | List of all members
Celartem::DiskStorage Class Referenceabstract

#include <cel_storage.h>

Inheritance diagram for Celartem::DiskStorage:
Inheritance graph
[legend]

Public Member Functions

virtual void * getOSHandle ()=0
 
virtual void lockRegion (uint64_t inPos, uint64_t inSize, bool inWriterLock)=0
 
virtual bool tryLockRegion (uint64_t inPos, uint64_t inSize, bool inWriterLock)=0
 
virtual void unlockRegion (uint64_t inPos, uint64_t inSize)=0
 
- Public Member Functions inherited from Celartem::Storage
virtual uint64_t getSize () const =0
 
virtual uint64_t getPos () const =0
 
virtual void reserve (uint64_t inReservationSize)=0
 
virtual void setPos (uint64_t inPosition)=0
 
virtual void setPosRelative (int64_t inPosition)=0
 
virtual void setPosFromEnd (int64_t inPosition)=0
 
virtual void setEof ()=0
 
virtual String getStorageId () const =0
 
virtual AutoPtr< Storageduplicate () const =0
 
virtual Time getLastUpdateTime () const =0
 
- Public Member Functions inherited from Celartem::Stream
virtual size_t readBytes (void *buffer, size_t inSize, bool wouldBlock=false)=0
 
virtual void writeBytes (const void *buffer, size_t inSize)=0
 
virtual void flushBuffer ()=0
 
virtual bool isEof () const =0
 
virtual size_t duplicateStream (Stream *inStream, size_t inBufferSize=1024, DuplicateStreamCallback inCallback=NULL, void *inCallbackContext=NULL)
 
virtual size_t duplicateStreamBytes (Stream *inStream, size_t inMaximumByteSize, size_t inBufferSize=1024, DuplicateStreamCallback inCallback=NULL, void *inCallbackContext=NULL)
 
- Public Member Functions inherited from Celartem::Referable
 Referable ()
 
void addRef () const
 
void releaseRef () const
 
size_t getReferenceCount () const
 
- Public Member Functions inherited from Celartem::Lockable
virtual void lock () const =0
 
virtual void unlock () const =0
 

Static Public Member Functions

static AutoPtr< DiskStoragecreate (const Path &inFileName, AccessMode inAccessMode=accessRead, CreationMode inCreationMode=creationDefault, bool inThrowOnError=true)
 
static AutoPtr< DiskStoragecreateAnonTemp ()
 
static AutoPtr< DiskStoragecreateTemp (String &ioFileName)
 
static AutoPtr< DiskStoragecreateFromHandle (void *inFileHandle, AccessMode inAccessMode=accessRead, CreationMode inCreationMode=creationDefault, bool inCloseOnDelete=true)
 
- Static Public Member Functions inherited from Celartem::Storage
static AutoPtr< Storagecreate (const String &inUriOrFileName, bool inLateBinding=false, ResourceBroker *inBroker=NULL)
 
static AutoPtr< StoragecreateTempNoLock ()
 
- Static Public Member Functions inherited from Celartem::Referable
static void dumpDbgAllRefCount ()
 

Detailed Description

This class manages the files on the local storage.

See Also
storages, DiskStorageWillRollback

Member Function Documentation

static AutoPtr<DiskStorage> Celartem::DiskStorage::create ( const Path inFileName,
AccessMode  inAccessMode = accessRead,
CreationMode  inCreationMode = creationDefault,
bool  inThrowOnError = true 
)
static

This method opens a disk file. For AccessMode and CreationMode configuration, see AccessMode and CreationMode.

Parameters
inFileNameA file to open.
inAccessModeOne of the AccessMode enumerations.
inCreationModeOne of the CreationMode enumerations.
inThrowOnErrorWhether the function throws an exception on error or not. If it is false, the function returns NULL on errors.
Returns
Pointer to the newly created storage.
It may be NULL if you set inThrowOnError to false and the function fails.
See Also
DiskStorageWithRollback, Storage
static AutoPtr<DiskStorage> Celartem::DiskStorage::createAnonTemp ( )
static

This method opens an anonymous temporary file with Read/Write access. It also supports auto deletion of the file on the close of file; you don't have to call deleteFile call.

Returns
Pointer to the newly created storage.
static AutoPtr<DiskStorage> Celartem::DiskStorage::createFromHandle ( void *  inFileHandle,
AccessMode  inAccessMode = accessRead,
CreationMode  inCreationMode = creationDefault,
bool  inCloseOnDelete = true 
)
static

This method creates a DiskStorage instance based on the specified file handle.
For AccessMode and CreationMode configuration, see AccessMode and CreationMode.

Parameters
inFileHandleOn Windows, the handle is actually a HANDLE value, so you should cast the actual handle value to void* to pass to this method.
On UNIX variations, the handle is a file descriptor, which is usually described by an integer value. So you should cast the file descriptor to void* to pass to this method.
inAccessModeOne of the AccessMode enumerations.
This parameter actually does nothing with the actual operation on the file handle but for advisary.
inCreationModeOne of the CreationMode enumerations. This parameter actually does nothing with the actual operation on the file handle but for advisary.
inCloseOnDeleteIf this is true, the handle is automatically closed on destruction of the DiskStorage instance; otherwise, you should close the handle manually.
Returns
Pointer to the newly created storage.
static AutoPtr<DiskStorage> Celartem::DiskStorage::createTemp ( String ioFileName)
static

This method opens a temporary file, which name is based on the input filename, with Read/Write access.

Returns
Pointer to the newly created storage.
virtual void* Celartem::DiskStorage::getOSHandle ( )
pure virtual

This method returns the OS File handle used internally in this instance.
Note that direct access to the handle may conflict with the operation on the DiskStorage instance and you had better use DiskStorage methods rather than the handle.
On Windows, you should firstly cast this value to HANDLE.
On UNIX OSs, you should firstly cast this value to int.

Returns
OS Specific File handle.
virtual void Celartem::DiskStorage::lockRegion ( uint64_t  inPos,
uint64_t  inSize,
bool  inWriterLock 
)
pure virtual

This method locks a region in an opened file.
This method blocks until it acquires the lock to the region.
You had better use DiskStorageLock method rather than directly use this method to ensure the call to unlockRegion method.

Parameters
inPosThe start position of the region to lock.
inSizeThe length of the region to lock.
inWriterLocktrue if want an exclusive (writer) lock; false to shared (reader) lock.
virtual bool Celartem::DiskStorage::tryLockRegion ( uint64_t  inPos,
uint64_t  inSize,
bool  inWriterLock 
)
pure virtual

This method locks a region in an opened file.
This method fails unless it can acquire the lock to the region.

Parameters
inPosThe start position of the region to lock.
inSizeThe length of the region to lock.
inWriterLocktrue if want an exclusive (writer) lock; false to shared (reader) lock.
virtual void Celartem::DiskStorage::unlockRegion ( uint64_t  inPos,
uint64_t  inSize 
)
pure virtual

This method unlocks a region in an opened file.

Parameters
inPosThe start position of the region to unlock.
inSizeThe length of the region to unlock. The region to unlock must correspond exactly to the locked region.

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

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo