jmri
Class TurnoutOperationManager

java.lang.Object
  extended by jmri.TurnoutOperationManager

public class TurnoutOperationManager
extends Object

class to look after the collection of TurnoutOperation subclasses Unlike the other xxxManager, this does not inherit from AbstractManager since the resources it deals with are not DCC system resources but rather purely internal state

Author:
John Harper Copyright 2005

Constructor Summary
TurnoutOperationManager()
           
 
Method Summary
protected  void addOperation(TurnoutOperation op)
          add a new operation Silently replaces any existing operation with the same name
 void addPropertyChangeListener(PropertyChangeListener l)
           
static String[] concatenateTypeLists(String[] types)
          Proxy support.
 void dispose()
           
protected  void firePropertyChange(String p, Object old, Object n)
           
 boolean getDoOperations()
           
static TurnoutOperationManager getInstance()
          get the one-and-only instance of this class, if necessary creating it first.
 TurnoutOperation getMatchingOperation(Turnout t, int apparentMode)
          find the correct operation for this turnout.
 TurnoutOperation getMatchingOperationAlways(Turnout t)
           
 TurnoutOperation getMatchingOperationAlways(Turnout t, int apparentMode)
          Find a suitable operation for this turnout, based on its feedback type.
 TurnoutOperation getOperation(String name)
          find a TurnoutOperation by its name
 TurnoutOperation[] getTurnoutOperations()
           
 void loadOperationTypes()
          Load the operation types given by the current TurnoutManager instance, in the order given.
protected  void removeOperation(TurnoutOperation op)
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void setDoOperations(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurnoutOperationManager

public TurnoutOperationManager()
Method Detail

dispose

public void dispose()

getTurnoutOperations

public TurnoutOperation[] getTurnoutOperations()

addOperation

protected void addOperation(TurnoutOperation op)
add a new operation Silently replaces any existing operation with the same name

Parameters:
op -

removeOperation

protected void removeOperation(TurnoutOperation op)

getOperation

public TurnoutOperation getOperation(String name)
find a TurnoutOperation by its name

Parameters:
name -
Returns:
the operation

getInstance

public static TurnoutOperationManager getInstance()
get the one-and-only instance of this class, if necessary creating it first. At creation also preload the known TurnoutOperator subclasses (done here to avoid constructor ordering problems). There's a threading problem here, because this invokes loadOperationTypes, which gets the current turnout manager, often the proxy manager, which in turn invokes loadOperationTypes again. This is bad.

Returns:
the TurnoutOperationManager

loadOperationTypes

public void loadOperationTypes()
Load the operation types given by the current TurnoutManager instance, in the order given.

The order is important because the acceptable feedback modes may overlap. All we do is instantiate the classes. The constructors take care of putting everything in the right places. We allow multiple occurrences of the same name without complaining so the Proxy stuff works. There's a threading problem here, because this invokes gets the current turnout manager, often the proxy manager, which in turn invokes loadOperationTypes again. This is bad. It's not clear why it even works.


getMatchingOperationAlways

public TurnoutOperation getMatchingOperationAlways(Turnout t,
                                                   int apparentMode)
Find a suitable operation for this turnout, based on its feedback type. The mode is passed separately so the caller can transform it

Parameters:
t - turnout
apparentMode - mode(s) to be used when finding a matching operation

getMatchingOperation

public TurnoutOperation getMatchingOperation(Turnout t,
                                             int apparentMode)
find the correct operation for this turnout. If operations are globally disabled, return nothing

Parameters:
t - turnout
apparentMode - mode(s) to be used when finding a matching operation
Returns:
operation

getMatchingOperationAlways

public TurnoutOperation getMatchingOperationAlways(Turnout t)

getDoOperations

public boolean getDoOperations()

setDoOperations

public void setDoOperations(boolean b)

concatenateTypeLists

public static String[] concatenateTypeLists(String[] types)
Proxy support. Take a concatenation of operation type lists from multiple systems and turn it into a single list, by eliminating duplicates and ensuring that NoFeedback - which matches anything - comes at the end if it is present at all.

Parameters:
types - list of types possibly containing dupliactes
Returns:
list reduced as described above

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads