// (c) MIT 2003.  All rights reserved.

// $Id: Reasoner.java,v 1.6 2003/03/06 00:40:39 moltmans Exp $
// Time-stamp: <2000-03-11 18:59:37 moltmans>
package rec.sys;



import java.io.*;
import java.util.*;
import rec.util.*;

public abstract class Reasoner implements Serializable
{
  public Reasoner()
  {
    m_Id = new Id();
  }


//    protected void strengthen( Surface s, Widget w, double amount )
//    {
//      w.strengthen( amount );

//      s.addTransition( new StrengthenTransition( s, w, amount ) );
//    }
  

//    protected void weaken( Surface s, Widget w, double amount )
//    {
//      w.weaken( amount );

//      s.addTransition( new StrengthenTransition( s, w, amount ).getFlip() );
//    }

  
  // we need some pattern matching rules here.  we need to determine if
  // the rule should match on the widget pair in question.
  public abstract Iterator getStrongerTypes();

  public abstract Iterator getWeakerTypes();

  /**
   * Called by BasicModule on each reasoner that applies.  A reasoner
   * applies if either stronger's type or any of stronger's supertypes
   * are listed in getStrongerTypes.  And likewise for weaker.
   *
   * This method can be used to prevent the reasoner from applying to
   * a pair of widgets (stronger and weaker) by returning false.
   *
   * If stronger and weaker should be ranked as such then return true.
   **/
  public boolean match( Surface s, Widget stronger, Widget weaker )
  {
    return true;
  }
  
  /**
   * @return the name of the Recognizer
   */
  public final String toString()
  {
    return( getClass().getName() );
  }

  ////////////////////////////////////////////////////////////////////////////

  public final Id getId()
  {
    return( m_Id );
  }

  public final boolean equals( Reasoner r )
  {
    return( m_Id.equals( r.m_Id ) );
  }

  ////////////////////////////////////////////////////////////////////////////

  private Id m_Id;
}

////////////////////////////////////////////////////////////////////////////////
