2 * Created on Sep 19, 2003
4 package isac.util.interfaces;
6 import java.rmi.Remote;
7 import java.rmi.RemoteException;
8 import java.util.Vector;
10 import isac.bridge.CalcTree;
11 import isac.util.Formalization;
12 import isac.util.NotInSpecificationPhaseException;
13 import isac.util.formulae.*;
14 import isac.util.tactics.*;
17 * Interface to be used to communicate in the direction towards the Math Engine.
19 * @author Alan Krempler WN040924 rename to ICalcTree ?
22 public interface IToCalc extends Remote {
25 * Get a new iterator referencing the root element of the calculation tree.
27 * The functionality for navigating the calculation is implemented in the
28 * CalcIterator object.
30 * @return new instance of CalcIterator
32 public ICalcIterator iterator() throws RemoteException;
35 * Register a new listener who wants to be notified of changes in the data.
36 * The listener has to implement the IToUser interface.
39 * New listener to be registered.
40 * @return false on success, true otherwise.
42 public boolean addDataChangeListener(IToUser listener)
43 throws RemoteException;
46 * @return an iterator referencing the current "hot spot" in the
47 * calculation, i.e. the active formula.
49 public ICalcIterator getActiveFormula() throws RemoteException;
52 * Makes the passed formula the active formula, i.e. the formula the next
53 * tactic is applied to.
55 * @param newActiveFormula
56 * Iterator referencing the new desired position
58 public void moveActiveFormula(ICalcIterator newActiveFormula)
59 throws RemoteException;
62 // * Start the a calculation by providing initial values to the Dialog On
63 // * success, the Dialog is in DIALOGPHASE_SOLVE
68 // * Formalization from the example collection or null
69 // * @param started_from
74 // * @see isac.util.Formalization
76 // public CalcTree startCalculation(int user_id, Formalization f,
77 // int started_from/* , int requested_calchead_view */)
78 // throws RemoteException;
81 // * Enter the solving phase of the calculation. StartSpecifying must be
82 // * called first Only possible with a complete and correct calcHead
85 // * CalcHead for this calculation
86 // * @return CalcTree represents the calculation on the java side
88 // public void startSolving(/* CalcHead calcHead */) throws Exception;
91 * Modify a given CalcHead The result is the same CalcHead with status flags
94 * @see CalcHead for possible status flags
96 * CalcHead to be modified
97 * @return new CalcHead with a status for each item TODO: return int like
100 public void modifyCalcHead(CalcHead calcHead) throws RemoteException;
103 * Complete a given calcHead: Tell the Kernel to fill out all the missing
104 * fields in the calcHead
107 * the calcHead to be completed TODO: return int like
108 * replaceFormula etc.
110 public void completeCalcHead() throws RemoteException;
113 * Complete a given calcHead: Tell the Kernel to fill out a missing field in
114 * the calcHead, which is specified by an parameter
117 * the calcHead to be completed
118 * @param completeItem
119 * the item which should be added TODO: return int like
120 * replaceFormula etc.
122 * WN040916 don't confuse with autCalculate(...CompleteCalcHead) WN0504 this
123 * case is notyet designed: how indicate the field ???
125 public void completeCalcHead(CalcHead calcHead, int completeItem)
126 throws RemoteException;
129 * Tries to replaces the active formula in the calculation tree by the
130 * passed formula. This could fail if no valid derivation from the preceding
131 * formula to the (new) active formula can be found.
133 * Parts of the calculation after the replaced formula are likely to become
134 * invalid, listeners will be informed of this with the update message,
135 * which contains the last unchanged formula.
138 * @return The method will return 0 on success or a nonzero value indicating
139 * the status otherwise.
141 public int replaceFormula(CalcFormula newFormula) throws RemoteException;
144 * Tries to append the passed formula after the active formula. This could
145 * fail if no valid derivation from the preceding formula to the (new)
146 * active formula can be found. The method will fail as well if the active
147 * formula is not the last formula in the (sub)calculation. Parts of the
148 * calculation might become invalid.
151 * @return The method will return 0 on success or a nonzero value indicating
152 * the status otherwise.
154 public int appendFormula(CalcFormula newFormula) throws RemoteException;
157 * requests the intermediate steps leading to the Formula at the Iterator
158 * (i.e. these steps might be calculated by the math-engine)
162 * @return transactionID also returned in the CalcChangedEvent
164 public int intermediateSteps(ICalcIterator ic) throws RemoteException;
167 * Set the tactic to be used in the next step of calculation.
170 * the Tactic to be used in the the next step
171 * @return The return value indicates success, failure or probable success
174 public int setNextTactic(Tactic tactic) throws RemoteException;
177 * Retrieve the tactic proposed by the SML-Kernel for the next step in the
180 * @return proposed tactic. Can be null, if the kernel does not know what to
181 * do next, or if the end of the calculation is reached
183 public Tactic fetchProposedTactic() throws RemoteException;
186 * Fetch all tactics applicable to the current situation known to the
189 * @see #fetchApplicableTactics(int)
191 public static final int TACTICS_ALL = 1;
194 * Fetch all tactics applicable to the current situation, but restrict the
195 * result to tactics from the current theory.
197 * @see #fetchApplicableTactics(int)
199 public static final int TACTICS_CURRENT_THEORY = 2;
202 * Fetch all tactics applicable to the current situation, but restrict the
203 * result to tactics from the method being applied.
205 * @see #fetchApplicableTactics(int)
207 public static final int TACTICS_CURRENT_METHOD = 3;
210 // * Get a list of tactics applicable to the active formula.
213 // * The filter parameter selects the scope of search for
214 // * applicable tactics.
215 // * @return Array with applicable tactics
216 // * @see #TACTICS_ALL
217 // * @see #TACTICS_CURRENT_THEORY
218 // * @see #TACTICS_CURRENT_METHOD
220 // public Tactic[] fetchApplicableTactics(int scope) throws RemoteException;
223 * Do the number of steps requested, without any restrictions. autoCalculate
224 * ... CompleteCalc Do NOT change the value of this constant, as this number
225 * has a specifig meaning in other parts of the system!
227 * @see #autoCalculate(int, int)
229 public static final int SCOPE_CALCULATION = 6;
232 * Do the number of steps requested, but do not leave the current
233 * subcalculation into a subproblem: CompleteToSubpbl Do NOT change the
234 * value of this constant, as this number has a specifig meaning in other
235 * parts of the system!
237 * @see #autoCalculate(int, int)
239 public static final int SCOPE_SUBCALCULATION = 5;
242 * Do the number of steps requested, but do not leave the current
243 * subproblem: autoCalculate ... CompleteSubpbl Do NOT change the value of
244 * this constant, as this number has a specifig meaning in other parts of
247 * @see #autoCalculate(int, int)
249 public static final int SCOPE_SUBPROBLEM = 4;
252 * Calculate the next n steps starting from the active formula or until the
253 * specified scope is left, whichever comes first.
256 * The scope parameter can have following values:
258 * Specifies the count of steps to be autocalculated. Passing 0
259 * for nSteps will calculate until reaching a final result.
260 * @return The method returns an unique id to identify the request when
261 * notifying about updates in the tree.
262 * @see #SCOPE_CALCULATION
263 * @see #SCOPE_SUBCALCULATION
264 * @see #SCOPE_SUBPROBLEM
267 * WN040624: the above design is desirable, but currently not impl., rather:
268 * either steps == 0, then regard SCOPE_* or steps != 0, then SCOPE_*
271 public int autoCalculate(int scope, int nSteps) throws RemoteException;
274 * get the Formulae and CalcHeads of the calcTree between the two iterators
275 * (including the elements the two iterators a pointing to)
277 * @param iterator_from
278 * The iterator pointing to the element immediately before of the
279 * returned range (which supports direct use of ...
280 * @see isac.util.CalcChangedEvent.last_unchanged_formula_
282 * The iterator pointing at the last element of the returned
285 * The maximum level of the elements in the range, element with a
286 * higher level (who are "deeper" in the hierarchie are not
287 * returned null if everything should be displayed
288 * @param result_includes_tactics
289 * true if the result should include the tactics, false otherwise
291 * @return an Vector containing the Formulae and CalcHeads of the calcTree
292 * @author Alois Kirchsteiger 12.01.2005 16:51:43
294 public Vector getElementsFromTo(ICalcIterator iterator_from,
295 ICalcIterator iterator_to, Integer level,
296 boolean result_includes_tactics) throws RemoteException;
299 * Match a given problem for this CalcTree
302 * @param CalcHead FIXXXME.WN050610 drop !!!
304 * @return CalcHead, if the operation was successful, else null
305 * ... replaced by ref-arg to be used instead
307 public void tryMatch(CalcHead calcHead, CalcHeadCompoundID problemID)
308 throws NotInSpecificationPhaseException;