Public Types | Public Member Functions

ILoad Class Reference

This reference page is linked to from the following overview topics: Loading Old Parameter Data using IParamBlock2, Indirect References and Object XRefs, Post-Load Callbacks, Backward Compatibility, Loading and Saving Plug-in Data.


Search for all occurrences

Detailed Description

See also:
Loading and Saving, Character Strings, Class ISave, Class PostLoadCallback, Class INode, Class ClassDesc, Class ClassDirectory, Class Interface.

Description:
This class provides methods to load data from disk and to register post load callbacks.

Note: It is not valid, to write two CStrs in the same chunk of a 3ds Max file, since ILoad::ReadCStringChunk() sets the size for the string to the ChunkSize. However it is possible to write other data, such as two ints, into the same chunk.

All methods of this class are implemented by the system.

#include <ioapi.h>

Inheritance diagram for ILoad:
Inheritance graph
[legend]

List of all members.

Public Types

enum   BPFlag { FORCEMERGE = (1<<0) }

Public Member Functions

virtual  ~ILoad ()
virtual void *  GetAddr (int imaker)=0
virtual void  RecordBackpatch (int imaker, void **patchThis, DWORD flags=0)=0
virtual void  SetRootAddr (void *addr)=0
virtual void *  GetRootAddr ()=0
virtual IOResult  OpenChunk ()=0
virtual USHORT  CurChunkID ()=0
virtual ChunkType  CurChunkType ()=0
virtual ULONGLONG  CurChunkLength ()=0
virtual int  CurChunkDepth ()=0
virtual IOResult  CloseChunk ()=0
virtual USHORT  PeekNextChunkID ()=0
virtual IOResult  Read (void *buf, ULONG nbytes, ULONG *nread)=0
virtual IOResult  ReadWStringChunk (char **buf)=0
virtual IOResult  ReadWStringChunk (mwchar_t **buf)=0
virtual IOResult  ReadCStringChunk (char **buf)=0
virtual IOResult  ReadCStringChunk (mwchar_t **buf)=0
virtual void  SetObsolete ()=0
virtual void  RegisterPostLoadCallback (PostLoadCallback *cb)=0
virtual const MCHAR *  GetDir (int which)=0
virtual FileIOType  DoingWhat ()=0
virtual INode RootNode ()=0
virtual ClassDesc GetClassDesc (USHORT refID)
virtual INT_PTR  Execute (int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
virtual DWORD  GetFileSaveVersion ()
  Retrieves the version and build number of 3ds Max used to save the file being loaded.
virtual bool  RecordNodeRefRemap (ReferenceMaker &aRefMaker, int aRefIdx, INode *aTargetNode, bool aIsIndirectRef)
  Records information needed to remap a reference to a node.
virtual const MCHAR *  FileName ()
virtual IOResult  LoadAssetMetaData ()

Member Enumeration Documentation

enum BPFlag
Enumerator:
FORCEMERGE 
                {
        FORCEMERGE = (1<<0)
    };

Constructor & Destructor Documentation

virtual ~ILoad ( ) [inline, virtual]
{};

Member Function Documentation

virtual void* GetAddr ( int  imaker ) [pure virtual]
Remarks:
This method may be used to load a pointer from disk. It returns the memory address of the specified object Scene stream. This may be NULL if the address is not available. See RecordBackpatch() above for a work around.
Parameters:
imaker This is the index returned from ISave::GetRefID(). that was used to save the pointer.
virtual void RecordBackpatch ( int  imaker,
void **  patchThis,
DWORD  flags = 0 
) [pure virtual]
Remarks:
This method may be used to load a pointer from disk. This is a pointer that was saved using ISave::GetRefID(). You pass the index returned from GetRefID() and a pointer to a pointer that will get set. This method will patch the address immediately if it is available, otherwise it will happen later when it is known. During the load process if you need to work with this information you'll have to use a post load callback since all the addresses are not updated immediately. See RegisterPostLoadCallback() above.
Parameters:
imaker This is the index returned from ISave::GetRefID().
patchThis This is a pointer to the pointer you want patched.
flags This flag indicates that backpatches (and their subsequent references) should be merged as well.
virtual void SetRootAddr ( void *  addr ) [pure virtual]
Remarks:
This method is used internally.
virtual void* GetRootAddr ( ) [pure virtual]
Remarks:
This method is used internally.
virtual IOResult OpenChunk ( ) [pure virtual]
Remarks:
This method is used to open a chunk. If OpenChunk() returns IO_OK, use the following 3 functions to get the info about the chunk. If it returns IO_END this indicates there are no more chunks at this level.
Returns:
IO_OK - The result was acceptable - no errors.

IO_END - This is returned from ILoad::OpenChunk() when the end of the chunks at a certain level have been reached. It is used as a signal to terminates the processing of chunks at that level.

IO_ERROR - This is returned if an error occurred. Note that the plug-in should not put up a message box if a read error occurred. It should simply return the error status. This prevents a overabundance of messages from appearing.
virtual USHORT CurChunkID ( ) [pure virtual]
Remarks:
This method returns the ID of the most recently opened chunk.
virtual ChunkType CurChunkType ( ) [pure virtual]
Remarks:
This method returns the type of the most recently opened chunk. This may be one of the following values:

NEW_CHUNK

CONTAINER_CHUNK

DATA_CHUNK
virtual ULONGLONG CurChunkLength ( ) [pure virtual]
Remarks:
This method returns the chunk length NOT including the header.
virtual int CurChunkDepth ( ) [pure virtual]
Remarks:
This method is used internally for checking for balanced OpenChunk/CloseChunk pairs.
virtual IOResult CloseChunk ( ) [pure virtual]
Remarks:
This method is used to close the currently opened chunk, and position at the next chunk.
Returns:
A return value of IO_ERROR indicates there is no open chunk to close; otherwise IO_OK.
virtual USHORT PeekNextChunkID ( ) [pure virtual]
Remarks:
This method returns the ID of the next chunk without opening it. It returns 0 if there are no more chunks.
virtual IOResult Read ( void *  buf,
ULONG  nbytes,
ULONG *  nread 
) [pure virtual]
Remarks:
This method is used to read a block of bytes from the output stream.
Parameters:
buf A pointer to the buffer to read.
nbytes The number of bytes to read.
nread The number of bytes that were read.
Returns:
A return value of IO_ERROR indicates an error occurred, otherwise IO_OK.
virtual IOResult ReadWStringChunk ( char **  buf ) [pure virtual]
Remarks:
This method read a string that was stored as Wide characters. Note: This method reads a string from a string chunk. It is assumed the chunk is already open, it will NOT close the chunk.
Parameters:
buf A pointer to an array of characters.
Returns:
A return value of IO_ERROR indicates an error occurred, otherwise IO_OK.
virtual IOResult ReadWStringChunk ( mwchar_t **  buf ) [pure virtual]
Remarks:
This method read a string that was stored as Wide chars. Note: This method reads a string from a string chunk. It is assumed the chunk is already open, it will NOT close the chunk.
Parameters:
buf A pointer to an array of wide characters.
Returns:
A return value of IO_ERROR indicates an error occurred, otherwise IO_OK.
virtual IOResult ReadCStringChunk ( char **  buf ) [pure virtual]
Remarks:
This method reads a string that was stored as single byte characters.
Parameters:
buf A pointer to an array of single byte characters. This method will allocate an internal buffer, stored in the ILoadImp class that is big enough to hold the string chunk read in. You must then copy or parse out the data and store it in your own area: you can't hang on to the string pointer it hands back because it will not be valid.
Returns:
A return value of IO_ERROR indicates an error occurred, otherwise IO_OK.
virtual IOResult ReadCStringChunk ( mwchar_t **  buf ) [pure virtual]
Remarks:
This method may be used to read a string that was stored as single byte characters.
Parameters:
buf A pointer to an array of wide characters. This method will allocate an internal buffer, stored in the ILoadImp class that is big enough to hold the string chunk read in. You must then copy or parse out the data and store it in your own area: you can't hang on to the string pointer it hands back because it will not be valid.
Returns:
A return value of IO_ERROR indicates an error occurred, otherwise IO_OK.
virtual void SetObsolete ( ) [pure virtual]
Remarks:
You may call this if you encounter obsolete data to cause a message to be displayed after loading.
virtual void RegisterPostLoadCallback ( PostLoadCallback cb ) [pure virtual]
Remarks:
Registers a procedure to be called after loading. These will be called in the order that they are registered. It is assumed that if the callback needs to be deleted, the proc will do it.
Parameters:
cb Points to the callback object.
virtual const MCHAR* GetDir ( int  which ) [pure virtual]
Remarks:
Retrieves the specified standard 3ds Max directory name (fonts, scenes, images, ...).
Parameters:
which Specifies the directory name to retrieve. See MAX Directory IDs. The constants are defined in MAXAPI.H
Returns:
The name of the specified directory.
virtual FileIOType DoingWhat ( ) [pure virtual]
Remarks:
Determines if we are loading a standard 3ds Max file (.MAX) or a material library (.MAT).
Returns:
One of the following values:

IOTYPE_MAX

IOTYPE_MATLIB
virtual INode* RootNode ( ) [pure virtual]
Remarks:
Returns the root node to attach to when loading a node with no parent.
virtual ClassDesc* GetClassDesc ( USHORT  refID ) [inline, virtual]
Remarks:
This method is available in release 3.0 and later only.

Returns a pointer to the ClassDesc corresponding to the specified reference ID in the ClassDirectory stream.
Parameters:
refID The reference ID in the ClassDirectory stream.
Default Implementation:
{ return NULL; }
{ return NULL; }
virtual INT_PTR Execute ( int  cmd,
ULONG_PTR  arg1 = 0,
ULONG_PTR  arg2 = 0,
ULONG_PTR  arg3 = 0 
) [inline, virtual]
virtual DWORD GetFileSaveVersion ( ) [inline, virtual]

Retrieves the version and build number of 3ds Max used to save the file being loaded.

Plugins can call this method when loading a max file is being loaded.

Returns:
A value describing the version of 3ds Max used to save the file. The value is composed of a LOWORD(value)= Build number, and a HIWORD(value) = MAX_RELEASE. For example, 41 for build #41, and 4000 for 3ds Max version 4.0
Note:
Plugins should not rely on the value returned by this function for versioning their own data saved to the max file. Plugins should rather use either:
  • Parameter block versioning for versioning data stored in parameter blocks. See IParamBlock2::GetVersion() and the P_VERSION flag for versioning instances of class ParamBlockDesc2.
  • Their own versioning scheme for data that is not stored in a parameter block. Loading and saving a max file in the absence of the plugin will maintain its data intact, but the max version and build numbers will be updated, so next time the file is loaded in the presence of the plugin, the max version number could be different than when the plugin data was saved.
{ return 0; };
virtual bool RecordNodeRefRemap ( ReferenceMaker aRefMaker,
int  aRefIdx,
INode aTargetNode,
bool  aIsIndirectRef 
) [inline, virtual]

Records information needed to remap a reference to a node.

References to nodes held by object-xrefed reference makers need to be remapped when updating xref records. In most cases, Max will automatically record data required to remap node references when xrefing objects. Plug-ins that save node pointers into the max file need to be modified to indirectly reference the node, in order for that plug-in to be xref-able. For the legacy version of the plugin to be xref-able, the plugin must record in a PostLoadCallback information needed for remapping the indirect reference it makes to nodes. This can be done by calling this method.

Parameters:
aRefMaker - A scene entity that makes a reference to a node
aRefIdx - The index of the reference aRefMaker makes to a node
aTargetNode - The node being referenced
aIsIndirectRef - If true, the reference to the node is indirect, otherwise it's a regular reference
Returns:
- true if a node-ref-remap entry was recorded successfully, false otherwise
{return false;}
virtual const MCHAR* FileName ( ) [inline, virtual]
Remarks:
Returns the name of the scene file being loaded.
{ return NULL; }
virtual IOResult LoadAssetMetaData ( ) [inline, virtual]
Remarks:
This method is used by Asset Manager to load from the scene file all asset meta data.
Returns:
A return value of IO_ERROR indicates an error occurred, otherwise IO_OK.
{ return IO_OK; }

ILoad ILoad ILoad ILoad ILoad ILoad ILoad ILoad ILoad ILoad
ILoad ILoad ILoad ILoad ILoad ILoad ILoad ILoad ILoad ILoad