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

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() );
  }
  
  
  /**
   * Called by Surface on each relevant Recognizer.
   *
   * @param w   The last thing added to the Surface, the root Widget
   *     which caused recognition to begin again.
   *
   * 
   */
  public abstract void reason( Surface s, Widget w );

  /**
   * @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;
}

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