Browse Source

+ Added TCustomConnection by Uberto Barbini

michael 20 years ago
parent
commit
89e6318dd8
2 changed files with 113 additions and 2 deletions
  1. 81 1
      fcl/db/database.inc
  2. 32 1
      fcl/db/db.pp

+ 81 - 1
fcl/db/database.inc

@@ -442,9 +442,89 @@ begin
     DatabaseError(SNoDatasets);
 end;
 
+{ ---------------------------------------------------------------------
+    TCustomConnection
+  ---------------------------------------------------------------------}
+
+procedure TCustomConnection.SetAfterConnect(const AValue: TNotifyEvent);
+begin
+  if FAfterConnect=AValue then exit;
+  FAfterConnect:=AValue;
+end;
+
+procedure TCustomConnection.SetAfterDisconnect(const AValue: TNotifyEvent);
+begin
+  if FAfterDisconnect=AValue then exit;
+  FAfterDisconnect:=AValue;
+end;
+
+procedure TCustomConnection.SetBeforeConnect(const AValue: TNotifyEvent);
+begin
+  if FBeforeConnect=AValue then exit;
+  FBeforeConnect:=AValue;
+end;
+
+procedure TCustomConnection.SetBeforeDisconnect(const AValue: TNotifyEvent);
+begin
+  if FBeforeDisconnect=AValue then exit;
+  FBeforeDisconnect:=AValue;
+end;
+
+procedure TCustomConnection.DoInternalConnect;
+begin
+  if Assigned(BeforeConnect) then
+    BeforeConnect(self);
+  DoConnect;
+  if Assigned(AfterConnect) then
+    AfterConnect(self);
+end;
+
+procedure TCustomConnection.DoInternalDisconnect;
+begin
+  if Assigned(BeforeDisconnect) then
+    BeforeDisconnect(self);
+  DoDisconnect;
+  if Assigned(AfterDisconnect) then
+    AfterDisconnect(self);
+end;
+
+procedure TCustomConnection.DoConnect;
+
+begin
+  // Do nothing yet
+end;
+
+procedure TCustomConnection.DoDisconnect;
+
+begin
+  // Do nothing yet
+end;
+
+function TCustomConnection.GetConnected: boolean;
+
+begin
+  Result := Connected;
+end;
+
+procedure TCustomConnection.StartTransaction;
+
+begin
+  // Do nothing yet
+end;
+
+procedure TCustomConnection.EndTransaction;
+
+begin
+  // Do nothing yet
+end;
+
+
 {
   $Log$
-  Revision 1.11  2005-04-24 19:21:28  joost
+  Revision 1.12  2005-04-26 16:37:44  michael
+  + Added TCustomConnection by Uberto Barbini
+
+  Revision 1.11  2005/04/24 19:21:28  joost
   - some fixes in assignment of transactions and databases
 
   Revision 1.10  2005/02/14 17:13:12  peter

+ 32 - 1
fcl/db/db.pp

@@ -1373,6 +1373,34 @@ type
     property Params : TStrings read FParams Write FParams;
     property OnLogin: TLoginEvent read FOnLogin write FOnLogin;
   end;
+  
+    { TCustomConnection }
+
+  TCustomConnection = class(TDatabase)
+  private
+    FAfterConnect: TNotifyEvent;
+    FAfterDisconnect: TNotifyEvent;
+    FBeforeConnect: TNotifyEvent;
+    FBeforeDisconnect: TNotifyEvent;
+    procedure SetAfterConnect(const AValue: TNotifyEvent);
+    procedure SetAfterDisconnect(const AValue: TNotifyEvent);
+    procedure SetBeforeConnect(const AValue: TNotifyEvent);
+    procedure SetBeforeDisconnect(const AValue: TNotifyEvent);
+  protected
+    procedure DoInternalConnect; override;
+    procedure DoInternalDisconnect; override;
+    procedure DoConnect; virtual;
+    procedure DoDisconnect; virtual;
+    function GetConnected : boolean; virtual;
+    procedure StartTransaction; override;
+    procedure EndTransaction; override;
+  published
+    property AfterConnect : TNotifyEvent read FAfterConnect write SetAfterConnect;
+    property BeforeConnect : TNotifyEvent read FBeforeConnect write SetBeforeConnect;
+    property AfterDisconnect : TNotifyEvent read FAfterDisconnect write SetAfterDisconnect;
+    property BeforeDisconnect : TNotifyEvent read FBeforeDisconnect write SetBeforeDisconnect;
+  end;
+  
 
   { TBufDataset }
 
@@ -1911,7 +1939,10 @@ end.
 
 {
   $Log$
-  Revision 1.49  2005-04-26 15:45:30  michael
+  Revision 1.50  2005-04-26 16:37:44  michael
+  + Added TCustomConnection by Uberto Barbini
+
+  Revision 1.49  2005/04/26 15:45:30  michael
   + Patch from Sergey Smirnov to fix TTimeField.AsString
 
   Revision 1.48  2005/04/24 19:21:28  joost