1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: ioapi.h
|
---|
4 |
|
---|
5 | DESCRIPTION:
|
---|
6 |
|
---|
7 | CREATED BY: Dan Silva
|
---|
8 |
|
---|
9 | HISTORY:
|
---|
10 |
|
---|
11 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
12 | **********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef __IOAPI__H
|
---|
15 | #define __IOAPI__H
|
---|
16 |
|
---|
17 | class ILoad;
|
---|
18 |
|
---|
19 | class PostLoadCallback {
|
---|
20 | public:
|
---|
21 | virtual void proc(ILoad *iload)=0;
|
---|
22 | };
|
---|
23 |
|
---|
24 | typedef enum {IO_OK=0, IO_END=1, IO_ERROR=2} IOResult;
|
---|
25 | typedef enum {NEW_CHUNK=0, CONTAINER_CHUNK=1, DATA_CHUNK=2} ChunkType;
|
---|
26 |
|
---|
27 | class ISave {
|
---|
28 | public:
|
---|
29 | virtual ~ISave(){};
|
---|
30 |
|
---|
31 | // Returns the index of the referenced object in the Scene stream.
|
---|
32 | virtual int GetRefID(void *ptarg)=0;
|
---|
33 |
|
---|
34 | // Begin a chunk.
|
---|
35 | virtual void BeginChunk(USHORT id)=0;
|
---|
36 |
|
---|
37 | // End a chunk, and back-patch the length.
|
---|
38 | virtual void EndChunk()=0;
|
---|
39 |
|
---|
40 | virtual int CurChunkDepth()=0; // for checking balanced BeginChunk/EndChunk
|
---|
41 |
|
---|
42 | // write a block of bytes to the output stream.
|
---|
43 | virtual IOResult Write(const void *buf, ULONG nbytes, ULONG *nwrit)=0;
|
---|
44 |
|
---|
45 | // Write character strings
|
---|
46 | virtual IOResult WriteWString(const char *str)=0;
|
---|
47 | virtual IOResult WriteWString(const wchar_t *str)=0;
|
---|
48 | virtual IOResult WriteCString(const char *str)=0;
|
---|
49 | virtual IOResult WriteCString(const wchar_t *str)=0;
|
---|
50 |
|
---|
51 | };
|
---|
52 |
|
---|
53 |
|
---|
54 | class ILoad {
|
---|
55 | public:
|
---|
56 | virtual ~ILoad(){};
|
---|
57 |
|
---|
58 | // Returns the memory address of the ith object Scene stream.
|
---|
59 | virtual void* GetAddr(int imaker)=0;
|
---|
60 |
|
---|
61 | // If GetAddr() returns NULL, then call this to get the address
|
---|
62 | // backpatched later, when it is known. patchThis must point at
|
---|
63 | // a valid pointer location. RecordBackpatch will patch the
|
---|
64 | // address immediately if it is available.
|
---|
65 | virtual void RecordBackpatch(int imaker, void** patchThis)=0;
|
---|
66 |
|
---|
67 | // When the root of a reference hierarchy is loaded, its
|
---|
68 | // Load() can call this to store away a pointer to itself
|
---|
69 | // for later retrieval.
|
---|
70 | virtual void SetRootAddr(void *addr)=0;
|
---|
71 | virtual void* GetRootAddr()=0;
|
---|
72 |
|
---|
73 | // if OpenChunk returns IO_OK, use following 3 function to get the
|
---|
74 | // info about the chunk. IO_END indicates no more chunks at this level
|
---|
75 | virtual IOResult OpenChunk()=0;
|
---|
76 |
|
---|
77 | // These give info about the most recently opened chunk
|
---|
78 | virtual USHORT CurChunkID()=0;
|
---|
79 | virtual ChunkType CurChunkType()=0;
|
---|
80 | virtual ULONG CurChunkLength()=0; // chunk length NOT including header
|
---|
81 | virtual int CurChunkDepth()=0; // for checking balanced OpenChunk/CloseChunk
|
---|
82 |
|
---|
83 | // close the currently opened chunk, and position at the next chunk
|
---|
84 | // return of IO_ERROR indicates there is no open chunk to close
|
---|
85 | virtual IOResult CloseChunk()=0;
|
---|
86 |
|
---|
87 | // Look at the next chunk ID without opening it.
|
---|
88 | // returns 0 if no more chunks
|
---|
89 | virtual USHORT PeekNextChunkID()=0;
|
---|
90 |
|
---|
91 | // Read a block of bytes from the output stream.
|
---|
92 | virtual IOResult Read(void *buf, ULONG nbytes, ULONG *nread )=0;
|
---|
93 |
|
---|
94 | // Read a string from a string chunk assumes chunk is already open,
|
---|
95 | // it will NOT close the chunk. Sets buf to point
|
---|
96 | // to a char string. Don't delete buf: ILoad will take care of it.
|
---|
97 |
|
---|
98 | // Read a string that was stored as Wide chars.
|
---|
99 | virtual IOResult ReadWStringChunk(char** buf)=0;
|
---|
100 | virtual IOResult ReadWStringChunk(wchar_t** buf)=0;
|
---|
101 |
|
---|
102 | // Read a string that was stored as single byte chars
|
---|
103 | virtual IOResult ReadCStringChunk(char** buf)=0;
|
---|
104 | virtual IOResult ReadCStringChunk(wchar_t** buf)=0;
|
---|
105 |
|
---|
106 | // Call this if you encounter obsolete data to cause a
|
---|
107 | // message to be displayed after loading.
|
---|
108 | virtual void SetObsolete()=0;
|
---|
109 |
|
---|
110 | // Register procedure to be called after loading. These will
|
---|
111 | // be called in the order that they are registered.
|
---|
112 | // It is assumed that if the callback needs to be deleted,
|
---|
113 | // the proc will do it.
|
---|
114 | virtual void RegisterPostLoadCallback(PostLoadCallback *cb)=0;
|
---|
115 |
|
---|
116 | // Gets the various directories. Constants are defined in
|
---|
117 | // JAGAPI.H
|
---|
118 | virtual TCHAR *GetDir(int which)=0;
|
---|
119 | };
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|
124 | #endif
|
---|