src/java/isac/util/interfaces/IToCalc.java
author akremp
Mon, 23 Feb 2004 19:46:17 +0100
changeset 1373 aa7d8900bba5
parent 1341 ebe0ac6b7743
child 1379 74ed39cf8533
permissions -rw-r--r--
*** empty log message ***
rgradisc@1311
     1
/*
rgradisc@1311
     2
 * Created on Sep 19, 2003
rgradisc@1311
     3
 */
rgradisc@1311
     4
package isac.util.interfaces;
rgradisc@1311
     5
rgradisc@1311
     6
import isac.util.formulae.*;
rgradisc@1311
     7
import isac.util.tactics.*;
rgradisc@1311
     8
rgradisc@1311
     9
rgradisc@1311
    10
/**
rgradisc@1311
    11
 * Interface to be used to communicate in the direction towards the Math Engine.
rgradisc@1311
    12
 * 
akremp@1338
    13
 * @author Alan Krempler
rgradisc@1311
    14
 */
rgradisc@1311
    15
rgradisc@1311
    16
public interface IToCalc {
rgradisc@1311
    17
	
rgradisc@1311
    18
	
rgradisc@1311
    19
	/**
rgradisc@1311
    20
	 * Get a new iterator referencing the root element of the calculation tree. 
rgradisc@1311
    21
	 * <p> The functionality for navigating the calculation 
rgradisc@1311
    22
	 * is implemented in the CalcIterator object.
rgradisc@1311
    23
	 * @return new instance of CalcIterator
rgradisc@1311
    24
	 */
rgradisc@1311
    25
	public ICalcIterator iterator();
rgradisc@1311
    26
	  
rgradisc@1311
    27
	/**
rgradisc@1311
    28
	 * Register a new listener who wants to be notified of changes in the data.
rgradisc@1311
    29
	 * The listener has to implement the IToUser interface.
rgradisc@1311
    30
	 * 
rgradisc@1311
    31
	 * @param listener New listener to be registered.
rgradisc@1311
    32
	 * @return false on success, true otherwise.
rgradisc@1311
    33
	 */  
rgradisc@1311
    34
	public boolean addListener(IToUser listener);
rgradisc@1311
    35
	
rgradisc@1311
    36
	/**
rgradisc@1311
    37
	 * @return an iterator referencing the current
rgradisc@1311
    38
	 * "hot spot" in the calculation, i.e. the active formula.
rgradisc@1311
    39
	 */
rgradisc@1311
    40
	public ICalcIterator getActiveFormula();
rgradisc@1311
    41
	
rgradisc@1311
    42
	/**
akremp@1338
    43
	 * Makes the passed formula the active formula, i.e. the formula 
akremp@1338
    44
	 * the next tactic is applied to.
akremp@1338
    45
	 * @param newActiveFormula Iterator referencing the new desired position
akremp@1338
    46
	 */
rgradisc@1311
    47
	public void moveActiveFormula(ICalcIterator newActiveFormula);
rgradisc@1311
    48
	
rgradisc@1311
    49
	/**
akremp@1338
    50
	 * Tries to replaces the active formula in the calculation tree by 
akremp@1338
    51
	 * the passed formula. This could fail if no valid derivation from 
akremp@1338
    52
	 * the preceding formula to the (new) active formula can be found. 
akremp@1338
    53
	 * <p>Parts of the calculation after the replaced 
akremp@1338
    54
	 * formula are likely to become invalid, listeners will be informed
akremp@1338
    55
	 * of this with the update message, which contains the last unchanged 
akremp@1338
    56
	 * formula.
akremp@1338
    57
	 * @param newFormula
akremp@1338
    58
	 * @return The method will return 0 on success or a nonzero value 
akremp@1338
    59
	 * indicating the status otherwise. 
akremp@1338
    60
	 */
rgradisc@1311
    61
	public int replaceFormula(Formula newFormula);
rgradisc@1311
    62
	
rgradisc@1311
    63
	/**
rgradisc@1311
    64
	Tries to append the passed formula after the active formula. 
rgradisc@1311
    65
	This could fail if no valid derivation from the preceding formula 
rgradisc@1311
    66
	to the (new) active formula can be found. The method will fail as 
rgradisc@1311
    67
	well if the active formula is not the last formula in the (sub)calculation.
rgradisc@1311
    68
	Parts of the calculation might become invalid.
rgradisc@1311
    69
	* @param newFormula
rgradisc@1311
    70
	* @return The method will return 0 on success or a nonzero value 
rgradisc@1311
    71
	indicating the status otherwise.
rgradisc@1311
    72
	*/
rgradisc@1311
    73
	public int appendFormula(Formula newFormula);
rgradisc@1311
    74
	
rgradisc@1311
    75
	/**
akremp@1373
    76
	 Set the tactic to be used in the next step of calculation.   
rgradisc@1311
    77
	 * @param tactic the Tactic to be used in the the next step
rgradisc@1311
    78
	 * @return The return value indicates success, failure or probable
akremp@1338
    79
	 * success at a later time.
rgradisc@1311
    80
	 */
rgradisc@1311
    81
	 public int setNextTactic(Tactic tactic);
rgradisc@1311
    82
	 
rgradisc@1311
    83
	/**
akremp@1338
    84
	 * Retrieve the tactic proposed by the SML-Kernel for 
akremp@1338
    85
	 * the next step in the calculation.  
rgradisc@1311
    86
	 * @return proposed tactic.
rgradisc@1311
    87
	 * Can be null, if the kernel does
rgradisc@1311
    88
	 * not know what to do next, or if the end 
rgradisc@1311
    89
	 * of the calculation is reached 
rgradisc@1311
    90
	 */
rgradisc@1311
    91
	 public Tactic fetchProposedTactic();
rgradisc@1311
    92
	 
rgradisc@1311
    93
	 public static final int TACTICS_ALL = 1;
rgradisc@1311
    94
	 public static final int TACTICS_CURRENT_THEORY = 2;
rgradisc@1311
    95
	 public static final int TACTICS_CURRENT_METHOD = 3;
rgradisc@1311
    96
	 
rgradisc@1311
    97
	 
rgradisc@1311
    98
	/**
akremp@1338
    99
	 * Get a list of tactics applicable to the active formula. 
rgradisc@1311
   100
	 * @param scope The filter parameter selects the scope of
akremp@1338
   101
	 * search for applicable tactics.
akremp@1338
   102
	 * @return Array with applicable tactics
akremp@1338
   103
	 * @see #TACTICS_ALL
akremp@1338
   104
	 * @see #TACTICS_CURRENT_THEORY
akremp@1338
   105
	 * @see #TACTICS_CURRENT_METHOD
rgradisc@1311
   106
	 */
rgradisc@1311
   107
	 public Tactic[] fetchApplicableTactics(int scope);
rgradisc@1311
   108
	 
rgradisc@1311
   109
	 
rgradisc@1311
   110
	 public static final int SCOPE_CALCULATION = 1;
rgradisc@1311
   111
	 public static final int SCOPE_SUBCALCULATION = 2;
rgradisc@1311
   112
	 public static final int SCOPE_SUBPROBLEM = 3;
rgradisc@1311
   113
	 
rgradisc@1311
   114
	/**
akremp@1338
   115
	 * Calculate the next n steps starting from the active formula.   
rgradisc@1311
   116
	 * @param scope The scope parameter can have following values:
rgradisc@1311
   117
	 * @param nSteps Specifies the count of steps to be autocalculated. 
akremp@1338
   118
	 * Passing 0 for nSteps will calculate until reaching a final result. 
rgradisc@1311
   119
	 * @return The method returns an unique id to identify the request when 
akremp@1338
   120
	 * notifying about updates in the tree.
akremp@1338
   121
	 * @see #SCOPE_CALCULATION
akremp@1338
   122
	 * @see #SCOPE_SUBCALCULATION
akremp@1338
   123
	 * @see #SCOPE_SUBPROBLEM
rgradisc@1311
   124
	 */
rgradisc@1311
   125
	 public int autoCalculate(int scope, int nSteps);
rgradisc@1311
   126
	  
rgradisc@1311
   127
}