Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ModeSupervisor Class Reference
[The Mode Supervisor]

#include <ModeSupervisor.hh>

Inherits Module.

List of all members.


Detailed Description

Generic module for switching and remote control of modes.

The ModeSupervisor class is provided as a generic but configurable high level supervisor implementation for the control of and switching between operational modes (whose interfaces are defined through the RHexMode class).

This class maintains a database of modes currently known to the system, each uniquely identified by their name, specified during construction as an inherent property of each mode.

Modes are defined by classes derived from RHexMode, which provide implementations for its virtual methods. Most notably, RHexMode::initialize, RHexMode::uninitialize, RHexMode::start, RHexMode::stop, and RHexMode::updateDatabase can be defined to specify the functionality of the mode. Other methods to be defined include RHexMode::pause and RHexMode::resume as well as RHexMode::kill.

Modes can be added to the supervisor's database by using the method addMode. The initialize method of the mode is then called and may perform internal initialization of the mode. In contrast, during final cleanup of the supervisor, the uninitialize methods of each mode is called to ensure proper cleanup.

For all RHexLib programs which use the mode supervisor (which can be done by adding and activating the ModeSupervisor as a module), the is at most one "current" mode. Following startup, there is no current mode and all calls to ModeSupervisor::getCurrentMode "getCurrentMode" return 0.

The mode supervisor controls the switching between modes through commands received from a communications stream that it sets up during initialization. This provides the only means of explicitly switching between different modes in its database.


Public Member Functions

void addMode (RHexMode *mode)
int countModes (void)
void setCalib (RHexCalibMode *mode)
RHexCalibModegetCalib () const
void setSafe (RHexMode *mode)
RHexModegetSafe () const
RHexModefindModeByName (const char *name)
RHexModefindModeById (mode_id_t id)
RHexModefirstMode (void)
RHexModenextMode (void)
void printModes (void)
mode_id_t getCurrentMode (void)
RHexModegetCurrentModePtr (void)
void init (void)
void activate (void)
void deactivate (void)
void update (void)
void uninit (void)


Member Function Documentation

void ModeSupervisor::addMode RHexMode mode  ) 
 

This method adds the specified mode to the supervisor's database. It also calls the mode's initialize method, which is expected to perform internal initialization and prepare the mode for startup.

int ModeSupervisor::countModes void   ) 
 

This method return the number of modes that are currently in the mode supervisor's database.

RHexMode* ModeSupervisor::findModeById mode_id_t  id  ) 
 

This method locates a mode in the supervisor's database by its ID. Return value is NULL if the mode cannot be found.

RHexMode* ModeSupervisor::findModeByName const char *  name  ) 
 

This method locates a mode in the supervisor's database by its name. Return value is NULL if the mode cannot be found.

RHexMode* ModeSupervisor::firstMode void   )  [inline]
 

This method returns the first mode in the supervisor's list of modes. Return value is NULL if there are no modes in the database. Together with nextMode, this can be used as an iterator to loop through all the modes.

RHexCalibMode* ModeSupervisor::getCalib  )  const [inline]
 

This method returns a pointer to the "calibration mode" used by the ModeSupervisor. It returns NULL if the calibration mode has not yet been set.

mode_id_t ModeSupervisor::getCurrentMode void   )  [inline]
 

This method returns the ID for the currently active mode. If none of the modes are active, a value of 0 is returned.

RHexMode* ModeSupervisor::getCurrentModePtr void   )  [inline]
 

This method returns a pointer to the currently active mode. The return value is NULL if none of the modes is currently active.

RHexMode* ModeSupervisor::getSafe  )  const [inline]
 

This method returns a pointer to the "safe mode" used by the ModeSupervisor. It returns NULL if the safe mode has not yet been set.

RHexMode* ModeSupervisor::nextMode void   )  [inline]
 

This method returns the next mode in the supervisor's list of modes. Return value is NULL if the previous call returned the last mode in the list. Together with firstMode, this can be used as an iterator to loop through all the modes.

void ModeSupervisor::printModes void   ) 
 

This methods prints out on the console, a list of modes currently known to the mode supervisor

void ModeSupervisor::setCalib RHexCalibMode mode  ) 
 

This method chooses a particular mode as the "calibration mode". As such, successful activation and completion of this mode will be required before any further mode transitions can be performed. Such calibration modes are implemented as classes derived from the RHexCalibMode class.

void ModeSupervisor::setSafe RHexMode mode  ) 
 

This method designates the specified mode as the "safe mode". When the mode supervisor loses communication with the commanding client or in the case of emergencies, the supervisor switches to this mode to put the overall system into a safe state. Any class derived from RHexMode can be designated as a safe mode.


RHexLib Reference Documentation