r7061: initial property settings
[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.  Currently only :mysql is
39 supported.")
40
41 (defvar *initialized-database-types* nil
42   "Contains a list of database types which have been initialized by calls
43 to initialize-database-type.")
44
45 (defun initialize-database-type (&key (database-type *default-database-type*))
46   "Initialize the given database-type, if it is not already
47 initialized, as indicated by `*initialized-database-types*'."
48   (if (member database-type *initialized-database-types*)
49       t
50       (when (database-initialize-database-type database-type)
51         (push database-type *initialized-database-types*)
52         t)))
53
54