home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / full / delphi / RUNIMAGE / DELPHI30 / SOURCE / TOOLSAPI / VIRTINTF.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1997-08-04  |  1.9 KB  |  83 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,97 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit VirtIntf;
  11.  
  12. interface
  13.  
  14. type
  15.   TInterface = class
  16.   private
  17.     FRefCount: Longint;
  18.   public
  19.     constructor Create;
  20.     procedure Free;
  21.     function AddRef: Longint; virtual; stdcall;
  22.     function Release: Longint; virtual; stdcall;
  23.     function GetVersion: Integer; virtual; stdcall;
  24.   end;
  25.  
  26.   { TIStream - This provides a pure virtual interface to a physical stream }
  27.  
  28.   TIStream = class(TInterface)
  29.   public
  30.     function Read(var Buffer; Count: Longint): Longint; virtual; stdcall; abstract;
  31.     function Write(const Buffer; Count: Longint): Longint; virtual; stdcall; abstract;
  32.     function Seek(Offset: Longint; Origin: Word): Longint; virtual; stdcall; abstract;
  33.     function GetModifyTime: Longint; virtual; stdcall; abstract;
  34.     procedure SetModifyTime(Time: Longint); virtual; stdcall; abstract;
  35.     procedure Flush; virtual; stdcall; abstract;
  36.   end;
  37.  
  38. function ReleaseException: string;
  39.  
  40. implementation
  41.  
  42. uses SysUtils;
  43.  
  44. { TInterface }
  45.  
  46. constructor TInterface.Create;
  47. begin
  48.   inherited Create;
  49.   FRefCount := 1;
  50. end;
  51.  
  52. procedure TInterface.Free;
  53. begin
  54.   if Self <> nil then Release;
  55. end;
  56.  
  57. function TInterface.AddRef: Longint;
  58. begin
  59.   Inc(FRefCount);
  60.   Result := FRefCount;
  61. end;
  62.  
  63. function TInterface.Release: Longint;
  64. begin
  65.   Dec(FRefCount);
  66.   Result := FRefCount;
  67.   if FRefCount = 0 then Destroy;
  68. end;
  69.  
  70. function TInterface.GetVersion: Integer;
  71. begin
  72.   Result := 3;
  73. end;
  74.  
  75. { Exception handling }
  76.  
  77. function ReleaseException: string;
  78. begin
  79.   Result := Exception(ExceptObject).Message;
  80. end;
  81.  
  82. end.
  83.