#include <djv_chunks.h>
Public Types | |
enum | DisconnectMethod { dm_OnMemory = 0, dm_OnTempFile = 1, dm_AllOnTempFile = 2 } |
typedef SimpleArray< AutoPtr < Chunk > > | Array |
typedef void(* | OnChunkCallback )(void *inContext, Chunk *inChunkLoaded) |
typedef String(* | RenameFunc )(void *inContext, const String &inOldName, const Chunk *inTarget, size_t inTrial) |
Public Member Functions | |
virtual String | getId () const =0 |
virtual const Data * | getData () const =0 |
virtual void | setData (const Data *inData)=0 |
virtual const Array & | getChildren () const =0 |
virtual Array & | getChildren ()=0 |
virtual size_t | find (const String &inIdentifier, size_t inPrevPos=(size_t) 0-1, bool inOnlyAvailable=false) const =0 |
virtual size_t | find (const String &inId1, const String &inId2, size_t inPrevPos=(size_t) 0-1, bool inOnlyAvailable=false) const =0 |
virtual bool | isIncluded () const =0 |
virtual bool | isAvailable () const =0 |
virtual bool | isCollection () const =0 |
virtual void | preload (OnChunkCallback inOnChunkCallback=NULL, void *inContext=NULL)=0 |
virtual void | prepareForMerger (const Chunk *inChunkMergeTo, std::map< String, String > *outNameRemappings=NULL, bool inDoingAutoNavmAnnoRemapping=true, RenameFunc inRenameFunc=NULL, void *inRenameContext=NULL)=0 |
virtual void | compact ()=0 |
virtual void | disconnectFromOriginalSources (DisconnectMethod inDisconnectMethod=dm_OnTempFile, OnChunkCallback inOnChunkCallback=NULL, void *inContext=NULL, Storage *inTemporaryStorage=NULL)=0 |
virtual void | setSecurityProvider (const SecurityProvider *inSecProv)=0 |
virtual const SecurityProvider * | getSecurityProvider () const =0 |
virtual void | lock () const =0 |
virtual void | unlock () const =0 |
virtual Chunk * | getDirectPointer ()=0 |
virtual String | getName () const =0 |
Public Member Functions inherited from Celartem::Referable | |
Referable () | |
void | addRef () const |
void | releaseRef () const |
size_t | getReferenceCount () const |
Static Public Member Functions | |
static AutoPtr< Chunk > | create (const String &inIdentifier) |
static AutoPtr< Chunk > | create (const String &inIdentifier, const void *inData, size_t inDataSize) |
static AutoPtr< Chunk > | create (const String &inIdentifier, Stream *inDataStream) |
static AutoPtr< Chunk > | createCollection (const String &inIdentifier) |
Static Public Member Functions inherited from Celartem::Referable | |
static void | dumpDbgAllRefCount () |
An abstract class which defines the requirements for chunks.\n Please note that the methods on a \ref Chunk instance is not serialized; they're not thread-safe. If you want to use the same instance between threads, you should lock the instance (by calling \ref lock or using \ref Locker class) before manipulation on it. The following code illustrates this:
typedef SimpleArray<AutoPtr<Chunk> > Celartem::DjVu::Chunk::Array |
Definition of Array which is usually used for accessing each child Chunk element.
typedef void(* Celartem::DjVu::Chunk::OnChunkCallback)(void *inContext, Chunk *inChunkLoaded) |
typedef String(* Celartem::DjVu::Chunk::RenameFunc)(void *inContext, const String &inOldName, const Chunk *inTarget, size_t inTrial) |
Function definition for chunk renaming on prepareForMerger call.
inContext | The parameter renameContext passed to prepareForMerger call. |
inOldName | The old name of the rename target chunk. |
inTarget | The rename target chunk. |
inTrial | A number which indicates how much calls before this call for this chunk. This method may be called repeatedly if the name returned on the previous call returns a name which does not fit to the situation (such as name already exists or invalid characters in the name, ...). |
|
pure virtual |
Minimize the memory usage by removing reserved area.
This is useful when reducing memory fragmentation due to complicated process.
Create a Chunk instance.
inIdentifier | 4 character identifier used with the newly created chunk. |
Referenced by Celartem::DjVu::PageInfo::encodeINFOChunk().
|
static |
Create a Chunk instance.
inIdentifier | 4 character identifier used with the newly created chunk. |
inData | The data to be associated. Please note that this data is duplicated to the newly created Chunk instance. |
inDataSize | The size of the data. |
Create a collection Chunk instance, which can contain multiple Chunk instance in it.
inIdentifier | 4 character identifier used with the newly created chunk. |
|
pure virtual |
This method ensures that the original source file is released and all the data referenced from the chunk is moved to other safe storage (memory or some temporary file).
It ensures the source file can be modified, overwritten or deleted.
Method | to disconnect from the original sources. |
inOnChunkCallback | Pointer to a callback function which will be called when each chunk is loaded. |
inContext | A user defined data which is passed to the callback function. |
inTemporaryStorage | Specify the external temporary storage instance if inDisconnectMethod is one of dm_OnTempFile or dm_AllOnTempFile. It can be NULL if you don't have to specify temporary storage explicitly. |
|
pure virtual |
Search for the specified chunk.
inIdentifier | The chunk identifier such as DJVU , INFO . |
inPrevPos | The index returned by the previous call to this method. To start search from the first element, set (size_t)-1 for this.This is useful when finding multiple occurrences of the chunks such as BG44 . |
inOnlyAvailable | If this is true , this method searchs only available chunks (For more about available chunks, see isAvailable method. |
|
pure virtual |
Search for the specified chunk.
This is a special version which takes two identifiers and returns the occurrence of either inId1 or inId2.
Some of the DjVu chunks such as TXTz
and ANTz
have uncompressed versions; TXTa
and ANTa
. This method is designed for searching such kind of chunks.
inId1 | The chunk identifier. |
inId2 | The chunk identifier. |
inPrevPos | The index returned by the previous call to this method. To start search from the first element, set (size_t)-1 for this.This is useful when finding multiple occurrences of the chunks such as BG44 . |
inOnlyAvailable | If this is true , this method searchs only available chunks (For more about available chunks, see isAvailable method. |
|
pure virtual |
Get the child elements. (const version)
FORM
) chunk, this method throws an exception.If you want to use a Chunk instance between threads, you should firstly aquire the lock of the instance and then use the returned Array instance.
|
pure virtual |
|
pure virtual |
Get the associated Data instance. (const version)
NULL
if no data is assigned. Referenced by Celartem::DjVu::PageInfo::decode().
|
pure virtual |
|
pure virtual |
Get the identifier of this chunk.
|
pure virtual |
Get the name for this chunk, which is listed in DIRM
if available.
|
pure virtual |
Get the SecurityProvider instance associated to this chunk.
NULL
.
|
pure virtual |
Determine whether the chunk data is already available or not.
This method determines whether all the data of the chunk is loaded onto the memory or not. To make sure all of them are on memory, use preload.
true
if the data is already available; otherwise false
.
|
pure virtual |
Determine whether the instance is a collection or not.
true
if this is a collection instance; otherwise false
.
|
pure virtual |
Determine whether the chunk is included by INCL
indirection chunk or not.
true
if the chunk is included by INCL
; otherwise false
.
|
pure virtual |
Lock 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.
Implements Celartem::Lockable.
|
pure virtual |
Load all the data synchronously.
This method ensures that all the data and descending chunks are ready to use.
inOnChunkCallback | Pointer to a callback function which will be called when each chunk is loaded. |
inContext | A user defined data which is passed to the callback function. |
|
pure virtual |
Prepare for the merger with the specified DJVM
chunk. Each DJVU chunks are usually managed by a name and if multiple DjVu files are merged into a DjVu file, it may cause some confliction in names. This method renames such chunks before the actual merge process. This method also removes shared annotation to reduce confliction with the merger document.
inChunkMergeTo | Pointer to a DJVM Chunk instance to merge with. |
outNameRemappings | A map instance which receives name remapping list (old to new) for further process. It can be NULL if you don't need such information. |
inDoingAutoNavmAnnoRemapping | true to instruct this method to do updating NAVM and ANTz , ANTa chunks. |
inRenameFunc | Optional function to rename chunks. |
inRenameContext | Optional parameter, which is passed to rename function. |
|
pure virtual |
Set the data to this chunk. The Data instance passed is retained by this Chunk instance.
inData | Data to assign. |
|
pure virtual |
Set a SecurityProvider instance to this chunk.
Only collection chunk can have SecurityProvider.
inSecProv | Pointer to a SecurityProvider instance. |
|
pure virtual |