"Use of Visibroker for Delphi" (2)

zhaozj2021-02-16  49

"Usage of Visibroker For Delphi" -Corba Technology Practice (2) Yichang City Center People's Hospital Zhao Pu Email: 3boy@sohu.com 2, a real CORBA small service program we all know EJB, COM / DCOM / MTS / COM , or some three-layer system such as Midas / Corba, the most important architecture intermediary system, for the theoretical things, more abstract, there is no need to talk about such a deep theory here, these still leave it to the master to say, we only It is possible to understand that the masters will be given to our tools. We can call these intermediary clusters for the intermediary object group. In fact, our public partial or human machine interaction in C / S is interactive, people and procedures, procedures Interaction with the database, the destination masters do it very well. After the programming system architect design, we can clearly see our intermediary objects, which is those objects on different forms and application servers. The client can not pay completely, the retrieval of excessive implementation details, the service procedure does not have too much subject to the client program, everything is published by Interface. All connection rules. Then there is a very simple problem, that is what kind of interface, the interface can be independent of the customer and the server, which is the stressed thing in our Corba for Delphi6.

Before we declare the interface I first briefly describe what some of the relevant reserved words IDL2PAS and operators AND ARRAY AS ASM BEGIN CASE CLASS CONST CONSTRUCTOR DESTORY DISPINTERFACE DIV DO DOWNTO ELSE END EXCEPT EXPORTS FILE FINALIZATION FINALLY FOR FUNCTION GOTO IF IMPLEMENTATION IN INHERITED INITIALIZATION INLINE INTERFACE iS LABEL lIBARAY MOD NIL NOT OBJECT oF OR PACKED PROCEDURE PROGRAM PROPERTY RAISE RECORD REPEAT rESOURCESTRING SET SHL SHR STRING THEN tHREADVAR tO TRY TYPE UNIT UNTIL USER VAR WHILE WITH XOR follow the Pascal reserved word Boolean Char WideChar Shortint Smallint Integer Byte word Extended Pointer AnsiCha r Longint Cardinal Single Double Real Real48 Comp Currency ShortString Openstring file Text TextFile PAnsiChar PChar PWideChar ByteBool Wordbool LongBool AnsiString WideString TVarArrayBound PVarArray TVarData PVarData TVarArray PShortString PAnsiString PWideString PString Pextended PCurrency TDateTime PVarRec String Variant TObject Tclass Iunknown TinterfaceObject TGUID PGUID Int64 Application Screen Print Printer (the Do a comparison with Pascal, pay attention to casement)

Basic data types IDL type Pascal type boolean Boolean char Char wchar WideChar octet Byte string AnsiString wstring WideString short SmallInt unsigned short Word long Integer unsigned long Cardinal long long Int64 unsigned long long Int64 float Single double Double long double Extended fixed {no corresponding type} above The retention word and operator will be introduced in my article, and it is not specifically described here. We started to make a small program to explain that the sample is first declared an interface description: I want to pass an arbitrary type information module crb {interface testany {any getany (); // payment};}; now follow us last session The generated frame code will be added to the CRB_IMPL to join Result: = strt (form1.edit1.text); add it to the Getany method, as follows function ttestany.getany: Any; begin result: = StrtOINT Form1.edit1.text); END; This interface is the meaning of returning the string on the edit1 on the main form of our service program to the interface to facilitate the character data from the interface. Of course, we must declare the unit servermain as follows in our main form;

Interface

Uses Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs, CORBA, CRB_I, CRB_C, CRB_S, CRB_IMPL, STDCTRLS

type TForm1 = class (TForm) Label1: TLabel; Edit1: TEdit; procedure FormCreate (Sender: TObject); private {private declarations} protected MyAnyTest: TTestAny; // Main objects procedure InitCorba; public {public declarations} end;

Var Form1: TFORM1;

IMPLEMENTATION

{$ R * .dfm}

Procedure TFORM1.INITCORBA; Begin Corbainitialize;

// Join the CRB service code myanytest: = TTESTANYSKELETON.CREATE ('Any Test Server', TMYTEST.CREATE); Boa.objisready (MyAnyTest as _Object);

Procedure TFORM1.FormCreate (Sender: TOBJECT); Begin Initcorba;

END. What do our clients get this string? Then we only need to reference this interface method in the client program, the code is the following unit clientmain; Interface

Uses Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, CORBA, CRB_I, CRB_C;

type TForm1 = class (TForm) Button1: TButton; Label1: TLabel; procedure FormCreate (Sender: TObject); procedure Button1Click (Sender: TObject); procedure FormDestroy (Sender: TObject); private {Private declarations} FromIStr: TTestAny; public { Public Declarations}

Var Form1: TFORM1;

IMPLEMENTATION

{$ R * .dfm}

Procedure tform1.formcreate (sender: TOBJECT); Begin Corbainitialize; fromistr: = TTESTANYHELPER.BIND; // Create an instance end of an interface;

Procedure TForm1.Button1Click (Sender: Tobject); var myany: any; begin myany: = fromistr.getany (); // Reference The method of the interface instance label1.caption: = INTOSTR (myany); // Transform the results of the method to String, pay it to label1.caption end;

Procedure TForm1.FormDestroy (Sender: TOBJECT); begin fromistr: = nil; // Release Interface instance object END;

Do you understand the above procedure? In the next section, we will continue to explain how to pass an array object. If you are wrong, please contact your letter! see you later

转载请注明原文地址:https://www.9cbs.com/read-27064.html

New Post(0)