Object representing a specific task which can be added to a MessageLoop_t and receive messages. More...
#include <UTTask.h>
Public Member Functions | |
Task_t () | |
virtual | ~Task_t () |
int32 | Token () const |
MessageLoop_t * | MessageLoop () const |
Protected Member Functions | |
virtual void | AddedToMessageLoop (MessageLoop_t *message_loop) |
virtual void | RemovedFromMessageLoop (MessageLoop_t *message_loop) |
virtual quit_response_t | QuitRequested () |
void | ResumeQuit () |
void | CancelQuit () |
virtual void | Quit () |
Object representing a specific task which can be added to a MessageLoop_t and receive messages. See MessageLoop_t for more complete documentation of the overall messaging architecture. A task is an aggregate of message receivers. As an example of what a task could be, it could implement a state machine with message receivers for each of the various inputs which drive the state machine progression. The task must declare one or more MessageReceiver_t members and one or more message receiver functions. For cleanliness, it is suggested that these be placed at the end of the task subclass declaration in a separate public, protected, or private block with each pair formatted as follows:
void SomethingReceived(const SomeMessage_t* message); MessageReceiver_t< ThisTask_t, SomeMessage_t > m_SomethingReceiver;
The task constructor must actually define the MessageReceiver_t members. The syntax for class member function pointers used by message receivers is a bit obscure, so an example is:
ThisTask_t::ThisTask_t() : m_SomethingReceiver(&ThisTask_t::SomethingReceived)
Messages are actually sent to message receivers by way of the MessageDestination_t class template.
Definition at line 56 of file UTTask.h.
Task_t::Task_t | ( | ) |
Task constructor.
virtual Task_t::~Task_t | ( | ) | [virtual] |
Task destructor. If the task has been added to a message loop but not removed, it will remove itself.
int32 Task_t::Token | ( | ) | const [inline] |
MessageLoop_t * Task_t::MessageLoop | ( | ) | const [inline] |
virtual void Task_t::AddedToMessageLoop | ( | MessageLoop_t * | message_loop | ) | [protected, virtual] |
Called when the task is added to a message loop.
virtual void Task_t::RemovedFromMessageLoop | ( | MessageLoop_t * | message_loop | ) | [protected, virtual] |
Called when the task is removed from a message loop.
virtual quit_response_t Task_t::QuitRequested | ( | ) | [protected, virtual] |
Called when a quit request has been received by the message loop which contains this task. If a task returns eQUIT_deferred, which typically means it needs to prompt the user for something before it can quit, it must later call ResumeQuit or CancelQuit. It is safe for a task to delete itself or another task, create another task, and/or remove itself or another task from the parent message loop inside of QuitRequested. In general, a task should not need to delete itself in QuitRequested. It can instead let the message loop continue to query all other tasks. If no tasks defer or deny the quit request, any tasks which remain installed in the message loop will receive a call to Quit. If the task returns eQUIT_deferred, because it may have deleted itself and created another task, it is safe for any task to resume the quit process.
void Task_t::ResumeQuit | ( | ) | [protected] |
Indicates that the task had previously returned eQUIT_deferred from QuitRequested, and has now come to the decision that it can quit. When the quit process is resumed, all tasks, including this one, will be queried again by way of QuitRequested.
void Task_t::CancelQuit | ( | ) | [protected] |
Indicates that the task had previously returned eQUIT_deferred from QuitRequested, and has now come to the decision that it will not quit.
virtual void Task_t::Quit | ( | ) | [protected, virtual] |
Called when a quit request has been received, all tasks have received that request, and none of them have deferred or denied the quit request. It is safe for a task to delete itself or another task, and/or remove itself or another task from the parent message loop inside of Quit.