r8811: add support for usql backend, integrate Marcus Pearce <ek735@soi.city.ac.uk...
[clsql.git] / base / initialize.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          initialize.cl
6 ;;;; Purpose:       Initializion routines for backend
7 ;;;; Programmers:   Kevin M. Rosenberg 
8 ;;;; Date Started:  May 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
13 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
14 ;;;;
15 ;;;; CLSQL users are granted the rights to distribute and use this software
16 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
17 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
18 ;;;; *************************************************************************
19
20 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
21 (in-package :clsql-base-sys)
22
23 (defvar *loaded-database-types* nil
24   "Contains a list of database types which have been defined/loaded.")
25
26 (defmethod database-type-load-foreign (x)
27   (error "No generic function defined for database-type-load-foreign with parameters of ~S" x))
28
29 (defmethod database-type-load-foreign :after (database-type)
30   (when (database-type-library-loaded database-type)
31      (pushnew database-type *loaded-database-types*)))
32
33 (defun reload-database-types ()
34   "Reloads any foreign code for the loaded database types after a dump."
35   (mapc #'database-type-load-foreign *loaded-database-types*))
36
37 (defvar *default-database-type* nil
38   "Specifies the default type of database.")
39
40 (defvar *initialized-database-types* nil
41   "Contains a list of database types which have been initialized by calls
42 to initialize-database-type.")
43
44 (defun initialize-database-type (&key (database-type *default-database-type*))
45   "Initialize the given database-type, if it is not already
46 initialized, as indicated by `*initialized-database-types*'."
47   (if (member database-type *initialized-database-types*)
48       database-type
49       (when (database-initialize-database-type database-type)
50         (push database-type *initialized-database-types*)
51         database-type)))
52
53