2 * @author Alan Krempler
3 * Created on Sep 19, 2003
5 package isac.interfaces;
7 import java.rmi.Remote;
8 import java.rmi.RemoteException;
10 import isac.util.formulae.*;
11 import isac.util.tactics.*;
14 * Interface to be used to communicate in the direction towards the Math Engine.
16 * @author Alan Krempler WN040924 rename to ICalcTree ?
19 public interface IToCalc extends Remote {
21 /** remove the CalcTree in the math-engine
23 public boolean destruct() throws RemoteException;
26 * Get a new iterator referencing the root element of the calculation tree.
28 * The functionality for navigating the calculation is implemented in the
29 * CalcIterator object.
31 * @return new instance of CalcIterator
33 public ICalcIterator iterator() throws RemoteException;
36 * Register a new listener who wants to be notified of changes in the data.
37 * The listener has to implement the IToUser interface.
40 * New listener to be registered.
41 * @return false on success, true otherwise.
43 public boolean addDataChangeListener(IToUser listener)
44 throws RemoteException;
47 * @return an iterator referencing the current "hot spot" in the
48 * calculation, i.e. the active formula.
50 public ICalcIterator getActiveFormula() throws RemoteException;
53 * Makes the passed formula the active formula, i.e. the formula the next
54 * tactic is applied to.
56 * @param newActiveFormula
57 * Iterator referencing the new desired position
59 public void moveActiveFormula(ICalcIterator newActiveFormula)
60 throws RemoteException;
63 * Set the Descriptions for all ModelItems given by the problem which is
64 * specified in the CalcHead held in the MathEngine (this may still be
65 * hidden from the front-end).
67 * in contrary to isac.interfaces.IToCalc#setNextTactic this method has a
68 * returnvalue from the calculation.
70 * @return CalcHead with Descriptions (e.g. equality, solveFor)
71 * @exception RemoteException
73 public CalcHead modelProblem() throws RemoteException;
76 * Add _ONE_ item to the Model or to the Specification, as long as the
77 * CalcHead is not complete.
79 * in contrary to the methods for the solve-phase this method returns a
80 * value from the calculation.
82 * @return CalcHead with one item added; if the CalcHead was complete, the
83 * CalcHead remains unchanged
84 * @exception RemoteException
86 public CalcHead nextSpecify() throws RemoteException;
89 * Check a given CalcHead. The result is the same CalcHead with status flags
92 * in contrary to the methods for the solve-phase this method returns a
93 * value from the calculation.
95 * @see CalcHead for possible status flags
97 * CalcHead to be checked
98 * @return new CalcHead with a status for each item
100 public CalcHead checkCalcHead(CalcHead calc_head) throws RemoteException;
103 * Complete the Model of a CalcHead: Tell the Kernel to fill out all the
104 * missing fields in the Model; this may not succeed if the (manual) input
105 * is too messed up (in this case first a resetCalcHead must be done).
107 * in contrary to the methods for the solve-phase this method returns a
108 * value from the calculation.
110 * @return the CalcHead with the completed Model
112 public CalcHead completeModel() throws RemoteException;
115 * Transfer the Theory selected in the TheoryBrowser to the SML-kernel. This
116 * method is used for transferring the Theory to the Worksheet (i.e. the
117 * CalcHead with the Theory inserted and checked has to be fetched from the
118 * SML-kernel by the front-end)
120 * in contrary to the methods for the solve-phase this method returns a
121 * value from the calculation.
124 * the identifier of the theory
125 * @return CalcHead with the Theory inserted; the new Theory may cause parse
126 * errors (because parts of a formula are unknown in this Theory)
127 * displayed in the Model (or in the guard)
128 * @exception RemoteException
130 public CalcHead setTheory(String thy_id) throws RemoteException;
133 * Transfer the Problem selected in the ProblemBrowser to the SML-kernel.
134 * This method is used for transferring the Problem to the Worksheet (i.e.
135 * the CalcHead with the Problem inserted and checked has to be fetched from
136 * the SML-kernel by the front-end)
138 * in contrary to the methods for the solve-phase this method returns a
139 * value from the calculation.
141 * @return CalcHead with the Problem inserted; the new Problem may cause
142 * error-status for some ModelItems already input (because they do
143 * not match the Problem selected)
144 * @exception RemoteException
146 public CalcHead setProblem(ProblemID id) throws RemoteException;
149 * Transfer the Method selected in the MethodBrowser to the SML-kernel. This
150 * method is used for transferring the Method to the Worksheet (i.e. the
151 * CalcHead with the Method inserted and checked has to be fetched from the
152 * SML-kernel by the front-end)
154 * in contrary to the methods for the solve-phase this method returns a
155 * value from the calculation.
157 * @return CalcHead with the Method inserted; the new Method may cause
158 * error-status for some ModelItems in the guard (because they do
159 * not match the Method selected)
160 * @exception RemoteException
162 public CalcHead setMethod(MethodID id) throws RemoteException;
165 * Complete a given CalcHead: Tell the Kernel to fill out all the missing
166 * fields in the Model _and_ in the Specification; this may not succeed if
167 * the (manual) input is too messed up (in this case first a resetCalcHead
170 * in contrary to the methods for the solve-phase this method returns a
171 * value from the calculation.
173 * @return the completed CalHead
175 public CalcHead completeCalcHead() throws RemoteException;
178 * Reset the CalcHead to the state as it was after startCalculation. This
179 * may help to escape from a CalcHead with messed input, which may not allow
180 * for a successful completeCalcHead.
182 * in contrary to the methods for the solve-phase this method returns a
183 * value from the calculation.
185 * @return an empty CalcHead
186 * @exception RemoteException
188 public CalcHead resetCalcHead() throws RemoteException;
191 * Complete a given calc_head_: Tell the Kernel to fill out a missing field
192 * in the calc_head_, which is specified by an parameter
194 * in contrary to the methods for the solve-phase this method returns a
195 * value from the calculation.
198 * the calc_head_ to be completed
199 * @param completeItem
200 * the item which should be added TODO: return int like
201 * replaceFormula etc. WN040916 don't confuse with
202 * autCalculate(...CompleteCalcHead) WN0504 this case is notyet
203 * designed: how indicate the field ???
204 * @return the completed CalHead
206 public CalcHead completeCalcHead(CalcHead calcHead, int completeItem)
207 throws RemoteException;
210 * Tries to replaces the active formula in the calculation tree by the
211 * passed formula. This could fail if no valid derivation from the preceding
212 * formula to the (new) active formula can be found.
214 * Parts of the calculation after the replaced formula are likely to become
215 * invalid, listeners will be informed of this with the update message,
216 * which contains the last unchanged formula.
219 * @return The method will return 0 on success or a nonzero value indicating
220 * the status otherwise.
222 public int replaceFormula(CalcFormula newFormula) throws RemoteException;
225 * Tries to append the passed formula after the active formula. This could
226 * fail if no valid derivation from the preceding formula to the (new)
227 * active formula can be found. The method will fail as well if the active
228 * formula is not the last formula in the (sub)calculation. Parts of the
229 * calculation might become invalid.
232 * @return The method will return 0 on success or a nonzero value indicating
233 * the status otherwise.
235 public int appendFormula(CalcFormula newFormula) throws RemoteException;
238 * requests the intermediate steps leading to the Formula at the Iterator
239 * (i.e. these steps might be calculated by the math-engine)
243 * @return transactionID also returned in the CalcChanged
245 public int intermediateSteps(ICalcIterator ic) throws RemoteException;
248 * Set the tactic to be used in the next step of calculation.
251 * the Tactic to be used in the the next step
252 * @return The return value indicates success, failure or probable success
255 public int setNextTactic(Tactic tactic) throws RemoteException;
258 * Retrieve the tactic proposed by the SML-Kernel for the next step in the
261 * @return proposed tactic. Can be null, if the kernel does not know what to
262 * do next, or if the end of the calculation is reached
264 public Tactic fetchProposedTactic() throws RemoteException;
267 * Fetch all tactics applicable to the current situation known to the
270 * @see #fetchApplicableTactics(int)
272 public static final int TACTICS_ALL = 1;
275 * Fetch all tactics applicable to the current situation, but restrict the
276 * result to tactics from the current theory.
278 * @see #fetchApplicableTactics(int)
280 public static final int TACTICS_CURRENT_THEORY = 2;
283 * Fetch all tactics applicable to the current situation, but restrict the
284 * result to tactics from the method being applied.
286 * @see #fetchApplicableTactics(int)
288 public static final int TACTICS_CURRENT_METHOD = 3;
291 // * Get a list of tactics applicable to the active formula.
294 // * The filter parameter selects the scope of search for
295 // * applicable tactics.
296 // * @return Array with applicable tactics
297 // * @see #TACTICS_ALL
298 // * @see #TACTICS_CURRENT_THEORY
299 // * @see #TACTICS_CURRENT_METHOD
301 // public Tactic[] fetchApplicableTactics(int scope) throws RemoteException;
304 * Do the number of steps requested, without any restrictions. autoCalculate
305 * ... CompleteCalc Do NOT change the value of this constant, as this number
306 * has a specifig meaning in other parts of the system!
308 * @see #autoCalculate(int, int)
310 public static final int SCOPE_CALCULATION = 7;
313 * Do the number of steps requested, without any restrictions. autoCalculate
314 * ... CompleteModel Do NOT change the value of this constant, as this
315 * number has a specifig meaning in other parts of the system!
317 * @see #autoCalculate(int, int)
319 public static final int SCOPE_MODEL = 6;
322 * Do the number of steps requested, but do not leave the current
323 * subcalculation into a subproblem: CompleteToSubpbl Do NOT change the
324 * value of this constant, as this number has a specifig meaning in other
325 * parts of the system!
327 * @see #autoCalculate(int, int)
329 public static final int SCOPE_SUBCALCULATION = 5;
332 * Do the number of steps requested, but do not leave the current
333 * subproblem: autoCalculate ... CompleteSubpbl Do NOT change the value of
334 * this constant, as this number has a specifig meaning in other parts of
337 * @see #autoCalculate(int, int)
339 public static final int SCOPE_SUBPROBLEM = 4;
342 * Calculate the next n steps starting from the active formula or until the
343 * specified scope is left, whichever comes first.
346 * The scope parameter can have following values:
348 * Specifies the count of steps to be autocalculated. Passing 0
349 * for nSteps will calculate until reaching a final result.
350 * @return The method returns an unique id to identify the request when
351 * notifying about updates in the tree.
352 * @see #SCOPE_CALCULATION
353 * @see #SCOPE_SUBCALCULATION
354 * @see #SCOPE_SUBPROBLEM
357 * WN040624: the above design is desirable, but currently not impl. in the
358 * math-engine, rather: either steps == 0, then regard SCOPE_* or steps !=
359 * 0, then SCOPE_* irrelevant !
361 public int autoCalculate(int scope, int nSteps) throws RemoteException;