package org.speakright.sro;
import org.speakright.core.IConfirmationFlow;
import org.speakright.core.IConfirmationNotifier;
import org.speakright.core.IExecutionContext;
import org.speakright.core.IFlow;
import org.speakright.core.IFlowContext;
import org.speakright.core.ITransparentFlowWrapper;
import org.speakright.core.SRResults;
import org.speakright.core.SRUtils;
import org.speakright.core.flows.NBestConfirmerFlow;
import org.speakright.sro.gen.*;
/**
* SRO for doing simple NBest confirmation. This confirmer can be used
* with any SRO by passing an instance of SROConfirmNBest to the SRO's
* setConfirmer method.
*
* This confirmer does explicit confirmation of each result in the NBest results, accepting yes or no as the
* answer. eg. "Do you want Boston?" If the user answers no to all NBest result values then a confirm-rejection
* occurs and the SRO asks its question again.
*
* Features
* <ul>
* </ul>
*
* @author IanRaeLaptop
*
*/
@SuppressWarnings("serial")
public class SROConfirmNBest extends genSROConfirmNBest implements IConfirmationFlow {
NBestConfirmerFlow m_confirmer;
// boolean m_finished;
public SROConfirmNBest(String subject)
{
super(subject);
m_confirmer = new NBestConfirmerFlow("notused.gsl");
}
public void setNotifier(IConfirmationNotifier notifier)
{
m_confirmer.setNotifier(notifier);
}
public void enableSkipList() {
m_confirmer.enableSkipList();
}
/**
* Must override everything NBestConfirmerFlow defines, and
* delegate to m_confirmer.
*/
@Override
public IFlow getFirst(IFlowContext context) {
return m_confirmer.getFirst(context);
}
public boolean needToExecute(IFlow current, SRResults results) {
return m_confirmer.needToExecute(current, results);
}
/**
* Must override everything NBestConfirmerFlow defines, and
* delegate to m_confirmer.
*/
@Override
public void execute(IExecutionContext context) {
m_confirmer.execute(context);
}
/**
* Must override everything NBestConfirmerFlow defines, and
* delegate to m_confirmer.
*/
@Override
public IFlow getNext(IFlow current, SRResults results)
{
//Since getFirst returned m_confirmer, it was pushed on the flow stack, and executed.
//So our getNext() only gets called when m_confirmer finishes. Since confirmation has finished
//we should return null too, so BaseSROQuestion's m_cw gets to run.
return null;
}
}