/
gmscStoreClass
gmscStoreClass
Mark Juras
Owned by Mark Juras
The Store Service Class
The service class Store contains the methods needed to manage data organized into hierarchical fields and records. When dealing with language processing, program storage must be viewed as containing a wide variety of different structures: indexes, lists, fixed records, long unformatted records, variable length strings, and so on. In addition, it may be purely memory bound or it may be stored in a persistent file system. The role of this service class is to provide a single interface for storing and retrieving information. It uses the LongMemory service class to manage its storage; therefore, it is sufficiently robust to allow for the management of large files in the multiple gigabyte size range, while it is still efficient for use by purely memory bound applications. Physically, a storage area consists of a series of relatively large fixed sized blocks whose boundaries cannot be crossed without software support. It is this unalterable property of persistent storage that must be dealt with explicitly if an efficient information management system is desired. The manner in which these blocks are created, maintained, and accessed is determined when the storage area is created or opened. At a logical level the storage area is viewed as consisting of a simple sequence of binary words -- long memory. All information is stored on a word boundary and all offsets are expressed in terms of words. The primary aspect of the approach used to achieve very rapid access times is semi-permanent pointers. These are implemented via the PagingSystem service class. The basic idea is that a page pointer is a valid memory pointer until the block which it contains is swapped out of memory. Thus, these pointers can be used safely within local blocks of code where efficiency is needed, even though they cannot be saved and reused over longer stretches of code.The field langRoot
Prototypeextern int langRoot;
The field langStore
Prototypeextern int langStore;
The field userStore
Prototypeextern int userStore;
The method Store_AddGlobal
Prototypeint Store_AddGlobal(int root,int global);
Parameter | Description |
root | Specifies the root offset of a component that may have global scope. |
global | Specifies the offset of the parent external library or class whose active reference status triggers the global scope of its component. |
If all goes well, the method returns a one. If the global, root pair already exists, the method returns a zero.
The method Store_ChangeParent
Prototypevoid Store_ChangeParent(int iRoot,int parent)
Parameter | Description |
iRoot | Specifies the root offset of the component in storage as originally returned by the Store_Vector method. |
parent | Specifies the root offset of the new parent component. |
The method Store_Close
Prototypevoid Store_Close(void);
The method Store_Create
Prototypeint Store_Create(char* filename,int iUnit);
Parameter | Description |
filename | Contains the name of that file (optionally without an extension), if the storage is to be paged into a file. If the storage is to be purely memory-based, then this parameter should be NULL. |
iUnit | Specifies the unit number of the desired storage area. The current implementation supports upto Store_MaxUnit areas, so this must contain a value between 1 and Store_MaxUnit. |
If all goes well a one (true) is returned. If there is a problem creating the storage area a zero (false) is returned.
The method Store_DeltaVector
Prototypevoid* Store_DeltaVector(int root);
Parameter | Description |
root | Specifies the root offset of component in storage. |
This method returns a semi-permanent void pointer to the information vector. The storage algorithm guarantees that there are no block boundaries with the vector, so the return value is normally cast to a structure type.
The method Store_FindFirstChild
Prototypeint Store_FindFirstChild(int* levels,int iRoot);
Parameter | Description |
levels | Receives information used internally by the search algorithm. It must have at least two plus the maximum levels in the tree entries. Normal code structures have no more than four levels -- project, class, subprogram, and local variable. Controls defined via forms can often be nested more deeply. A size of 20 is always safe. Note that levels[0] always receives the current nesting level. |
iRoot | Specifies the first node to be visited. If it> is non-zero, then the node with this offset is visited first. If it is zero, then the first node in the tree is visited first. |
See the description of the method Store_FindNextChild for information on how the next node visited is determined. This method returns the offset of the first node visited or zero, if the symbol tree is empty.
The method Store_FindGlobal
Prototypeint Store_FindGlobal(int symbolRoot,int libRoot)
Parameter | Description |
symbolRoot | Specifies the symbol root offset. It is normally obtained via a call to the Store_FindRoot method. |
libRoot | Specifies the offset of the external. |
If the return value is negative then there are no globals with the specified name. If the return value is zero, then the indicated external has no global component with the specified name. A positive value is the root of a public component in the current external with the specified name.
The method Store_FindNextChild
Prototypeint Store_FindNextChild(int* levels);
Parameter | Description |
levels | Receives information used internally by the search algorithm. It must have been initialized by the Store_FindFirstChild method. |
In a depth first search, a visit to a node is followed immediately by visits to all descendants of the node. There is a simple recursive algorithm for describing a depth first search.
void depth_first_tree_search(node v, int level, void* info) { node u; visit(v,level,info); level++; for(each child u of v) depth_first_tree_search(u,level,info); }
The method Store_FindRoot
Prototypeint Store_FindRoot(CONST char* identifier);
Parameter | Description |
identifier | Contains the identifier to be searched for in the symbol table in null-terminated form. |
If a component with the specified identifier is found within the symbol table then the root offset of that component is returned. If no component can be found in the table, then a zero is returned. Note this is the root of the symbol, not the root of any component that is identified by it.
The method Store_FindVector
Prototypeint Store_FindVector(CONST char* identifier,int parent);
Parameter | Description |
identifier | Contains a null-terminated string with the identifier to be searched for in the specified branch of the symbol table. |
parent | Specifies which branch of the symbol table is to be searched. If it is the root branch of the symbol table is to be searched, then it should be set to zero. If a child branch of a parent component, then it should be set equal to the root offset of that parent component. |
If a component with the specified identifier is found within the specified branch, then the root offset of that component is returned. If no component can be found in the branch, then a zero is returned.
The method Store_FirstReference
Prototypeint* Store_FirstReference(int symbolRoot,void* PostSet);
Seq | Description 0f content |
0 | The offset of the component containing the reference |
1 | The offset of the component being referenced |
2 | The text record number in the host file of the reference |
3 | The offset in the compiled code of the reference code |
4 | The offset of the information file containing the subprogram |
5 | If the reference treated the component as terminal then one, else zero |
Its parameters are:
Parameter | Description |
symbolRoot | Specifies the offset of the symbol for which references are desired. If it is zero, then all references are returned sorted by symbol referenced. |
PostSet | Receives the information needed to control the search. It is a small scratch storage area which must be allocated by the caller. Its content should not be used by the caller. This area must be passed to the Store_NextReference method to obtain additional reference records. |
Note that as many simultaneous searches as desired may be conducted so long as each search has its own unique PostSet allocated. If there is at least one reference record available, then a semi-permanent pointer to that record is returned. If there is no reference to the specified symbol, or at all, then a NULL is returned.
The method Store_GetDataName
Prototypechar* Store_GetDataName(void);
The method Store_GetFirst
Prototypeint Store_GetFirst(int parent);
Parameter | Description |
parent | Specifies the root offset of the parent component or zero if the first member of the root branch in the symbol table is desired. |
If there is a first child of the specified component then this method returns its root offset. If there is no first child, then this method returns a zero.
The method Store_GetGlobals
Prototypeint Store_GetGlobals(int symbolRoot,int* globals,int nGlobal);
Parameter | Description |
symbolRoot | Specifies a root offset in the base symbol index as returned by the Store_FindRoot method. |
globals | Receives the pairs added to the specified symbol. |
nGlobal | Specifies the length of the globals vector. No more than nGlobal entries will be stored int globals. |
The method returns the number of entries returned in the vector. This is two times the number of pairs.
The method Store_GetHandle
Prototypevoid* Store_GetHandle(void);
The method Store_GetIdent
Prototypechar* Store_GetIdent(int root,int* nIdent)
Parameter | Description |
root | Specifies the root offset of component in storage as originally returned by the Store_Vector method. |
nIdent | returns the length of the identifier. |
The method returns a semi-permanent character pointer to the identifier of the component.
The method Store_GetInfo
Prototypeint Store_GetInfo(int addr,int* info);
Parameter | Description |
addr | Specifies the address of the information vector. That vector is stored along with its length. |
info | Receives the content of the information vector. It is up to the user to ensure that it has sufficient room. See the method Store_GetLength to obtain its length in advance. |
The method returns the length of the information vector as stored in info in bytes.
The method Store_GetLength
Prototypeint Store_GetLength(int offset);
Parameter | Description |
offset | Specifies what length information is wanted. If it is zero, then the length in words of the currently selected storage area is returned. If it is not zero but less than the number of possible storage units Store_MaxUnit, then the length in words of that unit is returned. If it is greater than the possible number of storage units, then the length in bytes of the information stored at the specified offset is returned. |
Regardless of the value of the parameter offset, if the current storage area is empty, then this method returns zero.
The method Store_GetMessage
Prototypechar* Store_GetMessage(int number,int* nString)
Parameter | Description |
number | Specifies number of the message. |
nString | returns the length of the message. |
If the message exists, the method returns a pointer to the message string. If the message does not exist, then a NULL is returned.
The method Store_HasName
Prototypeint Store_HasName(int root);
Parameter | Description |
root | Specifies the root offset of the symbol whose name status is needed. |
The method Store_GetName
Prototypechar* Store_GetName(int root,int* nIdent);
Parameter | Description |
root | Specifies the root offset of component in storage. |
nIdent | returns the length of the name. |
The method returns a semi-permanent character pointer to the name of the component as it was originally specified when the component was first entered into the symbol table or that was entered later using Store_SetName.
The method Store_GetNext
Prototypeint Store_GetNext(int child);
Parameter | Description |
child | Specifies the root offset of the current child component as returned by Store_GetFirst or a previous call this method. |
If there is a next child of the parent of the specified component, then this method returns its root offset. If there is no next child, then this method returns a zero.
The method Store_GetObjectType
Prototypeint Store_GetObjectType(int root);
Parameter | Description |
root | Specifies the root offset of a component in storage. |
If the root offset passed to this method has a value less than or equal to zero, then this method displays the following message and returns a zero.
SYSERR#5001: Object Type requested for invalid root %root%
SYSERR#5002: Object Type requested for invalid root %root%
The method Store_GetParent
Prototypeint Store_GetParent(int root);
Parameter | Description |
root | Specifies the root offset of the component in storage as originally returned by the Store_Vector method. |
The method Store_GetString
Prototypechar* Store_GetString(int addr,int* nString);
Parameter | Description |
addr | Specifies the offset of the string in storage as returned by the Store_String method. |
nString | returns the length of the string. |
The method returns a semi-permanent character pointer to the start of the string. The caller can assume that there are no block-boundaries within the string.
The method Store_GetSymbols
Prototypeint Store_GetSymbols(char* identifier);
Parameter | Description |
identifier | Contains the identifier whose entries are desired. |
This method searches the base index for the specified identifier using the method Store_FindRoot. If found, it returns the root offset of a sequence maintained there that contains the root offsets of the symbols with that name stored in the order that they were defined. If no symbol with the specified name is present, a zero is returned.
The method Store_GetVector
Prototypevoid* Store_GetVector(int root);
Parameter | Description |
root | Specifies the root offset of the component in storage. |
The method returns a semi-permanent void pointer to the information vector. The storage algorithm guarantees that there are no block boundaries with the vector, so the return value is normally cast to a structure type.
The method Store_IssueMessage
Prototypeint Store_IssueMessage(CONST char* format,int number,char* Strings[],int nString,int Values[],int nValue);
Parameter | Description |
format | Contains a printf-style format to be used. |
number | Specifies the number of message to be used. |
Strings | Contains the string values to be supplied. |
nString | Specifies the number of string values. |
values | Contains the integer values to be supplied. |
nValue | Specifies the number of integer values. |
If a message was actually written to the log file, then this method returns the length of that message else it return 0.
The method Store_LinkedString
Prototypeint Store_LinkedString(char* String,int nString,int link);
Parameter | Description |
String | Contains the character string to be stored. It need not be null-terminated as its length is supplied explicitly. |
nString | Specifies the length of character string being stored. |
link | Specifies a simple value that is stored along with the string. Usually this will be an offset of some other information previously stored in the area but may be any integer value. |
The methods within this Store class do not make any assumptions about the content of the String or link parameter therefore, they can be used to store any fixed length byte sequence with an information associated integer value. The method returns offset in the storage area of the string. This offset can be used later to retrieve the string using the standard Store_GetString method. This offset can also be used later to obtain or change the link value using the methods Store_LinkGet or Store_LinkSet.
The method Store_LinkGet
Prototypeint Store_LinkGet(int addr);
Parameter | Description |
addr | Specifies the location of the string whose link is wanted. It must be the offset returned by the Store_LinkedString method when the string and its link were originally stored. |
The method returns the value of the link as retrieved from the storage area. This may be the original value or a value as changed by the Store_LinkSet method.
The method Store_LinkSet
Prototypevoid Store_LinkSet(int addr,int link);
Parameter | Description |
addr | Specifies the location of the string whose link is to be changed. It must be the offset returned by the Store_LinkedString method when the string and its link were originally stored. |
link | Specifies the new link value to be associated with the string as returned by the method Store_LinkGet. |
The typical use of this method is to create linked lists. The user retains the locations of the current first and last members of the list as it is being created. The link value of the last member added is always originally set to zero. As new members are added the previous member's link value is set to the location of the new member.
The method Store_Message
Prototypevoid Store_Message(int number,char* String,int nString);
Parameter | Description |
number | Specifies the number of the message. |
String | Contains the actual message. |
nString | Specifies the length of the message. |
The method Store_NextReference
Prototypeint* Store_NextReference(void* PostSet);
Seq | Description 0f content |
0 | The offset of the component containing the reference |
1 | The offset of the component being referenced |
2 | The text record number in the host file of the reference |
3 | The offset in the compiled code of the reference code |
4 | The offset of the information file containing the subprogram |
5 | If the reference treated the component as terminal then one, else zero |
Its parameter is:
Parameter | Description |
PostSet | Receives the information needed to control the search. It is a small scratch storage area which must be allocated by the caller. Its content should not be used by the caller. This area must be initialized with the Store_FirstReference method. |
If there is an additional reference record available, then a semi-permanent pointer to that record is returned. If there is no additional reference, then a NULL is returned.
The method Store_Open
Prototypeint Store_Open(char* filename,int iUnit,int append);
Parameter | Description |
filename | Contains the name of the file (without an extension) to be opened for the storage area. |
iUnit | Specifies the unit number of the desired storage area. The current implementation supports upto Store_MaxUnit areas, so this integer must contain a value between 1 and Store_MaxUnit. |
append | Specifies the access permission for the file. If it is nonzero (true), then the file is opened with read/write access permission. If zero (false), then the file is opened for read only access. |
If all goes well a one (true) is returned. If there is a problem opening the storage area because the file does not exist zero (false) is returned.
The method Store_PostVector
Prototypeint Store_PostVector(char* identifier,int parent,int length,int type);
Parameter | Description |
identifier | Contains the identifier of component in null-terminated form. |
parent | Specifies root offset of the parent of the component, if the component is the child of a previously stored component. If the component has no parent -- i.e., if it belongs in the root of the symbol table then this should be set to zero. |
length | Specifies the length of information vector to be allocated for use by this component. |
type | Specifies the component object type code to be assigned to the component table. |
If there already is a component with the same identifier stored in the specified branch of the symbol table, then its root address is returned; else the component is stored and then the new root offset is returned.
The method Store_ReadFront
Prototypeint Store_ReadFront(void* info,int offset,int nFront);
Parameter | Description |
info | Receives the information read. It must have sufficient room to contain the nFront bytes. |
offset | Specifies the starting offset of the information as originally returned by the Store_WriteInfo method. |
nFront | Specifies the maximum number of bytes to be read. |
The method returns the number of bytes actually read.
The method Store_ReadInfo
Prototypeint Store_ReadInfo(void* info,int offset);
Parameter | Description |
info | Receives the information read. It must have sufficient room to contain the entire vector (see Store_ReadFront). |
offset | Specifies the starting offset of the information as originally returned by the Store_WriteInfo method. |
The method returns the length of the information vector read in bytes.
The method Store_Reference
Prototypevoid Store_Reference(int* reference);
Seq | Description 0f content |
0 | The offset of the component containing the reference |
1 | The offset of the component being referenced |
2 | The text record number in the host file of the reference |
3 | The offset in the compiled code of the reference code |
4 | The offset of the information file containing the subprogram |
5 | If the reference treated the component as terminal then one, else zero |
Note that the reference information allows the later retrieval not only of the referencing pseudocode but also the actual source statement that generated the reference. Its parameter is as follows:
Parameter | Description |
reference | Contains the 6 integer values that describe a single reference stored within the pcode created by a language compiler. |
The method Store_RewriteInfo
Prototypevoid Store_RewriteInfo(void* info,int nByte,int offset);
SYSERROR#50003: Rewriting "current" bytes over "previous" bytes.
Parameter | Description |
info | Contains the information to be written. |
nByte | Specifies the length of the information. |
offset | Contains the starting offset of the information as originally returned by the Store_WriteInfo method. |
The method Store_Select
Prototypevoid Store_Select(int Unit);
Parameter | Description |
Unit | Specifies the unit sequence number of the desired storage area. It must have a value between 1 and Store_MaxUnit. |
The method Store_SeqClose
Prototypevoid Store_SeqClose(void* sequence);
Parameter | Description |
sequence | Specifies the handle to the sequence control structure. |
The method Store_SeqCreate
Prototypevoid* Store_SeqCreate(int BlockSize);
Parameter | Description |
BlockSize | Specifies the size of each block within the sequence. It is normally a small value like 8 or 16. |
The method returns the handle for the created sequence.
The method Store_SeqOpen
Prototypevoid* Store_SeqOpen(int seqRoot);
Parameter | Description |
seqRoot | Specifies the root offset of the sequence in the storage area. It would have been the value of the Sequence_GetRoot method for the sequence when it was created. |
The handle for the opened sequence is returned.
The method Store_SetCaseSensitive
Prototypevoid Store_SetCaseSensitive(int on);
Parameter | Description |
on | Specifies how string keys are to be compared. If nonzero, there are case sensitive; else they are case insensitive |
The method Store_SetName
Prototypevoid Store_SetName(int root,CONST char* Name,int nName);
Parameter | Description of content |
root | Specifies the root offset of component in storage as originally returned by the Store_Vector method if a component name is being supplied. An offset value of zero sets the storage area name. |
name | Contains the name to be assigned to the component or area. |
nName | Specifies the length of the name to be assigned. If it has a value of zero then name parameter is assumed to be null-terminated and this method computes its length. |
The method Store_SetObjectType
Prototypevoid Store_SetObjectType(int root,int objType);
Parameter | Description |
root | Specifies the root offset of the component in storage as originally returned by the Store_Vector method. |
objType | Specifies the new object type code to be assigned to the component. |
The method Store_SetRawCharacters
Prototypevoid Store_SetRawCharacters(int status);
Parameter | Description |
status | Specifies the status of the check. If it is zero, then the check will be made. If not zero, then the check will not be made. |
The method Store_SetString
Prototypevoid Store_SetString(int addr,char* string,int length);
Parameter | Description |
addr | Specifies the offset of the string in storage as returned by the Store_String method. |
string | Contains the new value of the string. |
length | Specifies the length of the string. |
It is up to the user to ensure that this length does not exceed the length of the string when it was initially stored.
The method Store_String
Prototypeint Store_String(char* String,int nString);
Parameter | Description |
String | Contains the character string to be stored. It need not be null-terminated as its length is supplied explicitly. |
nString | Specifies the length of character string being stored. |
The method returns the offset in the storage area of the string. This offset can be used later to retrieve the string.
The method Store_SwitchVectors
Prototypevoid Store_SwitchVectors(int root1,int root2);
Parameter | Description |
root1 | Specifies the root offset of the first component of the switch. |
root2 | Specifies the root offset of the second component of the switch. |
The method Store_Unit
Prototypeint Store_Unit(void);
The method Store_Vector
Prototypeint Store_Vector(CONST char* identifier,int parent,int length,int type);
Parameter | Description |
identifier | Contains the identifier of the component in null-terminated form. It must be unique relative to its parent. |
parent | Specifies root offset of the parent of the component, if the component is the child of a previously stored component. If the component has no parent, if it belongs in the root of the symbol table, then this parameter should be zero. |
length | Specifies the length of information vector to be allocated for use by this component. |
type | Specifies the component object type code to be assigned to the component. |
If there already is a component with the same identifier stored in the specified branch of the symbol table, then a zero is returned by this method; else the nonzero root offset of the component is returned. It is this root offset which must be used to manipulate or retrieve any information for the component.
The method Store_WriteInfo
Prototypeint Store_WriteInfo(void* info,int nByte);
Parameter | Description |
info | Contains the information to be written. |
nByte | Specifies the length of the information. |
If the number of bytes to be written is not well-formed -- i.e., is less than or equal to zero, this method displays the following message and returns a zero.
SYSERR#5004: Empty or negative length (%nbyte%) record being written.
The method Store_ZeroFirst
Prototypevoid Store_ZeroFirst(int parent);
Parameter | Description |
parent | Specifies the root offset of the component whose status is to be changed. |
Table of Contents
, multiple selections available,
Related content
gmslStoreClass
gmslStoreClass
More like this
gmSCLongMemoryClass
gmSCLongMemoryClass
More like this
gmscTextClass
gmscTextClass
More like this
gmSCPagingSystemClass
gmSCPagingSystemClass
More like this
gmSCFileSystemClass
gmSCFileSystemClass
More like this
gmSCRegistryClass
gmSCRegistryClass
More like this