001package jmri;
002
003import jmri.implementation.AbstractTurnout;
004
005/**
006 * Some (not much) common machinery for the concrete turnout operator classes.
007 *
008 * @author John Harper Copyright 2005
009 *
010 */
011public abstract class TurnoutOperator extends Thread {
012
013    protected AbstractTurnout myTurnout;
014
015    protected TurnoutOperator(AbstractTurnout t) {
016        myTurnout = t;
017        setName("Operating turnout " + t.getSystemName());
018    }
019
020    protected void operatorCheck() throws TurnoutOperatorException {
021        if (myTurnout.getCurrentOperator() != this) {
022            throw new TurnoutOperatorException();
023        }
024    }
025
026    /**
027     * Exception thrown when the turnout's operator has changed while the
028     * operator is running. This implies that another operation has been started
029     * and that this one should just quietly stop doing its thing.
030     */
031    static public class TurnoutOperatorException extends Exception {
032    }
033}