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