1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: initialize.lisp
6 ;;;; Purpose: Initializion routines for backend
7 ;;;; Programmers: Kevin M. Rosenberg
8 ;;;; Date Started: May 2002
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
13 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
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 ;;;; *************************************************************************
20 (in-package #:clsql-sys)
22 (defvar *loaded-database-types* nil
23 "Contains a list of database types which have been defined/loaded.")
25 (defmethod database-type-load-foreign (x)
26 (error "No generic function defined for database-type-load-foreign with parameters of ~S" x))
28 (defmethod database-type-load-foreign :after (database-type)
29 (when (database-type-library-loaded database-type)
30 (pushnew database-type *loaded-database-types*)))
32 (defun reload-database-types ()
33 "Reloads any foreign code for the loaded database types after a dump."
34 (mapc #'database-type-load-foreign *loaded-database-types*))
36 (defvar *default-database-type* nil
37 "Specifies the default type of database.")
39 (defvar *initialized-database-types* nil
40 "Contains a list of database types which have been initialized by calls
41 to initialize-database-type.")
43 (defun initialize-database-type (&key (database-type *default-database-type*))
44 "Initialize the given database-type, if it is not already
45 initialized, as indicated by `*initialized-database-types*'."
46 (when (member database-type *initialized-database-types*)
47 (return-from initialize-database-type database-type))
49 (let ((system (intern (concatenate 'string
50 (symbol-name '#:clsql-)
51 (symbol-name database-type)))))
52 (when (not (find-package system))
53 (asdf:operate 'asdf:load-op system)))
55 (when (database-initialize-database-type database-type)
56 (push database-type *initialized-database-types*)