Package jmri.managers
Class AbstractCabSignalManager
- java.lang.Object
-
- jmri.managers.AbstractCabSignalManager
-
- All Implemented Interfaces:
CabSignalManager
,Disposable
- Direct Known Subclasses:
CbusCabSignalManager
,DefaultCabSignalManager
,LnCabSignalManager
public abstract class AbstractCabSignalManager extends java.lang.Object implements CabSignalManager, Disposable
Abstract implementation of theCabSignalManager
interface.
This file is part of JMRI.JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<CabSignalListListener>
listListeners
protected java.util.HashMap<LocoAddress,CabSignal>
signalList
-
Constructor Summary
Constructors Constructor Description AbstractCabSignalManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addCabSignalListListener(CabSignalListListener listener)
Register a CabSignalListListener object with this CabSignalManagerprotected abstract CabSignal
createCabSignal(LocoAddress address)
Create a new cab signal with the given address.void
delCabSignal(LocoAddress address)
Remove an old CabSignal.void
dispose()
Called when disposing of a disposable.CabSignal
getCabSignal(LocoAddress address)
Find a CabSignal with the given address, and return it.CabSignal[]
getCabSignalArray()
Get an array of known cab signals.java.util.Set<LocoAddress>
getCabSignalList()
Get a list of known cab signal addresses.void
notifyCabSignalListChanged()
Notify the registered CabSignalListListener objects that the CabSignalList has changed.void
removeCabSignalListListener(CabSignalListListener listener)
Remove a CabSignalListListener object with this CabSignalManager
-
-
-
Field Detail
-
signalList
protected java.util.HashMap<LocoAddress,CabSignal> signalList
-
listListeners
protected java.util.ArrayList<CabSignalListListener> listListeners
-
-
Constructor Detail
-
AbstractCabSignalManager
public AbstractCabSignalManager()
-
-
Method Detail
-
getCabSignal
public CabSignal getCabSignal(LocoAddress address)
Find a CabSignal with the given address, and return it. If the CabSignal doesn't exit, create it.- Specified by:
getCabSignal
in interfaceCabSignalManager
- Parameters:
address
- the cab signal for the address- Returns:
- an existing or new cab signal
-
createCabSignal
protected abstract CabSignal createCabSignal(LocoAddress address)
Create a new cab signal with the given address.- Parameters:
address
- the address the cab signal is for- Returns:
- a new cab signal
-
delCabSignal
public void delCabSignal(LocoAddress address)
Remove an old CabSignal.- Specified by:
delCabSignal
in interfaceCabSignalManager
- Parameters:
address
- the address associated with the cab signal
-
getCabSignalList
public java.util.Set<LocoAddress> getCabSignalList()
Get a list of known cab signal addresses.- Specified by:
getCabSignalList
in interfaceCabSignalManager
- Returns:
- list of cab signal addresses
-
getCabSignalArray
public CabSignal[] getCabSignalArray()
Get an array of known cab signals.- Specified by:
getCabSignalArray
in interfaceCabSignalManager
- Returns:
- array of cab signals
-
addCabSignalListListener
public void addCabSignalListListener(CabSignalListListener listener)
Register a CabSignalListListener object with this CabSignalManager- Specified by:
addCabSignalListListener
in interfaceCabSignalManager
- Parameters:
listener
- a CabSignal List Listener object.
-
removeCabSignalListListener
public void removeCabSignalListListener(CabSignalListListener listener)
Remove a CabSignalListListener object with this CabSignalManager- Specified by:
removeCabSignalListListener
in interfaceCabSignalManager
- Parameters:
listener
- a CabSignal List Listener object.
-
notifyCabSignalListChanged
public void notifyCabSignalListChanged()
Notify the registered CabSignalListListener objects that the CabSignalList has changed.- Specified by:
notifyCabSignalListChanged
in interfaceCabSignalManager
-
dispose
public void dispose()
Description copied from interface:Disposable
Called when disposing of a disposable.Note there are no assurances this method will not be called multiple times against a single instance of this Disposable. It is the responsibility of this Disposable to protect itself and the application from ensuring that calling this method multiple times has no unwanted side effects.
- Specified by:
dispose
in interfaceDisposable
-
-