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

// -*-Mode: Java-*- 
// $Id: PhraseIO.java,v 1.3 2003/03/06 00:40:40 moltmans Exp $
// PhraseIO.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Mon Aug 23 12:17:38 1999> 
// Time-stamp: <2000-03-12 16:52:39 moltmans> 

package rec.speech;

import rec.util.*;
import rec.sys.*;

/**
 * A very simple mechanism for getting hold of an IO mechanism (for
 * now just speach (SpeechPhraseIO) but eventually also for text based
 * or...)
 *
 * There is a static io mechanism which must be set with SetIO and
 * accessed with getIO.
 **/
public abstract class PhraseIO
{
  private static PhraseIO s_TheIO;

  protected PhraseIO( )
  {
  }

  public static void setIO( PhraseIO io )
  {
    s_TheIO = io;
  }

  public static final PhraseIO getIO()
  {
    Assert.check( s_TheIO != null, "No PhraseIO has been setup" );
    return s_TheIO;
  }
  
  public static String getPhrase() 
  {
    PhraseIO io = getIO();
    return io.getPhraseInternal();
  }

  public static final void say( Object phrase ) 
  {
    say( phrase.toString() );
  }
  
  public static final void say( String phrase ) 
  {
    PhraseIO io = getIO();
    io.sayInternal( phrase );
  }

  protected abstract String getPhraseInternal();
  protected abstract void sayInternal( String phrase );
}
