ioapi.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 *<
00003 FILE: ioapi.h
00004 
00005 DESCRIPTION:
00006 
00007 CREATED BY: Dan Silva
00008 
00009 HISTORY:
00010 
00011 *>  Copyright (c) 1994, All Rights Reserved.
00012 **********************************************************************/
00013 
00014 #pragma once
00015 
00016 #include "maxtypes.h"
00017 #include "tab.h"
00018 #include "baseinterface.h"
00019 #include "strbasic.h"
00020 #include "assetmanagement\AssetType.h"
00021 #include "assetmanagement\AssetId.h"
00022 #include "strclass.h"
00023 
00024 
00025 class ILoad;
00026 class INode;
00027 class ReferenceMaker;
00028 class ClassDesc;
00029 
00036 #pragma warning(push)
00037 #pragma warning(disable:4100)
00038 class PostLoadCallback : public InterfaceServer {
00039 public:
00042     virtual void proc(ILoad *iload)=0;
00043     // Lower priorities are run first-- allowable values {0..10}: 0 is reserved for ParamBlock2PLCB & ParamBlockPLCB 
00055     virtual int Priority() { return 5; }  
00068     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; }
00069 };
00070 #pragma warning(pop)
00071 // CCJ - 9.15.00
00072 // This interface is used to remap node handles when a scene is merged.
00087 class IMergeManager : public InterfaceServer {
00088 public:
00094     virtual ULONG   GetNewHandle(ULONG oldHandle) = 0;
00100     virtual bool    HandleExist(ULONG handle) = 0;
00101 };
00102 
00103 //Return value for GetClassDescID if no class was found
00104 #define NO_CLASSDESC_ID_RETURNED 0xffff
00105 
00106 
00130 #pragma warning(push)
00131 #pragma warning(disable:4100)
00132 class ISave : public InterfaceServer {
00133 public:
00134     virtual ~ISave(){};
00135 
00136     // Returns the index of the referenced object in the Scene stream.
00145     virtual int GetRefID(void *ptarg)=0;
00146 
00147     // Begin a chunk.
00151     virtual void BeginChunk(USHORT id)=0;
00152 
00153     // End a chunk, and back-patch the length.
00156     virtual void EndChunk()=0;
00157 
00160     virtual int CurChunkDepth()=0;  // for checking balanced BeginChunk/EndChunk
00161 
00162     // write a block of bytes to the output stream.
00172     virtual IOResult Write(const void  *buf, ULONG nbytes, ULONG *nwrit)=0;
00173 
00174     // Write character strings
00179     virtual IOResult WriteWString(const char *str)=0;
00184     virtual IOResult WriteWString(const mwchar_t *str)=0;
00190     virtual IOResult WriteCString(const char *str)=0;
00195     virtual IOResult WriteCString(const mwchar_t *str)=0;
00196 
00197     // are we saveing a MAX file or a MAT lib
00203     virtual FileIOType DoingWhat()=0;
00204 
00205     // Test this for saving old version.  
00206     // Returns 0 for the current version, 2000 for version 2.0.
00220     virtual DWORD SavingVersion() { return  0; }
00221 
00222     // <JBW> get a load ref id for the given RefMaker's ClassDesc in the ClassDirectory stream
00230     virtual USHORT GetClassDescID(ReferenceMaker* rm) { return NO_CLASSDESC_ID_RETURNED; }
00231 
00232     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; }
00233 
00234     // The name of the scene file being saved
00236     virtual const MCHAR* FileName() { return NULL; }
00237 
00238     // Save Asset Metadata.
00242     virtual IOResult SaveAssetMetaData(const MaxSDK::AssetManagement::AssetId& assetId)  { return IO_OK; }
00243 
00244     // Save Asset Metadata.
00247     virtual bool SaveAssetAsAssetIDGuid() { return false; }
00248 
00249 };
00250 
00251 
00252 #pragma warning(pop)
00253 
00266 #pragma warning(push)
00267 #pragma warning(disable:4100)
00268 class ILoad : public InterfaceServer {
00269 public:
00270     enum BPFlag {
00271         FORCEMERGE = (1<<0)
00272     };
00273 
00274     virtual ~ILoad(){};
00275 
00276     // Returns the memory address of the ith object Scene stream.
00283     virtual void* GetAddr(int imaker)=0;
00284 
00285     // If GetAddr() returns NULL, then call this to get the address
00286     // backpatched later, when it is known.  patchThis must point at
00287     // a valid pointer location. RecordBackpatch will patch the
00288     // address immediately if it is available.
00301     virtual void RecordBackpatch(int imaker, void** patchThis, DWORD flags = 0)=0;
00302 
00303     // When the root of a reference hierarchy is loaded, its
00304     // Load() can call this to store away a pointer to itself
00305     // for later retrieval.
00307     virtual void SetRootAddr(void *addr)=0;
00309     virtual void* GetRootAddr()=0;
00310 
00311     // if OpenChunk returns IO_OK, use following 3 function to get the 
00312     // info about the chunk. IO_END indicates no more chunks at this level
00325     virtual IOResult OpenChunk()=0;
00326 
00327     // These give info about the most recently opened chunk
00330     virtual USHORT CurChunkID()=0;
00336     virtual ChunkType CurChunkType()=0;
00338     virtual ULONGLONG CurChunkLength()=0;  // chunk length NOT including header
00341     virtual int CurChunkDepth()=0;  // for checking balanced OpenChunk/CloseChunk
00342 
00343     // close the currently opened chunk, and position at the next chunk
00344     //  return of IO_ERROR indicates there is no open chunk to close
00349     virtual IOResult CloseChunk()=0;
00350 
00351     // Look at the next chunk ID without opening it.
00352     // returns 0 if no more chunks
00355     virtual USHORT PeekNextChunkID()=0;
00356 
00357     // Read a block of bytes from the output stream.
00365     virtual IOResult Read(void  *buf, ULONG nbytes, ULONG *nread )=0;
00366 
00367     // Read a string from a string chunk assumes chunk is already open, 
00368     // it will NOT close the chunk. Sets buf to point
00369     // to a char string.  Don't delete buf: ILoad will take care of it.
00370 
00371     //   Read a string that was stored as Wide chars. 
00378     virtual IOResult ReadWStringChunk(char** buf)=0;
00385     virtual IOResult ReadWStringChunk(mwchar_t** buf)=0;
00386 
00387     //   Read a string that was stored as single byte chars
00397     virtual IOResult ReadCStringChunk(char** buf)=0;
00407     virtual IOResult ReadCStringChunk(mwchar_t** buf)=0;
00408 
00409     // Call this if you encounter obsolete data to cause a
00410     //  message to be displayed after loading.
00413     virtual void SetObsolete()=0;       
00414 
00415     // Register procedure to be called after loading. These will
00416     // be called in the order that they are registered.
00417     // It is assumed that if the callback needs to be deleted,
00418     // the proc will do it.
00423     virtual void RegisterPostLoadCallback(PostLoadCallback *cb)=0;
00424 
00425     // Gets the various directories. Constants are defined in
00426     // JAGAPI.H
00432     virtual const MCHAR *GetDir(int which)=0;
00433 
00434     // are we Loading a MAX file or a MAT lib
00440     virtual FileIOType DoingWhat()=0;
00441 
00442     // Root node to attach to when loading node with no parent
00445     virtual INode *RootNode()=0;
00446 
00447     // <JBW> get the ClassDesc corresponding to the given refID in the ClassDirectory stream
00448     // companion to ISave::GetClassDescID() for saving & loading ClassDesc references
00456     virtual ClassDesc* GetClassDesc(USHORT refID) { return NULL; }
00457 
00458     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; }
00459 
00461 
00477     virtual DWORD GetFileSaveVersion() { return 0; };
00478 
00495     virtual bool RecordNodeRefRemap(ReferenceMaker& aRefMaker, int aRefIdx, INode* aTargetNode, bool aIsIndirectRef) {return false;}
00496 
00497     // The name of the scene file being loaded
00499     virtual const MCHAR* FileName() { return NULL; }
00500 
00501     // Load Asset Metadata.
00504     virtual IOResult LoadAssetMetaData()  { return IO_OK; }
00505 };
00506 #pragma warning(pop)
00507 
00508