Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

UI Class Reference

#include <UI.h>

Inheritance diagram for UI:

Thread List of all members.

Detailed Description

This class implements the user interface. It allows the user to start and stop the clustering using the input buttons of the EyeBot controller.
Jia L. Du

Public Member Functions

 UI (char *name, int stackSize, int priority, int id)
bool spawn ()
void initialize (void)

Protected Member Functions

void run (void)

Static Protected Member Functions

void staticRun (void)

Private Attributes

int state
Keyboard keyboard
LCD lcd
Starter starter

Static Private Attributes

const int READY = 0
const int RUNNING = 1

Constructor & Destructor Documentation

UI::UI char *    name,
int    stackSize,
int    priority,
int    id

Constructor for UI. The parameters are passed to the Thread constructor

name pointer to thread name
stackSize size of thread stack
priority thread priority (valid values are: MIN_ PRI to MAX_PRI)
id a unique thread id

Member Function Documentation

void UI::initialize void   

The simulator does not allow the usage of RoBIOS functions in class constructors. Therefore we use public initialize methods for classes that need RoBIOS functions for their initializations.

void UI::run void    [protected]

The method is overwritten by the inheritor. When the thread starts the code in this run method is executed

Reimplemented from Thread.

bool UI::spawn  

According to C++ convention, methods cannot be static and virtual at once. In the initial design run was declared as virtual which results in dynamic binding. That means the program determines at run-time which run method to use, the one of the Thread base class or the one of the inheritor. Because we have to use staticRun, we cannot use the virtual keyword anymore. Without the virtual keyword the compiler determines at compile-time which run method is used, always the run method of the Thread base class. To ensure that the inheritor indeed uses its own run method, it is necessary to overwrite the thread initialization method (spawn) as well.

See also:
true if successful

Reimplemented from Thread.

void UI::staticRun void    [static, protected]

Static wrapper method for run. It does nothing but to call run. That is necessary because the RoBIOS multi-tasking functions expect a pointer to a C-function (not a pointer to a C++ method) containing the code to be executed. Fortunately, pointer-to-static-C++-methods are compatible with regular pointer-to-C-functions. But the problem is that static methods can only use other static methods and variables. The reasons is that a static method, which is shared by all instances, would not know which non-static method or variable to use if there were multiple instances of the same class. Thus, the static property would have to be applied to all used (sub-)methods and (sub-) variables, and propagate through the whole class structure. By using staticRun, we can keep using our non-static run. If static methods cannot call non-static ones, how can staticRun call run? As aforementioned the reason why static method cannot use non-static members is because it is not clear which non-static member to use if there are multiple instances of the same class. That means staticRun needs a pointer to the instance whose run method is to be called. This pointer is stored in a static member variable called me.

See also:

Member Data Documentation

Keyboard UI::keyboard [private]

The UI uses the Keyboard to receive user input

LCD UI::lcd [private]

The UI uses the LCD to display output for the user

UI * UI::mes [static, private]

Stores pointers to instances of UI

See also:

const int UI::READY = 0 [static, private]

Used by the class to keep track of its own state

const int UI::RUNNING = 1 [static, private]

Used by the class to keep track of its own state

Starter UI::starter [private]

The UI uses the Starter to control the clustering algorithm

int UI::state [private]

Used by the class to keep track of its current state. Possible states are UI::READY, UI::RUNNING

Generated on Mon Aug 26 18:34:10 2002 for Cube Clustering by doxygen1.3-rc3