1 /* This file is part of the project "Hilbert II" - http://www.qedeq.org" target="alexandria_uri">http://www.qedeq.org 2 * 3 * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. 4 * 5 * "Hilbert II" is free software; you can redistribute 6 * it and/or modify it under the terms of the GNU General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 */ 15 16 package org.qedeq.kernel.bo.module; 17 18 import java.io.File; 19 import java.io.IOException; 20 21 import org.qedeq.kernel.bo.common.KernelProperties; 22 import org.qedeq.kernel.se.base.module.Specification; 23 import org.qedeq.kernel.se.common.ModuleAddress; 24 import org.qedeq.kernel.se.common.SourceFileExceptionList; 25 import org.qedeq.kernel.se.config.QedeqConfig; 26 import org.qedeq.kernel.se.visitor.ContextChecker; 27 import org.qedeq.kernel.se.visitor.InterruptException; 28 29 /** 30 * The kernel internal service methods are assembled here. Needed by the kernel and its helpers. 31 * 32 * @author Michael Meyling 33 */ 34 public interface InternalKernelServices extends KernelProperties { 35 36 /** 37 * Get access to configuration parameters. 38 * 39 * @return Configuration access. 40 */ 41 public QedeqConfig getConfig(); 42 43 /** 44 * Get buffer directory for QEDEQ module files. 45 * 46 * @return buffer directory. 47 */ 48 public File getBufferDirectory(); 49 50 /** 51 * Get directory for generated files. 52 * 53 * @return Generation directory. 54 */ 55 public File getGenerationDirectory(); 56 57 /** 58 * Get {@link KernelQedeqBo} for an address. 59 * 60 * @param address Look for this address. 61 * @return Existing or new {@link KernelQedeqBo}. Never <code>null</code>. 62 */ 63 public KernelQedeqBo getKernelQedeqBo(ModuleAddress address); 64 65 /** 66 * Transform an URL address into a local file path where the QEDEQ module is buffered. 67 * If the QEDEQ module is a local file the path to that file is given. 68 * 69 * @param address Get local address for this QEDEQ module address. 70 * @return Local file path for that <code>address</code>. 71 */ 72 public File getLocalFilePath(ModuleAddress address); 73 74 /** 75 * Load QEDEQ module. 76 * 77 * @param process Working process. 78 * @param address Load module from this address. 79 * @return BO for QEDEQ module. Loading still might have failed. Check status. 80 * @throws InterruptException User canceled request. 81 */ 82 public KernelQedeqBo loadKernelModule(final InternalServiceJob process, final ModuleAddress address) 83 throws InterruptException; 84 85 /** 86 * Load specified QEDEQ module from QEDEQ parent module. 87 * 88 * @param process Working process. 89 * @param parent Parent module address. 90 * @param spec Specification for another QEDEQ module. 91 * @return Loaded module. 92 * @throws SourceFileExceptionList Loading failed. 93 * @throws InterruptException User canceled request. 94 */ 95 public KernelQedeqBo loadKernelModule(InternalServiceJob process, ModuleAddress parent, 96 Specification spec) throws SourceFileExceptionList, InterruptException; 97 98 /** 99 * Get required modules of given module. You can check the status to know if the loading was 100 * successful. 101 * 102 * @param process Working process. 103 * @param qedeq Module to check. 104 * @return Successful loading. 105 * @throws InterruptException User canceled request. 106 */ 107 public boolean loadRequiredModules(InternalServiceJob process, KernelQedeqBo qedeq) throws InterruptException; 108 109 /** 110 * Check if all formulas of a QEDEQ module and its required modules are well formed. 111 * 112 * @param process Working process. 113 * @param qedeq Module to check. 114 * @return Was check successful? 115 * @throws InterruptException User canceled request. 116 */ 117 public boolean checkWellFormedness(InternalServiceJob process, KernelQedeqBo qedeq) throws InterruptException; 118 119 /** 120 * Check if all propositions of this and all required modules have correct formal proofs. 121 * 122 * @param process Working process. 123 * @param qedeq Module to check. 124 * @return Was check successful? 125 * @throws InterruptException Process execution was canceled by user. 126 */ 127 public boolean checkFormallyProved(InternalServiceJob process, KernelQedeqBo qedeq) throws InterruptException; 128 129 /** 130 * Execute plugin on given QEDEQ module. 131 * 132 * @param parent Parent service process. Must not be <code>null</code> 133 * @param id Plugin id. 134 * @param qedeq QEDEQ module. 135 * @param data Process data. Additional data beside module. 136 * @return Plugin specific resulting object. Might be <code>null</code>. 137 * @throws InterruptException Process execution was canceled by user. 138 * @throws NullPointerException <code>parent</code> was null. 139 */ 140 public Object executePlugin(final InternalServiceJob parent, final String id, final KernelQedeqBo qedeq, 141 final Object data) throws InterruptException; 142 143 /** 144 * Get DAO for reading and writing QEDEQ modules from or to a file. 145 * 146 * @return DAO. 147 */ 148 public QedeqFileDao getQedeqFileDao(); 149 150 /** 151 * Creates a list with a {@link org.qedeq.kernel.se.common.SourceFileException} with dummy 152 * position. 153 * 154 * @param address This source had a problem. 155 * @param code Failure code. 156 * @param message Textual description of failure. 157 * @param e Wrapped exception. 158 * @return Created list. 159 */ 160 public SourceFileExceptionList createSourceFileExceptionList(int code, String message, 161 String address, IOException e); 162 163 /** 164 * Creates a list with a {@link org.qedeq.kernel.se.common.SourceFileException} with dummy 165 * position. 166 * 167 * @param address This source had a problem. 168 * @param code Failure code. 169 * @param message Textual description of failure. 170 * @param e Wrapped exception. 171 * @return Created list. 172 */ 173 public SourceFileExceptionList createSourceFileExceptionList(int code, String message, 174 String address, RuntimeException e); 175 176 /** 177 * Creates a list with a {@link org.qedeq.kernel.se.common.SourceFileException} with dummy 178 * position. 179 * 180 * @param address This source had a problem. 181 * @param code Failure code. 182 * @param message Textual description of failure. 183 * @param e Wrapped exception. 184 * @return Created list. 185 */ 186 public SourceFileExceptionList createSourceFileExceptionList(int code, String message, 187 String address, Exception e); 188 189 /** 190 * Get context checker. 191 * 192 * @return Checker for testing if context is valid. 193 */ 194 public ContextChecker getContextChecker(); 195 196 }