98980d4ccf750794afa7332843a55657c2979ebc
[clsql.git] / sql / base-classes.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          classes.lisp
6 ;;;; Purpose:       Classes for High-level SQL interface
7 ;;;; Programmers:   Kevin M. Rosenberg based on
8 ;;;;                 original code by Pierre R. Mai 
9 ;;;; Date Started:  Feb 2002
10 ;;;;
11 ;;;; $Id$
12 ;;;;
13 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
14 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
15 ;;;;
16 ;;;; CLSQL users are granted the rights to distribute and use this software
17 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
18 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
19 ;;;; *************************************************************************
20
21 (in-package #:clsql-sys)
22
23
24 (defclass database ()
25   ((name :initform nil :initarg :name :reader database-name)
26    (connection-spec :initform nil :initarg :connection-spec
27                     :reader connection-spec
28                     :documentation "Require to use connection pool")
29    (database-type :initarg :database-type :initform :unknown
30                   :reader database-type)
31    (state :initform :closed :reader database-state)
32    (command-recording-stream :accessor command-recording-stream :initform nil)
33    (result-recording-stream :accessor result-recording-stream :initform nil)
34    (record-caches :accessor record-caches :initform nil)
35    (view-classes :accessor database-view-classes :initform nil)
36    (schema :accessor database-schema :initform nil)
37    (transaction-level :initform 0 :accessor transaction-level)
38    (transaction :initform nil :accessor transaction)
39    (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool)
40    (attribute-cache :initform (make-hash-table :size 100 :test 'equal) 
41                     :accessor attribute-cache
42                     :documentation "Internal cache of table attributes. It is keyed by table-name. Values
43 are a list of ACTION specified for table and any cached value of list-attributes-types."))
44   (:documentation
45    "This class is the supertype of all databases handled by CLSQL."))
46
47 (defmethod print-object ((object database) stream)
48   (print-unreadable-object (object stream :type t :identity t)
49     (format stream "~A ~A"
50             (if (slot-boundp object 'name)
51                 (database-name object)
52               "<unbound>")
53             (database-state object))))
54
55