ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBServices.pas
Revision: 143
Committed: Fri Feb 23 12:11:21 2018 UTC (6 years, 9 months ago) by tony
Content type: text/x-pascal
Original Path: ibx/trunk/fbintf/client/FBServices.pas
File size: 3561 byte(s)
Log Message:
Fixes Merged

File Contents

# Content
1 (*
2 * Firebird Interface (fbintf). The fbintf components provide a set of
3 * Pascal language bindings for the Firebird API. Although predominantly
4 * a new development they include source code taken from IBX and may be
5 * considered a derived product. This software thus also includes the copyright
6 * notice and license conditions from IBX.
7 *
8 * Except for those parts dervied from IBX, contents of this file are subject
9 * to the Initial Developer's Public License Version 1.0 (the "License"); you
10 * may not use this file except in compliance with the License. You may obtain a
11 * copy of the License here:
12 *
13 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
14 *
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing rights
18 * and limitations under the License.
19 *
20 * The Initial Developer of the Original Code is Tony Whyman.
21 *
22 * The Original Code is (C) 2016 Tony Whyman, MWA Software
23 * (http://www.mwasoftware.co.uk).
24 *
25 * All Rights Reserved.
26 *
27 * Contributor(s): ______________________________________.
28 *
29 *)
30 unit FBServices;
31 {$IFDEF MSWINDOWS}
32 {$DEFINE WINDOWS}
33 {$ENDIF}
34
35 {$IFDEF FPC}
36 {$mode delphi}
37 {$interfaces COM}
38 {$ENDIF}
39
40 interface
41
42 uses
43 Classes, SysUtils, IB, FBParamBlock, FBActivityMonitor;
44
45 type
46
47 { TFBServiceManager }
48
49 TFBServiceManager = class(TFBInterfacedObject)
50 private
51 FFirebirdAPI: IFirebirdAPI;
52 FProtocol: TProtocol;
53 FServerName: AnsiString;
54 FPort: AnsiString;
55 procedure CheckServerName;
56 protected
57 FSPB: ISPB;
58 procedure InternalAttach(ConnectString: AnsiString); virtual; abstract;
59 public
60 constructor Create(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB; Port: AnsiString = '');
61 destructor Destroy; override;
62 public
63 {IServiceManager}
64 function getSPB: ISPB;
65 function getServerName: AnsiString;
66 procedure Attach;
67 procedure Detach(Force: boolean=false); virtual; abstract;
68 function AllocateSRB: ISRB;
69 function AllocateSQPB: ISQPB;
70 function Query(SQPB: ISQPB; Request: ISRB): IServiceQueryResults; overload; virtual; abstract;
71 function Query(Request: ISRB): IServiceQueryResults; overload;
72 end;
73
74 implementation
75
76 uses FBMessages, FBClientAPI, IBUtils;
77
78 { TFBServiceManager }
79
80 procedure TFBServiceManager.CheckServerName;
81 begin
82 if (FServerName = '') and (FProtocol <> Local) then
83 IBError(ibxeServerNameMissing, [nil]);
84 end;
85
86 constructor TFBServiceManager.Create(ServerName: AnsiString;
87 Protocol: TProtocol; SPB: ISPB; Port: AnsiString);
88 begin
89 inherited Create;
90 FFirebirdAPI := FirebirdAPI; {Keep reference to interface}
91 FProtocol := Protocol;
92 FSPB := SPB;
93 FServerName := ServerName;
94 FPort := Port;
95 Attach;
96 end;
97
98 destructor TFBServiceManager.Destroy;
99 begin
100 Detach(true);
101 inherited Destroy;
102 end;
103
104 function TFBServiceManager.getSPB: ISPB;
105 begin
106 Result := FSPB;
107 end;
108
109 function TFBServiceManager.getServerName: AnsiString;
110 begin
111 Result := FServerName;
112 end;
113
114 procedure TFBServiceManager.Attach;
115 var ConnectString: AnsiString;
116 begin
117 ConnectString := MakeConnectString(FServerName,'service_mgr',FProtocol,FPort);
118 InternalAttach(ConnectString);
119 end;
120
121 function TFBServiceManager.AllocateSRB: ISRB;
122 begin
123 Result := TSRB.Create;
124 end;
125
126 function TFBServiceManager.AllocateSQPB: ISQPB;
127 begin
128 Result := TSQPB.Create;
129 end;
130
131 function TFBServiceManager.Query(Request: ISRB): IServiceQueryResults;
132 begin
133 Result := Query(nil,Request);
134 end;
135
136 end.
137