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        notifyConsistListChanged();
038        return consist;
039    }
040
041    /**
042     * This implementation does NOT support Command Station consists, so return
043     * false.
044     */
045    @Override
046    public boolean isCommandStationConsistPossible() {
047        return false;
048    }
049
050    /**
051     * Does a CS consist require a separate consist address? This implementation
052     * does not support Command Station consists, so return false
053     */
054    @Override
055    public boolean csConsistNeedsSeperateAddress() {
056        return false;
057    }
058}