gmSCScratchInfoClass
- Mark Juras
Owned by Mark Juras
The ScratchInfo Service Class
The service class ScratchInfo manages a scratch information storage area primarily for use by the engine for the rapid storage, retrieval, and removal of volatile values. All of its content is maintained in a single memory-based long storage area; consequently, this class has no external handles that must be managed by the users of this class. Note that this class uses the value of the global define SCRATCHINFO_PAGESIZE to define its page size. This constant is typically equal to 16384. No records longer than this size can be managed via this class. If very long records are needed by some process this value can be changed by changing the implementation of the method ScratchInfo_Create.The method ScratchInfo_Access
Prototypevoid* ScratchInfo_Access(int offset,int* nByte);
Parameter | Description |
offset | Specifies the offset in the information storage area of the information vector as previously returned by the Write method. |
nByte | returns the length in bytes of the information vector as it was specified when the vector was originally written. |
The method returns a handle to the start of the information vector. The caller can assume that there are no block-boundaries within the vector. This pointer can be used in the normal way, but it may be semipermanent in some implementations, which means that it should be used only locally for immediate access.
The method ScratchInfo_Close
Prototypevoid ScratchInfo_Close(void);
The method ScratchInfo_Create
Prototypevoid ScratchInfo_Create(int iUnit);
Parameter | Description |
iUnit | Specifies which unit is to be created. It must contain a value between 0 and 2, or one of the constants -- ScratchInfo_Global, ScratchInfo_Local, or ScratchInfo_User |
The created unit becomes the currently active one.
The method ScratchInfo_Delete
Prototypevoid ScratchInfo_Delete(int offset);
Parameter | Description |
offset | Specifies the offset in the information storage area of the information vector being deleted as previously returned by the Write method. |
The method ScratchInfo_PostCreate
Prototypeint ScratchInfo_PostCreate(void);
The method ScratchInfo_PostFind
Prototypeint ScratchInfo_PostFind(int basePoint,int pairIndex);
Parameter | Description |
basePoint | specifies the root offset of the posting set to be searched as returned by the method ScratchInfo_PostCreate. |
pairIndex | specifies the value whose associated entry value is desired. |
If the entry is found, the value associated with the index is returned; else zero is returned.
The method ScratchInfo_PostWrite
Prototypeint ScratchInfo_PostWrite(int basePoint,int index,int value);
Parameter | Description |
basePoint | specifies the root offset of the posting set to be written to as returned by the method ScratchInfo_PostCreate. |
index | Specifies the index value to be used are the pairIndex value when the posting set is searched by ScratchInfo_PostFind. |
value | Specifies the value that is to be associate with the index. |
If all goes well, the method returns a one. If the pair already exists and has a nonzero value associated with it, the method returns a zero.
The method ScratchInfo_Replace
Prototypeint ScratchInfo_Replace(int offset,void* info,int nByte);
Parameter | Description |
offset | Specifies the offset in the information storage area of the information vector being replaced as previously returned by the ScratchInfo_Write or ScratchInfo_Replace methods. If this offset is zero, then this method assumes that no previous vector exists and it simply writes a new one. |
info | Specifies the handle for the replacing information vector. Its content is arbitrary. |
nByte | Specifies the length of the information vector in bytes. It must be greater than zero and less than the pagesize of the storage area. |
This method returns the integer offset in the storage area of the start of the information vector. This offset must be used later to retrieve the information. Depending upon its length this may be the same as the previous offset or it may be different.
The method ScratchInfo_Select
Prototypevoid ScratchInfo_Select(int iUnit);
Parameter | Description |
iUnit | Specifies which unit is to be selected. It must contain a value between 0 and 2, or one of the constants -- ScratchInfo_Global, ScratchInfo_Local, or ScratchInfo_User |
The created unit becomes the currently active one.
The method ScratchInfo_Write
Prototypeint ScratchInfo_Write(void* info,int nByte);
Parameter | Description |
info | Contains the vector to be written. It is copied into the scratch storage area. No assumptions about its internal content are made as its length is supplied explicitly. The value of info may be NULL. In this case an area nByte long is allocated and initialized at zero. |
nByte | Specifies the length of the information vector in bytes. It must be greater than zero and less than the pagesize of the storage area. |
This method returns the integer offset in the storage area of the start of the information vector. This offset must be used later to retrieve the information.
Table of Contents