|##########|
|#MAGIC   #|BLOCLNGE
|#PROJECT #|""
|#PATHS   #|"StdProject"
|#FLAGS   #|xx---x--x-----x-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x----xxxxx-xx---
|##########|
DEFINITION MODULE ObjFiles;

FROM OStreams      IMPORT InStream,EOF;
FROM ODictionaries IMPORT SymbolExists,SymbolNotFound;
FROM Exceptions    IMPORT RangeViolation;

EXCEPTION
  SyntaxError : "Syntactic error";
  UnknownKey  : "Unknown key descriptor";

TYPE
  ClassDict   = HIDDEN;
  ObjDict     = HIDDEN;
  KeyDict     = HIDDEN;

  StrPtr      = CLASSPTR TO STRING;

  ObjFile     = POINTER TO ObjFileObj;
  Retrievable = POINTER TO OBJECT
                  METHOD Retrieve(file : ObjFile;key : LONGINT);
                END;
  Constructor = PROCEDURE(REF name : STRING):Retrievable;
  ConList     = ARRAY OF RECORD
                  name : POINTER TO STRING;
                  con  : Constructor;
                END;
  ConNodePtr  = POINTER TO ConNode;
  ConNode     = RECORD
                  car : Retrievable;
                  cdr : ConNodePtr;
                END;
  ObjList     = POINTER TO OBJECT OF Retrievable;
                  objs : ConNodePtr;
                  CONSTRUCTOR Create(file : ObjFile):Retrievable;
                  DESTRUCTOR Delete;
                  METHOD Destruct;
                END;
  ObjFileObj  = OBJECT
                  in      : InStream;
                  classes : ClassDict;
                  objects : ObjDict;
                  keys    : KeyDict;

                  CONSTRUCTOR Create;
                  DESTRUCTOR Delete;

                  METHOD ReadObject():Retrievable;
                  $$OwnHeap:=TRUE
                  METHOD ReadString():STRING;
                  METHOD ReadText(VAR str : StrPtr);

                  METHOD AddKey(REF names : LIST OF STRING);
                  METHOD AddClass(REF name : STRING;con : Constructor);
                  METHOD AddClasses(REF cons : ConList);

                  METHOD Include;

                  METHOD Retrieve(in : InStream);
                END;

END ObjFiles.
