Public Member Functions | Static Public Member Functions

Celartem::DjVu::MemoryData Class Reference

#include <djv_data.h>

Inheritance diagram for Celartem::DjVu::MemoryData:
Inheritance graph
[legend]

List of all members.

Public Member Functions

const u8getRawPtr () const
virtual size_t getSize () const
virtual AutoPtr< StoragegetReadOnlyStorage () const
virtual AutoPtr< Dataduplicate (bool inCompaction=false) const
virtual void compact ()
SimpleArray< u8 > & getSimpleArray ()
AutoPtr< MemoryStoragegetStorage ()
virtual void lock () const
virtual void unlock () const

Static Public Member Functions

static AutoPtr< MemoryDatacreate (size_t inSize=0, size_t inReserve=(size_t)-1, MemoryAllocator *inAllocator=NULL, size_t inAllocationUnit=0)
static AutoPtr< MemoryDatacreate (const void *inData, size_t inSize)
static AutoPtr< MemoryDatacreate (Storage *inStorage, uint64_t inOffset, size_t inSize)

Detailed Description

This implementation provides SimpleArray based data structure.


Member Function Documentation

virtual void Celartem::DjVu::MemoryData::compact (  )  [inline, virtual]

Minimize the memory usage by removing reserved area.

Implements Celartem::DjVu::Data.

static AutoPtr<MemoryData> Celartem::DjVu::MemoryData::create ( size_t  inSize = 0,
size_t  inReserve = (size_t)-1,
MemoryAllocator inAllocator = NULL,
size_t  inAllocationUnit = 0 
) [inline, static]

Creates a MemoryData instance on a memory.

Parameters:
inSize Specifies the size of the array in number of entries.
inReserve Specifies the reservation size of the array in number of entries. The reservation size is a parameter that controls relocation of the array. Although the larger reservation size assures you of the better speed performance of array resizing until the size surpasses the reservation size, it firstly request the reservation size of memory to the operating system.
inAllocator Specifies the MemoryAllocator instance that is used to allocate/deallocate memory blocks. It can be NULL and then SimpleArray uses the default allocator.
inAllocationUnit Specifies the unit size for allocation. For more information, see SimpleArray::setAllocationUnit.
Returns:
Pointer to the newly created MemoryData instance.
See also:
SimpleArray

Referenced by Celartem::DjVu::PageInfo::encodeINFOChunk(), getReadOnlyStorage(), and getStorage().

static AutoPtr<MemoryData> Celartem::DjVu::MemoryData::create ( const void *  inData,
size_t  inSize 
) [inline, static]

Creates a MemoryData instance by duplicating the specified data.

Parameters:
inData Pointer to a buffer which contains the data.
inSize The size of the data.
Returns:
Pointer to the newly created MemoryData instance.
static AutoPtr<MemoryData> Celartem::DjVu::MemoryData::create ( Storage inStorage,
uint64_t  inOffset,
size_t  inSize 
) [inline, static]

Creates a MemoryData instance by loading data from the specified storage block.

Parameters:
inStorage Storage which contains the data.
inOffset The data offset.
inSize The data size.
Returns:
Pointer to the newly created MemoryData instance.
virtual AutoPtr<Data> Celartem::DjVu::MemoryData::duplicate ( bool  inCompaction = false  )  const [inline, virtual]

Duplicate the Data instance.

Parameters:
inCompaction Whether the duplication process also does compaction of memory usage or not.
Returns:
Pointer to the newly created Data instance.

Implements Celartem::DjVu::Data.

const u8* Celartem::DjVu::MemoryData::getRawPtr (  )  const [inline]

Get the actual data.

Returns:
The pointer to the data.

Referenced by Celartem::DjVu::DataLocker::lock().

virtual AutoPtr<Storage> Celartem::DjVu::MemoryData::getReadOnlyStorage (  )  const [inline, virtual]

Get readonly Storage access to the actual data.
The caller should not write to the stream but only reads the data from it. The Storage should be rewound to the beginning position.

Returns:
Pointer to the Storage instance.

Implements Celartem::DjVu::Data.

SimpleArray<u8>& Celartem::DjVu::MemoryData::getSimpleArray (  )  [inline]

Get SimpleArray instance which manages actual data.

Returns:
A reference to the SimpleArray instance.
virtual size_t Celartem::DjVu::MemoryData::getSize (  )  const [inline, virtual]

Get the size of the data.

Returns:
The size of the data.

Implements Celartem::DjVu::Data.

AutoPtr<MemoryStorage> Celartem::DjVu::MemoryData::getStorage (  )  [inline]

Get Storage interface access to the memory data. This is just a helper method and it simply create MemoryStorage on the internal SimpleArray.

Returns:
Pointer to the newly created MemoryStorage instance.
See also:
MemoryStorage
virtual void Celartem::DjVu::MemoryData::lock (  )  const [inline, virtual]

Locks the instance.
This method provides a synchronization mechanism for processing the instance between threads.
If you plan to use the instance in multi-threaded program, it's recommended to lock the instance before accessing the data.

See also:
unlock, Locker, Lockable

Implements Celartem::DjVu::Data.

virtual void Celartem::DjVu::MemoryData::unlock (  )  const [inline, virtual]

Releases the lock on the instance.

See also:
lock, Locker, Lockable

Implements Celartem::DjVu::Data.


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

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:20.
Caminova Logo