home *** CD-ROM | disk | FTP | other *** search
-
- {*******************************************************}
- { }
- { Delphi Visual Component Library }
- { }
- { Copyright (c) 1995,1996 Borland International }
- { }
- {*******************************************************}
-
- unit VirtIntf;
-
- interface
-
- type
- TInterface = class
- private
- FRefCount: Longint;
- public
- constructor Create;
- procedure Free;
- function AddRef: Longint; virtual; stdcall;
- function Release: Longint; virtual; stdcall;
- function GetVersion: Integer; virtual; stdcall;
- end;
-
- { TIStream - This provides a pure virtual interface to a physical stream }
-
- TIStream = class(TInterface)
- public
- function Read(var Buffer; Count: Longint): Longint; virtual; stdcall; abstract;
- function Write(const Buffer; Count: Longint): Longint; virtual; stdcall; abstract;
- function Seek(Offset: Longint; Origin: Word): Longint; virtual; stdcall; abstract;
- function GetModifyTime: Longint; virtual; stdcall; abstract;
- procedure SetModifyTime(Time: Longint); virtual; stdcall; abstract;
- end;
-
- function ReleaseException: string;
-
- implementation
-
- uses SysUtils;
-
- { TInterface }
-
- constructor TInterface.Create;
- begin
- inherited Create;
- FRefCount := 1;
- end;
-
- procedure TInterface.Free;
- begin
- if Self <> nil then Release;
- end;
-
- function TInterface.AddRef: Longint;
- begin
- Inc(FRefCount);
- Result := FRefCount;
- end;
-
- function TInterface.Release: Longint;
- begin
- Dec(FRefCount);
- Result := FRefCount;
- if FRefCount = 0 then Destroy;
- end;
-
- function TInterface.GetVersion: Integer;
- begin
- Result := 2;
- end;
-
- { Exception handling }
-
- function ReleaseException: string;
- begin
- Result := Exception(ExceptObject).Message;
- end;
-
- end.
-