From: Brian May <bam@snoopy.apana.org.au>
Subject: Re: APQ
Date: Sat, 18 Dec 2004 09:55:00 +1100
Date: 2004-12-18T09:55:00+11:00 [thread overview]
Message-ID: <sa4acscr0vv.fsf@snoopy.apana.org.au> (raw)
In-Reply-To: sa4pt19qhg1.fsf@snoopy.apana.org.au
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]
>>>>> "Brian" == Brian May <bam@snoopy.apana.org.au> writes:
Brian> Good point. I meant to change it in both places, but I think I ended
Brian> up changing it in only one place...
You were right, I missed it up.
Here is a patch that turns all methods into abstract methods.
Unfortunately, I could not make Finalize abstract, the compiler
complained that abstract methods must be visible (Finalize is in the
private section). This restriction seems strange to me, but I am not
going to argue with the compiler and left the function generating an
exception at run-time.
I suspect Finalize doesn't need to be abstract, but didn't go
exploring enough to verify why it is abstract.
Also, I noticed that the pointers are "access all". I couldn't see any
requirement for "all", and my code still compiles, so I changed them
to "access". This eliminates a potential source of errors.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch for abstract methods --]
[-- Type: text/x-patch, Size: 13506 bytes --]
--- apq-2.1-old/apq.ads 2003-09-25 05:56:24.000000000 +1000
+++ apq-2.1/apq.ads 2004-12-18 09:50:31.000000000 +1100
@@ -90,7 +90,7 @@
type Column_Index_Type is new Positive;
- type Root_Connection_Type is new Ada.Finalization.Limited_Controlled with private;
+ type Root_Connection_Type is abstract new Ada.Finalization.Limited_Controlled with private;
type Trace_Mode_Type is (
Trace_None, -- No tracing
@@ -101,10 +101,10 @@
type Fetch_Mode_Type is ( Sequential_Fetch, Random_Fetch );
- type Root_Query_Type is new Ada.Finalization.Controlled with private;
+ type Root_Query_Type is abstract new Ada.Finalization.Controlled with private;
- function Engine_Of(C : Root_Connection_Type) return Database_Type;
+ function Engine_Of(C : Root_Connection_Type) return Database_Type is Abstract;
function New_Query(C : Root_Connection_Type) return Root_Query_Type'Class;
procedure Set_Host_Name(C : in out Root_Connection_Type; Host_Name : String);
@@ -123,13 +123,13 @@
function User(C : Root_Connection_Type) return String;
function Password(C : Root_Connection_Type) return String;
- procedure Connect(C : in out Root_Connection_Type); -- IS ABSTRACT
- procedure Connect(C : in out Root_Connection_Type; Same_As : Root_Connection_Type'Class); -- IS ABSTRACT
- procedure Disconnect(C : in out Root_Connection_Type); -- IS ABSTRACT
-
- function Is_Connected(C : Root_Connection_Type) return Boolean; -- IS ABSTRACT
- procedure Reset(C : in out Root_Connection_Type); -- IS ABSTRACT
- function Error_Message(C : Root_Connection_Type) return String; -- IS ABSTRACT
+ procedure Connect(C : in out Root_Connection_Type) is abstract;
+ procedure Connect(C : in out Root_Connection_Type; Same_As : Root_Connection_Type'Class) is abstract;
+ procedure Disconnect(C : in out Root_Connection_Type) is abstract;
+
+ function Is_Connected(C : Root_Connection_Type) return Boolean is abstract;
+ procedure Reset(C : in out Root_Connection_Type) is abstract;
+ function Error_Message(C : Root_Connection_Type) return String is abstract;
function In_Abort_State(C : Root_Connection_Type) return Boolean;
@@ -137,7 +137,7 @@
function Will_Rollback_On_Finalize(C : Root_Connection_Type) return Boolean;
- function Engine_Of(Q : Root_Query_Type) return Database_Type;
+ function Engine_Of(Q : Root_Query_Type) return Database_Type is Abstract;
procedure Clear(Q : in out Root_Query_Type);
function Fetch_Mode(Q : Root_Query_Type) return Fetch_Mode_Type;
@@ -160,40 +160,40 @@
procedure Append_Quoted(Q : in out Root_Query_Type; Connection : Root_Connection_Type'Class; SQL : String; After : String := "");
procedure Append_Quoted(Q : in out Root_Query_Type; Connection : Root_Connection_Type'Class; SQL : Ada.Strings.Unbounded.Unbounded_String; After : String := "");
- procedure Execute(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class);
- procedure Execute_Checked(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class; Msg : String := "");
+ procedure Execute(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is abstract;
+ procedure Execute_Checked(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class; Msg : String := "") is abstract;
- procedure Begin_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class);
- procedure Commit_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class);
- procedure Rollback_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class);
+ procedure Begin_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is abstract;
+ procedure Commit_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is abstract;
+ procedure Rollback_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is abstract;
procedure Raise_Exceptions(Query : in out Root_Query_Type; Raise_On : Boolean := True);
procedure Report_Errors(Query : in out Root_Query_Type; Report_On : Boolean := True);
- procedure Rewind(Q : in out Root_Query_Type);
- procedure Fetch(Q : in out Root_Query_Type);
- procedure Fetch(Q : in out Root_Query_Type; TX : Tuple_Index_Type);
-
- function End_of_Query(Q : Root_Query_Type) return Boolean;
- function Tuple(Q : Root_Query_Type) return Tuple_Index_Type;
- function Tuples(Q : Root_Query_Type) return Tuple_Count_Type;
+ procedure Rewind(Q : in out Root_Query_Type) is abstract;
+ procedure Fetch(Q : in out Root_Query_Type) is abstract;
+ procedure Fetch(Q : in out Root_Query_Type; TX : Tuple_Index_Type) is abstract;
+
+ function End_of_Query(Q : Root_Query_Type) return Boolean is abstract;
+ function Tuple(Q : Root_Query_Type) return Tuple_Index_Type is abstract;
+ function Tuples(Q : Root_Query_Type) return Tuple_Count_Type is abstract;
- function Value(Query : Root_Query_Type; CX : Column_Index_Type) return String; -- Abstract
+ function Value(Query : Root_Query_Type; CX : Column_Index_Type) return String is abstract;
procedure Value(Query: Root_Query_Type; CX : Column_Index_Type; V : out String);
function Value(Query : Root_Query_Type; CX : Column_Index_Type) return Ada.Strings.Unbounded.Unbounded_String;
function Value(Query : Root_Query_Type; CX : Column_Index_Type) return Row_ID_Type;
function Value(Query : Root_Query_Type; CX : Column_Index_Type) return APQ_Bitstring;
- function Result(Query : Root_Query_Type) return Natural; -- Returns Result_Type'Pos()
+ function Result(Query : Root_Query_Type) return Natural is abstract; -- Returns Result_Type'Pos()
- function Is_Null(Q : Root_Query_Type; CX : Column_Index_Type) return Boolean;
+ function Is_Null(Q : Root_Query_Type; CX : Column_Index_Type) return Boolean is abstract;
- function Command_Oid(Query : Root_Query_Type) return Row_ID_Type;
- function Null_Oid(Query : Root_Query_Type) return Row_ID_Type;
+ function Command_Oid(Query : Root_Query_Type) return Row_ID_Type is abstract;
+ function Null_Oid(Query : Root_Query_Type) return Row_ID_Type is abstract;
- function Error_Message(Query : Root_Query_Type) return String;
- function Is_Duplicate_Key(Query : Root_Query_Type) return Boolean;
+ function Error_Message(Query : Root_Query_Type) return String is abstract;
+ function Is_Duplicate_Key(Query : Root_Query_Type) return Boolean is abstract;
function To_String(Query : Root_Query_Type) return String;
@@ -573,15 +573,15 @@
package CStr renames Interfaces.C_Streams;
- type String_Ptr is access all String;
+ type String_Ptr is access String;
type String_Ptr_Array is array(Natural range <>) of String_Ptr;
- type String_Ptr_Array_Access is access all String_Ptr_Array;
- type Stream_Element_Array_Ptr is access all Ada.Streams.Stream_Element_Array;
+ type String_Ptr_Array_Access is access String_Ptr_Array;
+ type Stream_Element_Array_Ptr is access Ada.Streams.Stream_Element_Array;
subtype Port_Integer is Integer range 0..32768;
type Port_Format_Type is ( IP_Port, UNIX_Port );
- type Root_Connection_Type is new Ada.Finalization.Limited_Controlled with
+ type Root_Connection_Type is abstract new Ada.Finalization.Limited_Controlled with
record
Host_Name : String_Ptr; -- Host name string or..
Host_Address : String_Ptr; -- Host IP address
@@ -602,7 +602,7 @@
procedure Clear_Abort_State(C : in out Root_Connection_Type);
- type Root_Query_Type is new Ada.Finalization.Controlled with
+ type Root_Query_Type is abstract new Ada.Finalization.Controlled with
record
Count : Natural := 0; -- # of elements in the Collection
Alloc : Natural := 0; -- # of allocated elements in the Collection
--- apq-2.1-old/apq.adb 2003-09-25 05:56:24.000000000 +1000
+++ apq-2.1/apq.adb 2004-12-18 09:10:51.000000000 +1100
@@ -198,38 +198,6 @@
-- ABSTRACT PRIMITIVES
- procedure Connect(C : in out Root_Connection_Type) is
- begin
- raise Is_Abstract;
- end Connect;
-
- procedure Connect(C : in out Root_Connection_Type; Same_As : Root_Connection_Type'Class) is
- begin
- raise Is_Abstract;
- end Connect;
-
- procedure Disconnect(C : in out Root_Connection_Type) is
- begin
- raise Is_Abstract;
- end Disconnect;
-
- function Is_Connected(C : Root_Connection_Type) return Boolean is
- begin
- raise Is_Abstract;
- return False;
- end Is_Connected;
-
- procedure Reset(C : in out Root_Connection_Type) is
- begin
- raise Is_Abstract;
- end Reset;
-
- function Error_Message(C : Root_Connection_Type) return String is
- begin
- raise Is_Abstract;
- return "";
- end Error_Message;
-
procedure Clear(Q : in out Root_Query_Type) is
begin
for X in 1..Q.Count loop
@@ -368,45 +336,6 @@
end;
end To_String;
- procedure Rewind(Q : in out Root_Query_Type) is
- begin
- raise Is_Abstract;
- end Rewind;
-
- procedure Fetch(Q : in out Root_Query_Type) is
- begin
- raise Is_Abstract;
- end Fetch;
-
- procedure Fetch(Q : in out Root_Query_Type; TX : Tuple_Index_Type) is
- begin
- raise Is_Abstract;
- end Fetch;
-
- function End_of_Query(Q : Root_Query_Type) return Boolean is
- begin
- raise Is_Abstract;
- return False;
- end End_of_Query;
-
- function Tuple(Q : Root_Query_Type) return Tuple_Index_Type is
- begin
- raise Is_Abstract;
- return Tuple_Index_Type'First;
- end Tuple;
-
- function Tuples(Q : Root_Query_Type) return Tuple_Count_Type is
- begin
- raise Is_Abstract;
- return Tuple_Count_Type'First;
- end Tuples;
-
- function Value(Query : Root_Query_Type; CX : Column_Index_Type) return String is
- begin
- raise Is_Abstract;
- return ":-)";
- end Value;
-
function Value(Query : Root_Query_Type; CX : Column_Index_Type) return Ada.Strings.Unbounded.Unbounded_String is
use Ada.Strings.Unbounded;
begin
@@ -443,73 +372,6 @@
return C.Rollback_Finalize;
end Will_Rollback_On_Finalize;
- function Result(Query : Root_Query_Type) return Natural is
- begin
- raise Is_Abstract; -- This primitive must be overridden by the implementation
- return 0; -- This is just to satisfy the compiler (not executed)
- end Result;
-
- function Engine_Of(C : Root_Connection_Type) return Database_Type is
- begin
- raise Is_Abstract; -- Must be overridden
- return Database_Type'First; -- To quiet the compiler
- end Engine_Of;
-
- function Engine_Of(Q : Root_Query_Type) return Database_Type is
- begin
- raise Is_Abstract; -- Must be overridden
- return Database_Type'First; -- To quiet the compiler
- end Engine_Of;
-
- function Command_Oid(Query : Root_Query_Type) return Row_ID_Type is
- begin
- raise Is_Abstract;
- return Row_ID_Type'First;
- end Command_Oid;
-
- function Null_Oid(Query : Root_Query_Type) return Row_ID_Type is
- begin
- raise Is_Abstract;
- return Row_ID_Type'First;
- end Null_Oid;
-
- function Error_Message(Query : Root_Query_Type) return String is
- begin
- raise Is_Abstract;
- return "";
- end Error_Message;
-
- function Is_Duplicate_Key(Query : Root_Query_Type) return Boolean is
- begin
- raise Is_Abstract;
- return False;
- end Is_Duplicate_Key;
-
- procedure Execute(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is
- begin
- raise Is_Abstract;
- end Execute;
-
- procedure Execute_Checked(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class; Msg : String := "") is
- begin
- raise Is_Abstract;
- end Execute_Checked;
-
- procedure Begin_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is
- begin
- raise Is_Abstract;
- end Begin_Work;
-
- procedure Commit_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is
- begin
- raise Is_Abstract;
- end Commit_Work;
-
- procedure Rollback_Work(Query : in out Root_Query_Type; Connection : in out Root_Connection_Type'Class) is
- begin
- raise Is_Abstract;
- end Rollback_Work;
-
function Time_Component(TM : Ada.Calendar.Day_Duration; Unit : Time_Unit) return Natural is
begin
case Unit is
@@ -1178,12 +1040,6 @@
end if;
end Encode_Bitstring;
- function Is_Null(Q : Root_Query_Type; CX : Column_Index_Type) return Boolean is
- begin
- raise Is_Abstract; -- Must be overriden
- return False;
- end Is_Null;
-
function Column_Is_Null(Q : Root_Query_Type'Class; CX : Column_Index_Type) return Ind_Type is
begin
return Ind_Type(Is_Null(Root_Query_Type'Class(Q),CX));
@@ -1373,7 +1229,6 @@
procedure Date_Fetch(Query : Root_Query_Type'Class; CX : Column_Index_Type; V : out Val_Type; Indicator : out Ind_Type) is
function Value is new Date_Value(Val_Type);
- D : APQ_Date;
begin
Indicator := Ind_Type( Is_Null(Root_Query_Type'Class(Query),CX) );
if not Indicator then
[-- Attachment #3: Type: text/plain, Size: 40 bytes --]
--
Brian May <bam@snoopy.apana.org.au>
next prev parent reply other threads:[~2004-12-17 22:55 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-15 23:31 APQ Brian May
2004-12-16 11:34 ` APQ Warren W. Gay VE3WWG
2004-12-16 23:58 ` APQ Randy Brukardt
2004-12-17 3:45 ` APQ Brian May
2004-12-17 4:03 ` APQ Warren W. Gay VE3WWG
2004-12-17 4:38 ` APQ Brian May
2004-12-17 9:06 ` APQ Egil H. H�vik
2004-12-17 11:42 ` APQ Brian May
2004-12-17 22:55 ` Brian May [this message]
2004-12-18 15:52 ` APQ Warren W. Gay VE3WWG
2004-12-18 18:23 ` APQ Dmitry A. Kazakov
2004-12-21 23:34 ` APQ Brian May
2004-12-22 8:57 ` APQ Dmitry A. Kazakov
2004-12-22 10:07 ` APQ Martin Krischik
2004-12-22 13:15 ` APQ Dmitry A. Kazakov
2004-12-22 16:53 ` APQ Martin Krischik
2004-12-22 17:21 ` APQ Dmitry A. Kazakov
2004-12-22 18:23 ` APQ Martin Krischik
2004-12-17 8:59 ` APQ Stephen Leake
2004-12-17 14:12 ` APQ Dmitry A. Kazakov
2004-12-17 23:20 ` APQ Brian May
2004-12-18 16:13 ` APQ Dmitry A. Kazakov
2004-12-21 23:29 ` APQ Brian May
2004-12-22 9:14 ` APQ Dmitry A. Kazakov
2005-01-04 21:32 ` APQ Brian May
2005-01-05 11:58 ` APQ Dmitry A. Kazakov
2004-12-23 17:04 ` APQ (Connection Cloning) Warren W. Gay VE3WWG
2004-12-23 17:55 ` Georg Bauhaus
2004-12-23 18:52 ` Warren W. Gay VE3WWG
2005-01-03 7:40 ` Frank Piron
2004-12-17 13:54 ` APQ Dmitry A. Kazakov
-- strict thread matches above, loose matches on Subject: below --
2004-12-16 4:37 APQ Christoph Karl Walter Grein
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox