dasher
Class CDasherComponent

java.lang.Object
  extended by dasher.CDasherComponent
Direct Known Subclasses:
CAutoSpeedControl, CDasherModel, CDasherModule, CDasherView, CLanguageModel, CStartHandler

public class CDasherComponent
extends java.lang.Object

DasherComponent is the base class of most functional units of Dasher, and serves to provide a number of common functions and services to its children. These include:

Generally speaking, a single EventHandler and SettingsStore should be created during Dasher's initialisation, and a reference to both passed to each created DasherComponent. However, there is no reason why in future there could not be multiple subgroups of components which are not connected, and by virtue of having seperate EventHandlers and SettingsStores would not hear each other's events, or be effected by each other's parameter changes.

It is, however, not recommended that any two components should share a SettingsStore without also sharing an EventHandler, as the SettingsStore raises an Event to notify whenever a parameter is changed, a behaviour which components may depend upon.


Field Summary
protected  CEventHandler m_EventHandler
          This Component's EventHandler
protected  CSettingsStore m_SettingsStore
          This Component's SettingsStore
 
Constructor Summary
CDasherComponent(CEventHandler EventHandler, CSettingsStore SettingsStore)
          Sole constructor.
 
Method Summary
 boolean GetBoolParameter(Ebp_parameters iParameter)
          Retreives the value of a given global boolean parameter.
 long GetLongParameter(Elp_parameters iParameter)
          Retreives the value of a given global long parameter.
 java.lang.String GetParameterName(EParameters iParameter)
          Retrieves the friendly name of a given parameter.
 int GetParameterType(EParameters iParameter)
          Determines the type of some parameter; this is exactly the same as checking whether it is an instance of Ebp_parameters (boolean), Elp_parameters (long) or Esp_parameters (string).
 java.lang.String GetStringParameter(Esp_parameters iParameter)
          Retreives the value of a given global string parameter.
 void HandleEvent(CEvent pEvent)
          Called by the EventHandler to notify this component of an event raised by another.
 void InsertEvent(CEvent Event)
          Dispatches a new event, which will be passed to the HandleEvent of all other components registered with the EventHandler.
 void SetBoolParameter(Ebp_parameters iParameter, boolean bValue)
          Sets the value of a given boolean parameter by calling the SettingsStore's SetBoolParameter method.
 void SetLongParameter(Elp_parameters iParameter, long lValue)
          Sets the value of a given long parameter by calling the SettingsStore's SetBoolParameter method.
 void SetStringParameter(Esp_parameters iParameter, java.lang.String sValue)
          Sets the value of a given string parameter by calling the SettingsStore's SetBoolParameter method.
 void UnregisterComponent()
          Unregisters this component with the EventHandler, preventing the receipt of any further events, though new ones can still be dispatched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_EventHandler

protected CEventHandler m_EventHandler
This Component's EventHandler


m_SettingsStore

protected CSettingsStore m_SettingsStore
This Component's SettingsStore

Constructor Detail

CDasherComponent

public CDasherComponent(CEventHandler EventHandler,
                        CSettingsStore SettingsStore)
Sole constructor. Registers this component as an event listener, such that HandleEvent will be called whenever any other componenet raises an event.

Parameters:
EventHandler - Event handler with which to register. Must not be null.
SettingsStore - Settings store to be used to get and set parameters. Must not be null.
Method Detail

UnregisterComponent

public void UnregisterComponent()
Unregisters this component with the EventHandler, preventing the receipt of any further events, though new ones can still be dispatched. Typically this is called on destruction of the object.


InsertEvent

public void InsertEvent(CEvent Event)
Dispatches a new event, which will be passed to the HandleEvent of all other components registered with the EventHandler.

Parameters:
Event - Event we wish to pass to other components.

HandleEvent

public void HandleEvent(CEvent pEvent)
Called by the EventHandler to notify this component of an event raised by another. Modifications of the Event object will be seen by subsequent listeners and by the originator. No garuntees are made as to the order in which components will receive events.

Parameters:
pEvent - Event received.

GetBoolParameter

public boolean GetBoolParameter(Ebp_parameters iParameter)
Retreives the value of a given global boolean parameter.

This request is actioned by calling the same method on m_SettingsStore

Parameters:
iParameter - Parameter to retrieve
Returns:
Boolean value of this parameter

GetLongParameter

public long GetLongParameter(Elp_parameters iParameter)
Retreives the value of a given global long parameter.

This request is actioned by calling the same method on m_SettingsStore

Parameters:
iParameter - Parameter to retrieve
Returns:
Long value of this parameter

GetStringParameter

public java.lang.String GetStringParameter(Esp_parameters iParameter)
Retreives the value of a given global string parameter.

This request is actioned by calling the same method on m_SettingsStore

Parameters:
iParameter - Parameter to retrieve
Returns:
String value of this parameter

SetBoolParameter

public void SetBoolParameter(Ebp_parameters iParameter,
                             boolean bValue)
Sets the value of a given boolean parameter by calling the SettingsStore's SetBoolParameter method.

Parameters:
iParameter - Parameter to set
bValue - New value for this parameter

SetLongParameter

public void SetLongParameter(Elp_parameters iParameter,
                             long lValue)
Sets the value of a given long parameter by calling the SettingsStore's SetBoolParameter method.

Parameters:
iParameter - Parameter to set
lValue - New value for this parameter

SetStringParameter

public void SetStringParameter(Esp_parameters iParameter,
                               java.lang.String sValue)
Sets the value of a given string parameter by calling the SettingsStore's SetBoolParameter method.

Parameters:
iParameter - Parameter to set
sValue - New value for this parameter

GetParameterType

public int GetParameterType(EParameters iParameter)
Determines the type of some parameter; this is exactly the same as checking whether it is an instance of Ebp_parameters (boolean), Elp_parameters (long) or Esp_parameters (string).


GetParameterName

public java.lang.String GetParameterName(EParameters iParameter)
Retrieves the friendly name of a given parameter.

Useful for dumping a complete human-readable configuration.

Parameters:
iParameter - Parameter we wish to identify
Returns:
Friendly name for this parameter