DEFINITION MODULE AbstractClasses;

------------------------------------
-- The classes defined in the AbstractClasses module
-- mimic YAFL's predefined types. They are significantly
-- less efficient, since they must be CREATEd, use access
-- methods, etc...
--
-- However, they are plain user-defined classes and as such,
-- may be used as parameters for parameterized classes.
------------------------------------

  CLASS AbstractChar;
    METHOD Set(Ch: CHAR);
    METHOD Get: CHAR;
  END AbstractChar;

  CLASS AbstractInteger;
    METHOD Set(Int: INTEGER);
    METHOD Get: INTEGER;
  END AbstractInteger;
  
  CLASS AbstractBoolean;
    METHOD Set(Flag: BOOLEAN);
    METHOD Get: BOOLEAN;
  END AbstractBoolean;
  
  CLASS AbstractReal;
    METHOD Set(r: REAL);
    METHOD Get: REAL;
  END AbstractReal;
  
  CLASS AbstractArray(Element);
    REDEFINE METHOD CREATE (Size: INTEGER);
    METHOD Get(ElNr: INTEGER): Element;
    METHOD Set(ElNr: INTEGER;
               El: Element);
             
    --------------------------------------------
    -- The Size and Slice methods mimic the SIZE
    -- and SLICE pseudo-methods when applied to
    -- plain arrays.
    --------------------------------------------             
    METHOD Size: INTEGER;
    METHOD Slice(From, To: INTEGER): AbstractArray(Element);
    
    REDEFINE METHOD CLONE(Other: AbstractArray(Element));
  END AbstractArray;

  --------------------------------------
  -- AbstractString's are AbstractArrays, with
  -- the possibility of providing an initial
  -- value at creation time more conveniently
  -- than by providing characters one by one.
  --------------------------------------
  CLASS AbstractString;
    INHERITS AbstractArray(AbstractChar);
    REDEFINE METHOD CREATE(Value: ARRAY OF CHAR);
  END AbstractString;                  
  --------------------------------------
END AbstractClasses; -- End of module...

