r9199: fold clsql-base and clsql-base-sys into clsql-base
[clsql.git] / base / classes.lisp
index 104c7b6680a5af4fa11f6fb1af0b147c87a62fdf..292bb6ba22b9804934877620acf2a4c72e363778 100644 (file)
@@ -2,7 +2,7 @@
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
-;;;; Name:          classes.cl
+;;;; Name:          classes.lisp
 ;;;; Purpose:       Classes for High-level SQL interface
 ;;;; Programmers:   Kevin M. Rosenberg based on
 ;;;;                 original code by Pierre R. Mai 
@@ -10,7 +10,7 @@
 ;;;;
 ;;;; $Id$
 ;;;;
-;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
 ;;;;
 ;;;; CLSQL users are granted the rights to distribute and use this software
 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; *************************************************************************
 
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-base-sys)
+(in-package #:clsql-base)
 
 
 (defclass database ()
   ((name :initform nil :initarg :name :reader database-name)
-   (connection-spec :initform nil :initarg :connection-spec :reader connection-spec
+   (connection-spec :initform nil :initarg :connection-spec
+                    :reader connection-spec
                    :documentation "Require to use connection pool")
+   (database-type :initarg :database-type :initform :unknown
+                 :reader database-type)
+   (state :initform :closed :reader database-state)
+   (command-recording-stream :accessor command-recording-stream :initform nil)
+   (result-recording-stream :accessor result-recording-stream :initform nil)
+   (query-recording-stream :accessor query-recording-stream :initform nil)
+   (view-classes :accessor database-view-classes :initform nil)
+   (schema :accessor database-schema :initform nil)
    (transaction-level :initform 0 :accessor transaction-level)
    (transaction :initform nil :accessor transaction)
-   (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool))
+   (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool)
+   (attribute-cache :initform (make-hash-table :size 100 :test 'equal) 
+                   :accessor attribute-cache
+                   :documentation "Internal cache of table attributes. It is keyed by table-name. Values
+are a list of ACTION specified for table and any cached value of list-attributes-types."))
   (:documentation
    "This class is the supertype of all databases handled by CLSQL."))
 
 (defmethod print-object ((object database) stream)
   (print-unreadable-object (object stream :type t :identity t)
-    (write-string (if (slot-boundp object 'name)
-                     (database-name object)
-                     "<unbound>")
-                 stream)))
-
-;; Closed database idea and original code comes from UncommonSQL
-
-(defclass closed-database ()
-  ((name :initarg :name :reader database-name))
-  (:documentation
-   "This class represents databases after they are closed via 'disconnect'."))
-
-(defmethod print-object ((object closed-database) stream)
-  (print-unreadable-object (object stream :type t :identity t)
-    (write-string (if (slot-boundp object 'name)
-                     (database-name object)
-                     "<unbound>")
-                 stream)))
+    (format stream "~A ~A"
+           (if (slot-boundp object 'name)
+               (database-name object)
+             "<unbound>")
+           (database-state object))))