Remove CVS $Id$ keyword
[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 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2010 by Kevin M. Rosenberg
12 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
13 ;;;;
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
18
19 (in-package #:clsql-sys)
20
21
22 (defclass database ()
23   ((name :initform nil :initarg :name :reader database-name)
24    (connection-spec :initform nil :initarg :connection-spec
25                     :reader connection-spec
26                     :documentation "Require to use connection pool")
27    (database-type :initarg :database-type :initform :unknown
28                   :reader database-type)
29    (state :initform :closed :reader database-state)
30    (autocommit :initform t :accessor database-autocommit)
31    (command-recording-stream :accessor command-recording-stream :initform nil)
32    (result-recording-stream :accessor result-recording-stream :initform nil)
33    (record-caches :accessor record-caches :initform nil)
34    (view-classes :accessor database-view-classes :initform nil)
35    (transaction-level :initform 0 :accessor transaction-level)
36    (transaction :initform nil :accessor transaction)
37    (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool)
38    (attribute-cache :initform (make-hash-table :size 100 :test 'equal)
39                     :accessor attribute-cache
40                     :documentation "Internal cache of table attributes. It is keyed by table-name. Values
41 are a list of ACTION specified for table and any cached value of list-attributes-types."))
42   (:documentation
43    "This class is the supertype of all databases handled by CLSQL."))
44
45 (defmethod print-object ((object database) stream)
46   (print-unreadable-object (object stream :type t :identity t)
47     (format stream "~A ~A"
48             (if (slot-boundp object 'name)
49                 (database-name object)
50               "<unbound>")
51             (database-state object)))
52   object)
53
54 (setf (documentation 'database-name 'function)
55       "Returns the name of a database.")