src/java/isac/util/interfaces/ICalcIterator.java
author mkoschuc
Thu, 12 May 2005 18:14:49 +0200
changeset 2311 a25434b5a9ac
parent 2310 433ccc878ac0
child 2312 cdcc19348255
permissions -rw-r--r--
java unchanged again
     1 /*
     2  * Created on Sep 19, 2003
     3  */
     4 package isac.util.interfaces;
     5 
     6 import isac.util.formulae.Assumptions;
     7 import isac.util.formulae.CalcFormula;
     8 import isac.util.formulae.Position;
     9 import isac.util.tactics.Tactic;
    10 
    11 import java.rmi.Remote;
    12 import java.rmi.RemoteException;
    13 import java.util.Vector;
    14 
    15 /**
    16  * References a certain position in a CalcTree.
    17  * 
    18  * At such a Position there is (a) a Formula or a CalcHead (b) a Tactic which is
    19  * applicable to this Formula (Apply_Method is the only Tactic applicable to a
    20  * CalcHead) (c) an Assumption generated by application of this Tactic to this
    21  * Formula
    22  * 
    23  * Invariant: The Level changes at most +/- ONE when moveUp or moveDown.
    24  * 
    25  * a CalcIterator may be invalid,
    26  * 
    27  * @see isac.util.CalcChangedEvent#
    28  * 
    29  * Comments for the Dialog Guide # on 'applicable Tactic': if a Formula is also
    30  * a parent of some children (one LevelDown), there is also a 'DETAILED
    31  * applicable Tactic' generating the children. WN040920 presentation unclear #
    32  * on 'causal Tactic': this direction of investigation is opposite to the
    33  * applicablility of Tactics; investigating in this direction, for each Formula
    34  * the Tactic can befound which generated the Formula. The causal Tactic is
    35  * unique for each Formula, with the exception of Positions with moveLevelUp
    36  * (there is a 'DETAILED causal Tactic' analogously to 'DETAILED applicable
    37  * Tactic' at LevelDown)
    38  * 
    39  * @see isac.util.formulae.CalcElement
    40  * @see isac.bridge.CalcTree
    41  * @author Alan Krempler
    42  */
    43 public interface ICalcIterator extends Comparable, Cloneable, Remote {
    44 
    45     /**
    46      * get the marker 'Position' unique within a CalcTree (i.e. a CalcIterator)
    47      * 
    48      * @return Position
    49      */
    50     public Position getPosition() throws RemoteException;
    51 
    52     /**
    53      * Reference the first (root) element in the attached calculation tree.
    54      * 
    55      * @return Like all the moveXXX methods this returns true on success, false
    56      *         if there is no element to move to.
    57      */
    58     public boolean moveRoot() throws RemoteException;
    59 
    60     /**
    61      * Reference the next enclosing CalcHead element in the attached calculation
    62      * tree. This will be the subproblem being solved at the moment, or, if not
    63      * solving subproblems, the root problem of the calculation.
    64      * 
    65      * @return Like all the moveXXX methods this returns true on success, false
    66      *         if there is no element to move to.
    67      */
    68     public boolean moveCalcHead() throws RemoteException;
    69 
    70     /**
    71      * Reference the previous formula in the attached calculation tree.
    72      * 
    73      * @return Like all the moveXXX methods this returns true on success, false
    74      *         if there is no element to move to.
    75      */
    76     public boolean moveUp() throws RemoteException;
    77 
    78     /**
    79      * Reference the next formula in the attached calculation tree.
    80      * 
    81      * @return Like all the moveXXX methods this returns true on success, false
    82      *         if there is no element to move to.
    83      * 
    84      * moveRoot() plus moveDown() reaches all nodes in a CalcTree
    85      */
    86     public boolean moveDown() throws RemoteException;
    87 
    88     /**
    89      * Enter the next coarser level of refinement in the attached calculation
    90      * tree.
    91      * 
    92      * @return Like all the moveXXX methods this returns true on success, false
    93      *         if there is no element to move to.
    94      */
    95     public boolean moveLevelUp() throws RemoteException;
    96 
    97     /**
    98      * Enter the next more detailed level of refinement in the attached
    99      * calculation tree.
   100      * 
   101      * @return Like all the moveXXX methods this returns true on success, false
   102      *         if there is no element to move to.
   103      */
   104     public boolean moveLevelDown() throws RemoteException;
   105 
   106     /**
   107      * Reference the formula which resulted in the currently selected element of
   108      * the attached calculation tree.
   109      */
   110     public boolean moveFormula() throws RemoteException;
   111 
   112     /**
   113      * Ask whether this is the last Item, which is equivalent to whwther there
   114      * is another item where moveDown() could move to.
   115      * 
   116      * @return true, if moveDown() would not yield any new elements false, if
   117      *         moveDown() would move to another element WN040819 awaiting
   118      *         problems with parallel branches (OR, AND, etc.) in calcTree
   119      * @deprecated due to calcChangedEvent since 0512
   120      */
   121     public boolean isLast() throws RemoteException;
   122 
   123     /**
   124      * is the Iterator on a CalcHead or not
   125      */
   126     public boolean onCalcHead() throws RemoteException;
   127 
   128     /**
   129      * Use this to get the current element and check the type by calling
   130      * getType().
   131      * 
   132      * @return The currently referenced Element
   133      * @see #getType()
   134      * @deprecated due to getFormula, getTactic, getAssumption
   135      */
   136     public ICalcElement getElement() throws RemoteException;
   137 
   138     /**
   139      * @return Formula, which may also be a CalcHead !
   140      */
   141 
   142     public ICalcElement getFormula() throws RemoteException;
   143 
   144     /**
   145      * @return Tactic applicable to the formula under the Iterator
   146      */
   147     public Tactic getTactic() throws RemoteException;
   148 
   149     /**
   150      * Get a list of tactics applicable to the active formula.
   151      * 
   152      * @param scope
   153      *            WN0502 not yet impl. The filter parameter selects the scope of
   154      *            search for applicable tactics.
   155      * @return Vector with applicable tactics
   156      * @see #TACTICS_ALL
   157      * @see #TACTICS_CURRENT_THEORY
   158      * @see #TACTICS_CURRENT_METHOD
   159      */
   160     public Vector getApplicableTactics(int scope) throws RemoteException;
   161 
   162     /**
   163      * @return Assumptions generated by the Tactic applied to the formula, both
   164      *         under the same Iterator
   165      */
   166     public Assumptions getAssumptions() throws RemoteException;
   167 
   168     /**
   169      * @return Assumptions accumulated during calculation down to the formula
   170      *         under the Iterator ATTENTION: this returnvalue is also used by
   171      *         getAssumptions as long as getAccumulatedAssumptions does not
   172      *         include references to their _several_ sources -- i.e. change
   173      *         _this_ return, not that in getAssumptions !
   174      */
   175     public Assumptions getAccumulatedAssumptions() throws RemoteException;
   176 
   177     /**
   178      * The current level of nesting into subcalculations.
   179      * 
   180      * @return An int representing level of nesting (higher == more detailed)
   181      *         <p>
   182      *         Special values:
   183      *         <p>
   184      *         0: outmost level: only first and last step of calculation are on
   185      *         this level
   186      */
   187     public int getLevel() throws RemoteException;
   188 
   189     /**
   190      * Create a copy of this Iterator: the clone will point to the same formula
   191      * in the calcTree
   192      * 
   193      * @return a cloned Iterator
   194      */
   195     public Object clone();
   196 
   197     /**
   198      * for test-output
   199      * 
   200      * @return 'position', i.e. unique identifier in a CalcTree
   201      */
   202     public String toSMLString();
   203 
   204     //	/**
   205     //	 * Create a copy of this Iterator: the clone will point to the Position
   206     //	 * in the calcTree (Position may come from a formula in the worksheet)
   207     //	 *
   208     //	 * @return a cloned Iterator
   209     //	 */
   210     //	public ICalcIterator clone(Position p);
   211 
   212     //	/**
   213     //	 * @return the position unique within a calctree
   214     //	 * @see isac.uti.interfaces.ICalcIterator#clone(Position)
   215     //	 */
   216     //	public Position getSmlPos();
   217 }