r8821: integrate usql support
[clsql.git] / 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-base-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    (command-recording-stream :accessor command-recording-stream :initform nil)
30    (result-recording-stream :accessor result-recording-stream :initform nil)
31    (view-classes :accessor database-view-classes :initform nil)
32    (schema :accessor database-schema :initform nil)
33    (transaction-level :initform 0 :accessor transaction-level)
34    (transaction :initform nil :accessor transaction)
35    (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool))
36   (:documentation
37    "This class is the supertype of all databases handled by CLSQL."))
38
39 (defmethod print-object ((object database) stream)
40   (print-unreadable-object (object stream :type t :identity t)
41     (write-string (if (slot-boundp object 'name)
42                       (database-name object)
43                       "<unbound>")
44                   stream)))
45
46 ;; Closed database idea and original code comes from UncommonSQL
47
48 (defclass closed-database ()
49   ((name :initarg :name :reader database-name))
50   (:documentation
51    "This class represents databases after they are closed via 'disconnect'."))
52
53 (defmethod print-object ((object closed-database) stream)
54   (print-unreadable-object (object stream :type t :identity t)
55     (write-string (if (slot-boundp object 'name)
56                       (database-name object)
57                       "<unbound>")
58                   stream)))
59