]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaInit.ml
all initialization code is now in the new matitaInit.ml module.
[helm.git] / helm / matita / matitaInit.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 type thingsToInitilaize = 
27   ConfigurationFile | Db | Environment | Getter | Notation | 
28   Paramodulation | Makelib
29   
30 exception FailedToInitialize of thingsToInitilaize
31
32 let wants s l = 
33   List.iter (
34     fun item -> 
35       if not (List.exists (fun x -> x = item) l) then
36         raise (FailedToInitialize item)) 
37   s
38
39 let already_configured s l =
40   List.for_all (fun item -> List.exists (fun x -> x = item) l) s
41   
42 let load_configuration init_status =
43   if not (already_configured [ConfigurationFile] init_status) then
44     begin
45       Helm_registry.load_from BuildTimeConf.matita_conf;
46       ConfigurationFile::init_status 
47     end
48   else
49     init_status
50
51 let initialize_db init_status = 
52   wants [ConfigurationFile] init_status;
53   if not (already_configured [Db] init_status) then
54     begin
55       MetadataTypes.ownerize_tables (Helm_registry.get "matita.owner");
56       MatitaDb.create_owner_environment ();
57       Db::init_status
58     end
59   else
60     init_status
61
62 let initialize_paramodulation init_status = 
63   wants [] init_status;
64   if not (already_configured [Paramodulation] init_status) then
65     begin
66       Paramodulation.Saturation.init ();
67       Paramodulation::init_status
68     end
69   else
70     init_status
71
72 let initialize_makelib init_status = 
73   wants [ConfigurationFile] init_status;
74   if not (already_configured [Makelib] init_status) then
75     begin
76       MatitamakeLib.initialize (); 
77       Makelib::init_status
78     end
79   else
80     init_status
81
82 let initialize_notation init_status = 
83   wants [ConfigurationFile] init_status;
84   if not (already_configured [Notation] init_status) then
85     begin
86       CicNotation.load_notation BuildTimeConf.core_notation_script;
87       Notation::init_status
88     end
89   else
90     init_status
91
92 let initialize_environment init_status = 
93   wants [ConfigurationFile] init_status;
94   if not (already_configured [Getter;Environment] init_status) then
95     begin
96       Http_getter.init ();
97       CicEnvironment.set_trust (* environment trust *)
98         (let trust = Helm_registry.get_bool "matita.environment_trust" in
99          fun _ -> trust);
100       Getter::Environment::init_status
101     end
102   else
103     init_status 
104   
105 let status = ref []
106     
107 let initialize_all () =
108   status := 
109     initialize_notation 
110       (initialize_environment 
111         (initialize_db 
112           (initialize_paramodulation 
113             (initialize_makelib
114               (load_configuration !status)))))
115
116 let load_config_only () =
117   status := load_configuration !status
118
119 let initialize_notation () =
120   status := initialize_notation (load_configuration !status)
121