001package jmri.implementation;
002
003import jmri.Consist;
004import jmri.LocoAddress;
005import jmri.DccLocoAddress;
006import jmri.CommandStation;
007
008/**
009 * Default Consist Manager which uses the NmraConsist class for
010 * the consists it builds
011 *
012 * @author Paul Bender Copyright (C) 2003
013 * @author Randall Wood Copyright (C) 2013
014 */
015public class NmraConsistManager extends AbstractConsistManager {
016
017    private CommandStation commandStation = null;
018
019    public NmraConsistManager(CommandStation cs) {
020        super();
021        commandStation = cs;
022    }
023
024    @Override
025    public Consist addConsist(LocoAddress address) {
026        if (! (address instanceof DccLocoAddress)) {
027            throw new IllegalArgumentException("address is not a DccLocoAddress object");
028        }
029        if (consistTable.containsKey(address)) {
030            return (consistTable.get(address));
031        }
032        NmraConsist consist;
033        consist = new NmraConsist((DccLocoAddress) address, commandStation);
034        consistTable.put(address, consist);
035        return (consist);
036    }
037
038    /**
039     * This implementation does NOT support Command Station consists, so return
040     * false.
041     */
042    @Override
043    public boolean isCommandStationConsistPossible() {
044        return false;
045    }
046
047    /**
048     * Does a CS consist require a separate consist address? This implementation
049     * does not support Command Station consists, so return false
050     */
051    @Override
052    public boolean csConsistNeedsSeperateAddress() {
053        return false;
054    }
055}