r8811: add support for usql backend, integrate Marcus Pearce <ek735@soi.city.ac.uk...
[clsql.git] / base / classes.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          classes.cl
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 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 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
22 (in-package :clsql-base-sys)
23
24
25 (defclass database ()
26   ((name :initform nil :initarg :name :reader database-name)
27    (connection-spec :initform nil :initarg :connection-spec
28                     :reader connection-spec
29                     :documentation "Require to use connection pool")
30    (command-recording-stream :accessor command-recording-stream :initform nil)
31    (result-recording-stream :accessor result-recording-stream :initform nil)
32    (view-classes :accessor database-view-classes :initform nil)
33    (schema :accessor database-schema :initform nil)
34    (transaction-level :initform 0 :accessor transaction-level)
35    (transaction :initform nil :accessor transaction)
36    (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool))
37   (:documentation
38    "This class is the supertype of all databases handled by CLSQL."))
39
40 (defmethod print-object ((object database) stream)
41   (print-unreadable-object (object stream :type t :identity t)
42     (write-string (if (slot-boundp object 'name)
43                       (database-name object)
44                       "<unbound>")
45                   stream)))
46
47 ;; Closed database idea and original code comes from UncommonSQL
48
49 (defclass closed-database ()
50   ((name :initarg :name :reader database-name))
51   (:documentation
52    "This class represents databases after they are closed via 'disconnect'."))
53
54 (defmethod print-object ((object closed-database) stream)
55   (print-unreadable-object (object stream :type t :identity t)
56     (write-string (if (slot-boundp object 'name)
57                       (database-name object)
58                       "<unbound>")
59                   stream)))
60