home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Demos / Corba / Account / accountserver_tlb.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  6KB  |  161 lines

  1. unit AccountServer_TLB;
  2.  
  3. // ************************************************************************ //
  4. // WARNING                                                                  //
  5. // -------                                                                  //
  6. // The types declared in this file were generated from data read from a     //
  7. // Type Library. If this type library is explicitly or indirectly (via      //
  8. // another type library referring to this type library) re-imported, or the //
  9. // 'Refresh' command of the Type Library Editor activated while editing the //
  10. // Type Library, the contents of this file will be regenerated and all      //
  11. // manual modifications will be lost.                                       //
  12. // ************************************************************************ //
  13.  
  14. // PASTLWTR : $Revision:   1.11.1.63  $
  15. // File generated on 6/17/98 3:55:15 PM from Type Library described below.
  16.  
  17. // ************************************************************************ //
  18. // Type Lib: C:\Borland\Delphi4\Demos\Corba\Account\AccountServer.tlb
  19. // IID\LCID: {CE4F24E4-FD8A-11D1-AA9F-00C04FA368D1}\0
  20. // Helpfile: 
  21. // HelpString: Project1 Library
  22. // Version:    1.0
  23. // ************************************************************************ //
  24.  
  25. interface
  26.  
  27. uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL, SysUtils, CORBAObj, OrbPas, CorbaStd;
  28.  
  29. // *********************************************************************//
  30. // GUIDS declared in the TypeLibrary. Following prefixes are used:      //
  31. //   Type Libraries     : LIBID_xxxx                                    //
  32. //   CoClasses          : CLASS_xxxx                                    //
  33. //   DISPInterfaces     : DIID_xxxx                                     //
  34. //   Non-DISP interfaces: IID_xxxx                                      //
  35. // *********************************************************************//
  36. const
  37.   LIBID_AccountServer: TGUID = '{CE4F24E4-FD8A-11D1-AA9F-00C04FA368D1}';
  38.   IID_IAccount: TGUID = '{CE4F24E5-FD8A-11D1-AA9F-00C04FA368D1}';
  39.   CLASS_Account: TGUID = '{CE4F24E7-FD8A-11D1-AA9F-00C04FA368D1}';
  40. type
  41.  
  42. // *********************************************************************//
  43. // Forward declaration of interfaces defined in Type Library            //
  44. // *********************************************************************//
  45.   IAccount = interface;
  46.   IAccountDisp = dispinterface;
  47.  
  48. // *********************************************************************//
  49. // Declaration of CoClasses defined in Type Library                     //
  50. // (NOTE: Here we map each CoClass to its Default Interface)            //
  51. // *********************************************************************//
  52.   Account = IAccount;
  53.  
  54.  
  55. // *********************************************************************//
  56. // Interface: IAccount
  57. // Flags:     (4416) Dual OleAutomation Dispatchable
  58. // GUID:      {CE4F24E5-FD8A-11D1-AA9F-00C04FA368D1}
  59. // *********************************************************************//
  60.   IAccount = interface(IDispatch)
  61.     ['{CE4F24E5-FD8A-11D1-AA9F-00C04FA368D1}']
  62.     function Balance: Double; safecall;
  63.   end;
  64.  
  65. // *********************************************************************//
  66. // DispIntf:  IAccountDisp
  67. // Flags:     (4416) Dual OleAutomation Dispatchable
  68. // GUID:      {CE4F24E5-FD8A-11D1-AA9F-00C04FA368D1}
  69. // *********************************************************************//
  70.   IAccountDisp = dispinterface
  71.     ['{CE4F24E5-FD8A-11D1-AA9F-00C04FA368D1}']
  72.     function Balance: Double; dispid 1;
  73.   end;
  74.  
  75.   TAccountStub = class(TCorbaDispatchStub, IAccount)
  76.   public
  77.     function Balance: Double; safecall;
  78.   end;
  79.  
  80.   TAccountSkeleton = class(TCorbaSkeleton)
  81.   private
  82.     FIntf: IAccount;
  83.   public
  84.     constructor Create(const InstanceName: string; const Impl: IUnknown); override;
  85.     procedure GetImplementation(out Impl: IUnknown); override; stdcall;
  86.   published
  87.     procedure Balance(const InBuf: IMarshalInBuffer; Cookie: Pointer);
  88.   end;
  89.  
  90.   CoAccount = class
  91.     class function Create: IAccount;
  92.     class function CreateRemote(const MachineName: string): IAccount;
  93.   end;
  94.  
  95.   TAccountCorbaFactory = class
  96.     class function CreateInstance(const InstanceName: string): IAccount;
  97.   end;
  98.  
  99. implementation
  100.  
  101. uses ComObj;
  102.  
  103. { TAccountStub }
  104.  
  105. function TAccountStub.Balance: Double;
  106. var
  107.   OutBuf: IMarshalOutBuffer;
  108.   InBuf: IMarshalInBuffer;
  109. begin
  110.   FStub.CreateRequest('Balance', True, OutBuf);
  111.   FStub.Invoke(OutBuf, InBuf);
  112.   Result := InBuf.GetDouble;
  113. end;
  114.  
  115. { TAccountSkeleton }
  116.  
  117. constructor TAccountSkeleton.Create(const InstanceName: string; const Impl: IUnknown);
  118. begin
  119.   inherited;
  120.   inherited InitSkeleton('Account', InstanceName, 'IDL:AccountServer/IAccount:1.0', tmMultiThreaded, True);
  121.   FIntf := Impl as IAccount;
  122. end;
  123.  
  124. procedure TAccountSkeleton.GetImplementation(out Impl: IUnknown);
  125. begin
  126.   Impl := FIntf;
  127. end;
  128.  
  129. procedure TAccountSkeleton.Balance(const InBuf: IMarshalInBuffer; Cookie: Pointer);
  130. var
  131.   OutBuf: IMarshalOutBuffer;
  132.   Retval: Double;
  133. begin
  134.   Retval := FIntf.Balance;
  135.   FSkeleton.GetReplyBuffer(Cookie, OutBuf);
  136.   OutBuf.PutDouble(Retval);
  137. end;
  138.  
  139. class function CoAccount.Create: IAccount;
  140. begin
  141.   Result := CreateComObject(CLASS_Account) as IAccount;
  142. end;
  143.  
  144. class function CoAccount.CreateRemote(const MachineName: string): IAccount;
  145. begin
  146.   Result := CreateRemoteComObject(MachineName, CLASS_Account) as IAccount;
  147. end;
  148.  
  149. class function TAccountCorbaFactory.CreateInstance(const InstanceName: string): IAccount;
  150. begin
  151.   Result := CorbaFactoryCreateStub('IDL:AccountServer/AccountFactory:1.0', 'Account',
  152.     InstanceName, '', IAccount) as IAccount;
  153. end;
  154.  
  155. initialization
  156.   CorbaStubManager.RegisterStub(IAccount, TAccountStub);
  157.   CorbaInterfaceIDManager.RegisterInterface(IAccount, 'IDL:AccountServer/IAccount:1.0');
  158.   CorbaSkeletonManager.RegisterSkeleton(IAccount, TAccountSkeleton);
  159.  
  160. end.
  161.