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

#include <cel_storage.h>

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

Public Member Functions

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< 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 provides the definition of Storage interface.
For the storage class factory functions, see Storage Class Factory Functions.

See Also
Storage Class Factory Functions

Member Function Documentation

static AutoPtr<Storage> Celartem::Storage::create ( const String inUriOrFileName,
bool  inLateBinding = false,
ResourceBroker inBroker = NULL 
)
static

This method locates the resource and returns a pointer to read-only Storage instance.

Parameters
inUriOrFileNameURI or local file name of the resource. The default implementation can deal with URIs starts from http or file or local file names.
inLateBindingIf this parameter is true, this method actually never establish a connection to the resource but the first time when any of the methods of this instance is called, it tries to connect to the resource.
Otherwise, if this parameter is false, this method immediately connects to the resource within this method.
inBrokerA ResourceBroker instance which locates the file.
If NULL is specified, this method uses the default broker.
Returns
Pointer to the Storage instance of the specified resource. This method internally uses the shared instance of ResourceBroker class.
See Also
ResourceBroker::create
static AutoPtr<Storage> Celartem::Storage::createTempNoLock ( )
static

This method creates a temporary file with Read/Write access.
The file is not locked by the Storage instance but each time the file is accessed by a Storage method, it opens the file before the operation and closes the file after the operation.
It realizes that the file is not locked by the Storage instance and it reduces the handle/file desciptor count used by the application.

Returns
Pointer to the newly created storage.
virtual AutoPtr<Storage> Celartem::Storage::duplicate ( ) const
pure virtual

This method duplicates the storage instance, it is not to duplicate the reference count of the storage instance.

Returns
Pointer to the newly created copy of the Storage.
virtual Time Celartem::Storage::getLastUpdateTime ( ) const
pure virtual

This method returns the last update time of the file.

Returns
The last update time.
virtual uint64_t Celartem::Storage::getPos ( ) const
pure virtual

This method obtains the current storage pointer position in byte offset from the beginning of the storage.

Returns
The current storage pointer position.
virtual uint64_t Celartem::Storage::getSize ( ) const
pure virtual

This method obtains the current storage size in bytes.

Returns
The current storage size.

Referenced by Celartem::DjVu::StorageData::create().

virtual String Celartem::Storage::getStorageId ( ) const
pure virtual

This method returns the identifier of the storage.
It usually returns a filename or an URL that specifies the storage location. In cases with volatile storage, this function returns some string that is automatically generated by the storage class.

virtual void Celartem::Storage::reserve ( uint64_t  inReservationSize)
pure virtual

This method reserves the storage size. Since to resize the storage is not so simple work and it may takes so much time, you should reserve the size of storage in the first time. With this method, you don't have to care of the runtime costs of the resizing storage.
Please note that there are storages that is not implement the method. In any case, it never throws any exception but it may do nothing.

Parameters
inReservationSizeSize to reserve.
virtual void Celartem::Storage::setEof ( )
pure virtual

This method set the end mark to the current storage position. The following code sets the storage size:

void setStorageSize(Storage *inStorage, size_t inSize)
{
// firstly, preserves the current position
StorageRewinder sr(inStorage);
// set size
inStorage->setPos(inSize);
inStorage->setEof();
}
virtual void Celartem::Storage::setPos ( uint64_t  inPosition)
pure virtual

This method moves the storage pointer to the specified position. Please note that it is not an error to set the storage pointer to a position beyond the EOF. The size of the file does not increase until you call the writeBytes function. A write operation increases the size of the storage to the storage pointer position plus the size of the buffer written, leaving the intervening bytes uninitialized.

Parameters
inPositionPosition in byte offset from the beginning of the storage.
See Also
setPosRelative, setPosFromEnd

Referenced by Celartem::DjVu::MemoryData::create().

virtual void Celartem::Storage::setPosFromEnd ( int64_t  inPosition)
pure virtual

This method moves the storage pointer to the specified position. Please note that it is not an error to set the storage pointer to a position beyond the EOF. The size of the file does not increase until you call the writeBytes function. A write operation increases the size of the storage to the storage pointer position plus the size of the buffer written, leaving the intervening bytes uninitialized.

Parameters
inPositionPosition in byte offset from the current EOF.
See Also
setPos, setPosRelative
virtual void Celartem::Storage::setPosRelative ( int64_t  inPosition)
pure virtual

This method moves the storage pointer to the specified position. Please note that it is not an error to set the storage pointer to a position beyond the EOF. The size of the file does not increase until you call the writeBytes function. A write operation increases the size of the storage to the storage pointer position plus the size of the buffer written, leaving the intervening bytes uninitialized.

Parameters
inPositionPosition in byte offset from the current storage pointer position.
See Also
setPos, setPosFromEnd

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