7bb8d1bdff9cade2310ca82b3ea30d8f11e4c2f9
[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: initialize.lisp,v 1.1 2002/09/30 10:19:01 kevin Exp $
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 :after (database-type)
27   (when (database-type-library-loaded database-type)
28      (pushnew database-type *loaded-database-types*)))
29
30 (defun reload-database-types ()
31   "Reloads any foreign code for the loaded database types after a dump."
32   (mapc #'database-type-load-foreign *loaded-database-types*))
33
34 (defvar *default-database-type* nil
35   "Specifies the default type of database.  Currently only :mysql is
36 supported.")
37
38 (defvar *initialized-database-types* nil
39   "Contains a list of database types which have been initialized by calls
40 to initialize-database-type.")
41
42 (defun initialize-database-type (&key (database-type *default-database-type*))
43   "Initialize the given database-type, if it is not already
44 initialized, as indicated by `*initialized-database-types*'."
45   (if (member database-type *initialized-database-types*)
46       t
47       (when (database-initialize-database-type database-type)
48         (push database-type *initialized-database-types*)
49         t)))
50
51