Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

LoadC Class Reference

Demopaja input stream. More...

#include <LoadC.h>

List of all members.

Public Methods

 LoadC (PluginClass::FactoryC *pFactory)
 Default constructor.

virtual ~LoadC ()
 Default destructor.

virtual PajaTypes::uint32 open (const char *szName, const PajaTypes::int8 *pSignature, PajaTypes::int32 i32SignatureSize)
 Opens input stream.

virtual PajaTypes::uint32 close ()
 Closes the input stream.

virtual PajaTypes::uint32 open_chunk ()
 Opens a chunk for read.

virtual PajaTypes::uint32 get_chunk_id ()
 Returns the ID if the currently open chunk, this value is used to determine different chunks.

virtual PajaTypes::uint32 get_chunk_version ()
 Returns the Version of the currently open chunk.

virtual PajaTypes::uint32 get_chunk_size ()
 Returns the size of the currently open chunk.

virtual PajaTypes::uint32 get_chunk_indent ()
 Returns the indentation level of the currently open chunk.

virtual PajaTypes::uint32 peek_next_chunk ()
 Goes to the next chunk in this indentation level.

virtual PajaTypes::uint32 close_chunk ()
 Closes a chunk and goes to the next chunk in the indentation level.

virtual PajaTypes::uint32 read (void *pBuffer, PajaTypes::uint32 ui32Size)
 Reads uiSize bytes to the specified buffer from the stream.

virtual PajaTypes::uint32 read_str (char *szStr)
 Reads a string from the stream.

virtual PajaTypes::uint32 get_error ()
 Returns current error.

virtual void add_file_handle_patch (void **pPointer, PajaTypes::uint32 ui32HandleId)
 Adds file handle patch.

virtual PajaTypes::uint32 get_file_handle_patch_count ()
 Returns number of file handle patched (used internally).

virtual void ** get_file_handle_patch_pointer (PajaTypes::uint32 ui32Index)
 Returns pointer to patch (used internally).

virtual PajaTypes::uint32 get_file_handle_patch_id (PajaTypes::uint32 ui32Index)
 Returns ID of the pointer to patch (used internally).

virtual PluginClass::FactoryCget_factory () const
 Returns factory class attached to the LoadC.

virtual PajaTypes::uint32 get_error_message_count ()
 Returns number of error messages (used internally).

virtual const char * get_error_message (PajaTypes::uint32 ui32Index)
 Returns error message at given index (used internally).

virtual void add_error_message (const char *szMessage)
 Adds new error message.

virtual PajaTypes::uint32 get_file_size () const
 Returns the size of the file.

virtual PajaTypes::uint32 get_read_pos () const
 Returns the current read position.


Detailed Description

Demopaja input stream.

LoadC is used to load the information in Demopaja from a chunk based file format. The data in the output stream is serialized in chunk based format. The read phase consist of opening a chunk, determining the chunk and the version of the chunk, and then reading the data aout of the chunk.

The close_chunk() method skips from the opened chunk to the next chunk even if the whole chunk wasn't read.

This class is implemented by the system.

Example of load() method on effect class:

        uint32
        TestEffectC::load( LoadC* pLoad )
        {
            uint32  ui32Error = IO_OK;

            // Open new chunk for read.
            while( (ui32Error = pLoad->open_chunk()) == IO_OK ) {

                // Determine which chunk to read.
                switch( pLoad->get_chunk_id() ) {
                case CHUNK_TESTEFFECT_BASE:
                    if( pLoad->get_chunk_version() == TESTEFFECT_VERSION )
                        ui32Error = EffectI::load( pLoad );
                    break;
                case CHUNK_TESTEFFECT_TRANSGIZMO:
                    if( pLoad->get_chunk_version() == TESTEFFECT_VERSION )
                        ui32Error = m_pTransGizmo->load( pLoad );
                    break;
                case CHUNK_TESTEFFECT_ATTRIBGIZMO:
                    if( pLoad->get_chunk_version() == TESTEFFECT_VERSION )
                        ui32Error = m_pAttribGizmo->load( pLoad );
                    break;
                default:
                    // Report illegal chunks.
                    assert( 0 );
                }

                // Goto next chunk
                pLoad->close_chunk();

                // Check for errors
                if( ui32Error != IO_OK && ui32Error != IO_END )
                    return ui32Error;
            }

            return ui32Error;
        }

See also:
SaveC


Constructor & Destructor Documentation

LoadC PluginClass::FactoryC   pFactory
 

Default constructor.

virtual ~LoadC   [virtual]
 

Default destructor.


Member Function Documentation

virtual void add_error_message const char *    szMessage [virtual]
 

Adds new error message.

On load the plugin class can report errors via this method. Adding a error message does not stop reading the file. The errors are reported after the file load is completed.

virtual void add_file_handle_patch void **    pPointer,
PajaTypes::uint32    ui32HandleId
[virtual]
 

Adds file handle patch.

Parameters:
pPointer  pointer of the file handle pointer.
ui32HandleId  The ID returned by Import::FileHandleC::get_id().
Via this method a file handle pointer can be set to patched when the data is available. The file handle is patched before the initialize method of effect class is called. Therefore file handle parameters cannot be copied sooner than in the initialize method of the effect class.

Since the file referencing is done via file parameter, the system takes care of all the file handle patching in effect classes. Importer classes have to use this file handle patching mechanism.

Example of writing file handle:

            Import::FileHandleC*    m_pTextureHandle;
            uint32  ui32ID;
            // Write texture handle.
            if( m_pTextureHandle )
                ui32ID = m_pTextureHandle->get_id();
            else
                ui32ID = 0xffffffff;    // NULL ID.
            ui32Error = pSave->write( &ui32ID, sizeof( ui32ID ) );

Example of reading file handle saved in previous example:

            Import::FileHandleC*    m_pTextureHandle;
            uint32  ui32ID = 0xffffffff;
            // Read texture handle.
            ui32Error = pLoad->read( &ui32ID, sizeof( ui32ID) );
            if( ui32ID != 0xffffffff )
                pLoad->add_file_handle_patch( (void**)&m_pTextureHandle, ui32ID );

virtual PajaTypes::uint32 close   [virtual]
 

Closes the input stream.

virtual PajaTypes::uint32 close_chunk   [virtual]
 

Closes a chunk and goes to the next chunk in the indentation level.

close_chunk uses peek_next_chunk to go to the next chunk.

virtual PajaTypes::uint32 get_chunk_id   [virtual]
 

Returns the ID if the currently open chunk, this value is used to determine different chunks.

virtual PajaTypes::uint32 get_chunk_indent   [virtual]
 

Returns the indentation level of the currently open chunk.

virtual PajaTypes::uint32 get_chunk_size   [virtual]
 

Returns the size of the currently open chunk.

virtual PajaTypes::uint32 get_chunk_version   [virtual]
 

Returns the Version of the currently open chunk.

virtual PajaTypes::uint32 get_error   [virtual]
 

Returns current error.

virtual const char* get_error_message PajaTypes::uint32    ui32Index [virtual]
 

Returns error message at given index (used internally).

virtual PajaTypes::uint32 get_error_message_count   [virtual]
 

Returns number of error messages (used internally).

virtual PluginClass::FactoryC* get_factory   const [virtual]
 

Returns factory class attached to the LoadC.

virtual PajaTypes::uint32 get_file_handle_patch_count   [virtual]
 

Returns number of file handle patched (used internally).

virtual PajaTypes::uint32 get_file_handle_patch_id PajaTypes::uint32    ui32Index [virtual]
 

Returns ID of the pointer to patch (used internally).

virtual void** get_file_handle_patch_pointer PajaTypes::uint32    ui32Index [virtual]
 

Returns pointer to patch (used internally).

virtual PajaTypes::uint32 get_file_size   const [virtual]
 

Returns the size of the file.

virtual PajaTypes::uint32 get_read_pos   const [virtual]
 

Returns the current read position.

virtual PajaTypes::uint32 open const char *    szName,
const PajaTypes::int8   pSignature,
PajaTypes::int32    i32SignatureSize
[virtual]
 

Opens input stream.

See FileIOErrorsE for more information on the error codes. If the signature of the opened file doe not match the given signature the error IO_ERROR_FORMAT is returned.

Parameters:
szName  NULL terminated name of the input file.
pSignature  pointer to array of bytes describing the signature of the file.
length  of the signature in bytes.
Returns :
IO_OK if everything went ok, error otherwise.

virtual PajaTypes::uint32 open_chunk   [virtual]
 

Opens a chunk for read.

The open_chunk method returns IO_OK if opening succeed. Since the chunks can be hierarchial (that is, chunks stored inside chunks) IO_END is returned if the load() method should not continue to read the data.

virtual PajaTypes::uint32 peek_next_chunk   [virtual]
 

Goes to the next chunk in this indentation level.

virtual PajaTypes::uint32 read void *    pBuffer,
PajaTypes::uint32    ui32Size
[virtual]
 

Reads uiSize bytes to the specified buffer from the stream.

virtual PajaTypes::uint32 read_str char *    szStr [virtual]
 

Reads a string from the stream.


Moppi Demopaja SDK Documentation -- Copyright © 2000-2002 Moppi Productions