AtlasResourceTOC< StubTypeT > Class Template Reference [Atlas Core]

#include <atlasResourceTOC.h>

Inheritance diagram for AtlasResourceTOC< StubTypeT >:

Inheritance graph
[legend]
List of all members.

Detailed Description


template<class StubTypeT> class AtlasResourceTOC< StubTypeT >

Base resource TOC implementation.

This is where most of the meat vis a vis paged loading of chunks, as well as generation of Atlas files, occurs. This adds several important elements to AtlasBaseTOC, most notably typed implementations of a prioritized background loader for that TOC, and functionality to write updates to the Atlas file.


Public Types

typedef StubTypeT StubType
typedef AtlasBaseTOC< StubTypeT > Parent
typedef Parent::ChunkType ChunkType
 Bring the chunk type in as a local typedef to save indirection.

Public Member Functions

 AtlasResourceTOC ()
virtual void instateLoadedChunk (StubType *stub, ChunkType *chunk)
 Instate a loaded chunk into a stub.
virtual void purgeStub (StubType *stub)
 Purge a stub's chunk. Forcibly remove a stub's paged data from memory.
virtual void instateNewChunk (StubType *stub, ChunkType *chunk, bool blockTillSerialized=false)
 Instate a new chunk into a stub.
virtual void cbPostBackToAtlasFile (U32 key, AtlasDeferredIO *adio)
 Internal callback to indicate to the AtlasFile that we have a pending deserialize.
virtual void generate (RectI invalidationRegion)
 Regenerate all the chunks that overlap with the invalidated region.
virtual void immediateLoad (StubType *stub, U32 reason)
 Forcibly load a file immediately.
virtual void requestLoad (StubType *stub, U32 reason, F32 priority)
 Called by an instance TOC when load requests are made.
virtual void cancelLoadRequest (StubType *stub, U32 reason)
 Called by an instance TOC when load requests are cancelled.
virtual bool write (Stream *s)
 Write the whole TOC to a stream.
virtual bool read (Stream *s)
 Read the whole TOC from a stream.
void queueStubUpdate (StubType *t)
 Reserialize the passed stub to disk.
void recalculateUpdates (Vector< AtlasReadNote * > &list, U32 maxItems)
 Fill provided vector with up to maxItems load requests for this TOC, sorted by priority.
virtual void dumpStubLoadStatus (U32 stubIdx)
 Used to dump the load request status of the specified stub.
AtlasChunkconstructNewChunk ()
 Construct a new chunk of the apropriate type and link it to this TOC.
U32 getFormatVersion ()
 Return the current file format version; ie, the version we loaded.
virtual bool copyFromTOC (AtlasResourceTOC< StubType > *toc)
 Copy ourselves from the specified TOC.
virtual bool copyChunksToTOC (AtlasResourceTOC< StubType > *toc, S32 reformat=-1)
 Copy all of our chunks to another TOC.
virtual void getIOStatus (AtlasFile::IOStatus::TOCIOStatus &status)
 Fill in the TOC I/O status structure.

Static Public Member Functions

static S32 updateStubSortFunc (const void *a, const void *b)
 Sort function for recalculateUpdates().

Static Public Attributes

static const U32 csmVersion = 160
 Atlas file version.

Protected Member Functions

virtual void cbOnChunkWriteComplete (U32 key, AtlasDeferredIO *adio)
virtual void cbOnStubWriteComplete (U32 key, AtlasDeferredIO *adio)
virtual void cbOnChunkReadComplete (U32 key, AtlasChunk *adio)
virtual void cbOnChunkReadStarted (U32 stubIdx)
virtual void cbPopulateChunkReadNote (AtlasReadNote *arn)
virtual void queueChunkUpdate (StubType *t)
virtual void syncCallback (const F32 deltaTime)
 This gets called back from AtlasFile::syncThreads, with time in seconds since last call.

Protected Attributes

U32 mVersion
 Version of file format that we read from.
Vector< StubType * > mLoadQueue
 Outstanding load requests.
U32 mNumStubsLoading
 Number of stubs currently in loading state.
U32 mNumChunksDeadOnArrival
 Number of stubs that no longer needed their chunk data when it finally arrived.
U32 mNumBytesPending
 Number of chunk bytes in pending state.
U32 mNumBytesLoading
 Number of chunk bytes in loading state.


Member Typedef Documentation

template<class StubTypeT>
typedef StubTypeT AtlasResourceTOC< StubTypeT >::StubType

template<class StubTypeT>
typedef AtlasBaseTOC<StubTypeT> AtlasResourceTOC< StubTypeT >::Parent

template<class StubTypeT>
typedef Parent::ChunkType AtlasResourceTOC< StubTypeT >::ChunkType

Bring the chunk type in as a local typedef to save indirection.

Reimplemented from AtlasBaseTOC< StubTypeT >.


Constructor & Destructor Documentation

template<class StubTypeT>
AtlasResourceTOC< StubTypeT >::AtlasResourceTOC (  )  [inline]


Member Function Documentation

template<class StubType>
void AtlasResourceTOC< StubType >::cbOnChunkWriteComplete ( U32  key,
AtlasDeferredIO adio 
) [inline, protected, virtual]

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::cbOnStubWriteComplete ( U32  key,
AtlasDeferredIO adio 
) [inline, protected, virtual]

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::cbOnChunkReadComplete ( U32  key,
AtlasChunk adio 
) [inline, protected, virtual]

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::cbOnChunkReadStarted ( U32  stubIdx  )  [inline, protected, virtual]

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::cbPopulateChunkReadNote ( AtlasReadNote arn  )  [inline, protected, virtual]

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::queueChunkUpdate ( StubType t  )  [inline, protected, virtual]

template<class StubTypeT>
virtual void AtlasResourceTOC< StubTypeT >::syncCallback ( const F32  deltaTime  )  [inline, protected, virtual]

This gets called back from AtlasFile::syncThreads, with time in seconds since last call.

It's useful for updating things like heat.

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::instateLoadedChunk ( StubType stub,
ChunkType chunk 
) [inline, virtual]

Instate a loaded chunk into a stub.

TOCs may want to perform callbacks or other book-keeing when a chunk is loaded, and this method provides a hook for that behavior.

Note:
chunk is required to be a valid chunk pointer.

template<class StubType>
void AtlasResourceTOC< StubType >::purgeStub ( StubType stub  )  [inline, virtual]

Purge a stub's chunk. Forcibly remove a stub's paged data from memory.

template<class StubType>
void AtlasResourceTOC< StubType >::instateNewChunk ( StubType stub,
ChunkType chunk,
bool  blockTillSerialized = false 
) [inline, virtual]

Instate a new chunk into a stub.

This queues the provided chunk for serialization, as well as the stub.

Note:
This is a superset of instateLoadedChunk().

template<class StubType>
void AtlasResourceTOC< StubType >::cbPostBackToAtlasFile ( U32  key,
AtlasDeferredIO adio 
) [inline, virtual]

Internal callback to indicate to the AtlasFile that we have a pending deserialize.

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::generate ( RectI  invalidationRegion  )  [inline, virtual]

Regenerate all the chunks that overlap with the invalidated region.

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::immediateLoad ( StubType stub,
U32  reason 
) [inline, virtual]

Forcibly load a file immediately.

Will cause a reload if the stub already has a chunk loaded.

template<class StubType>
void AtlasResourceTOC< StubType >::requestLoad ( StubType stub,
U32  reason,
F32  priority 
) [inline, virtual]

Called by an instance TOC when load requests are made.

template<class StubType>
void AtlasResourceTOC< StubType >::cancelLoadRequest ( StubType stub,
U32  reason 
) [inline, virtual]

Called by an instance TOC when load requests are cancelled.

template<class StubType>
bool AtlasResourceTOC< StubType >::write ( Stream s  )  [inline, virtual]

Write the whole TOC to a stream.

Reimplemented from AtlasTOC.

Reimplemented in AtlasResourceGeomTOC.

template<class StubType>
bool AtlasResourceTOC< StubType >::read ( Stream s  )  [inline, virtual]

Read the whole TOC from a stream.

Reimplemented from AtlasTOC.

Reimplemented in AtlasResourceGeomTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::queueStubUpdate ( StubType t  )  [inline]

Reserialize the passed stub to disk.

template<class StubTypeT>
static S32 AtlasResourceTOC< StubTypeT >::updateStubSortFunc ( const void a,
const void b 
) [inline, static]

Sort function for recalculateUpdates().

template<class StubType>
void AtlasResourceTOC< StubType >::recalculateUpdates ( Vector< AtlasReadNote * > &  list,
U32  maxItems 
) [inline, virtual]

Fill provided vector with up to maxItems load requests for this TOC, sorted by priority.

Used by the AtlasFile to implement our round-robin loading scheme.

Reimplemented from AtlasTOC.

template<class StubType>
void AtlasResourceTOC< StubType >::dumpStubLoadStatus ( U32  stubIdx  )  [inline, virtual]

Used to dump the load request status of the specified stub.

Reimplemented from AtlasTOC.

template<class StubTypeT>
AtlasChunk* AtlasResourceTOC< StubTypeT >::constructNewChunk (  )  [inline, virtual]

Construct a new chunk of the apropriate type and link it to this TOC.

Reimplemented from AtlasTOC.

template<class StubTypeT>
U32 AtlasResourceTOC< StubTypeT >::getFormatVersion (  )  [inline]

Return the current file format version; ie, the version we loaded.

See also:
csmVersion for the most modern supported version.

template<class StubTypeT>
virtual bool AtlasResourceTOC< StubTypeT >::copyFromTOC ( AtlasResourceTOC< StubType > *  toc  )  [inline, virtual]

Copy ourselves from the specified TOC.

This only copies stubs; chunks are handled separately.

template<class StubTypeT>
virtual bool AtlasResourceTOC< StubTypeT >::copyChunksToTOC ( AtlasResourceTOC< StubType > *  toc,
S32  reformat = -1 
) [inline, virtual]

Copy all of our chunks to another TOC.

Parameters:
reformat Optional parameter to request a reformat of the transferred data. This is passed to generateCopy.

template<class StubTypeT>
virtual void AtlasResourceTOC< StubTypeT >::getIOStatus ( AtlasFile::IOStatus::TOCIOStatus status  )  [inline, virtual]

Fill in the TOC I/O status structure.

Reimplemented from AtlasTOC.


Member Data Documentation

template<class StubTypeT>
U32 AtlasResourceTOC< StubTypeT >::mVersion [protected]

Version of file format that we read from.

template<class StubTypeT>
Vector<StubType*> AtlasResourceTOC< StubTypeT >::mLoadQueue [protected]

Outstanding load requests.

template<class StubTypeT>
U32 AtlasResourceTOC< StubTypeT >::mNumStubsLoading [protected]

Number of stubs currently in loading state.

template<class StubTypeT>
U32 AtlasResourceTOC< StubTypeT >::mNumChunksDeadOnArrival [protected]

Number of stubs that no longer needed their chunk data when it finally arrived.

template<class StubTypeT>
U32 AtlasResourceTOC< StubTypeT >::mNumBytesPending [protected]

Number of chunk bytes in pending state.

template<class StubTypeT>
U32 AtlasResourceTOC< StubTypeT >::mNumBytesLoading [protected]

Number of chunk bytes in loading state.

template<class StubTypeT>
const U32 AtlasResourceTOC< StubTypeT >::csmVersion = 160 [static]

Atlas file version.

For now we just increment a global counter for each revision of the file format.

101 - Stored bounding box for geom stubs, instead of min/max. Also stored bounds in the chunk.

120 - Added collision information to AtlasGeomChunk.

130 - Reordered vertex data to match order of structure.

140 - Added normals to AGC.

150 - added multi-layer AtlasTexChunks to support >4 blend layers.

160 - removed geomorphing information.