#include <rwil.h>
Inheritance diagram for rwil::RWIL::

Public Methods | |
| RWIL () | |
| Constructs a RWIL object. More... | |
| void | AddDevice (Device *dev) |
| Add a device to this instance of the implementation. More... | |
| Device * | GetDevice (std::string name) |
| Get a device from its name. More... | |
| void | RemoveDevice (std::string name) |
| Remove a device by name. More... | |
| virtual void | Function () |
| The overloaded function that implements the RWIL functionality. More... | |
| void | Kill () |
| Kill the thread. More... | |
Public Attributes | |
| MessageList | input |
| Represents the input messages. More... | |
| MessageList | output |
| Represents the output messages. More... | |
Private Attributes | |
| std::list< Device *> | m_devices |
| The list of devices. More... | |
| Mutex | m_mutex |
| The mutex that maintains thread safety. More... | |
| bool | m_die |
| Indicates that it is time for the thread to die. More... | |
Definition at line 5 of file rwil.h.
|
|
Constructs a RWIL object.
Definition at line 3 of file rwil.cpp.
00003 : m_die(false) {} |
|
|
Add a device to this instance of the implementation. Device must have unique name
Definition at line 4 of file rwil.cpp. References m_devices, and m_mutex.
|
|
|
The overloaded function that implements the RWIL functionality.
Reimplemented from rwil::Thread. Definition at line 45 of file rwil.cpp. References input, m_devices, m_die, m_mutex, and NULL.
00046 {
00047 bool temp;
00048
00049 while(m_mutex.Wait(), temp = m_die, m_mutex.Release(), temp == false)
00050 {
00051 input.Lock();
00052 std::list<Message*> moving(input.Query(0, time(NULL)));
00053 std::list<Message*>::iterator movingIter = moving.begin();
00054 std::list<Message*> removed;
00055
00056 //Move all messages into the appropriate devices
00057 while(movingIter != moving.end())
00058 {
00059 std::list<Device*>::iterator deviceIter = m_devices.begin();
00060 while(deviceIter != m_devices.end())
00061 {
00062 if((*deviceIter)->GetName() == ((*movingIter)->GetDevice()))
00063 {
00064 (*deviceIter)->AddToQueue(**movingIter);
00065 removed.push_back(*movingIter);
00066 }
00067 deviceIter++;
00068 }
00069 movingIter++;
00070 }
00071
00072 input.Destroy(removed);
00073 input.Release();
00074 //Iterate through all the devices and tell them to work their magic
00075 std::list<Device*>::iterator deviceIter = m_devices.begin();
00076 while(deviceIter != m_devices.end())
00077 {
00078 (*deviceIter)->Tick();
00079 deviceIter++;
00080 }
00081 }
00082 m_die = false;
00083 return;
00084 }
|
|
|
Get a device from its name.
Definition at line 10 of file rwil.cpp. References m_devices, m_mutex, and NULL.
00011 {
00012
00013 ScopedMutex scpm(m_mutex);
00014
00015 std::list<Device*>::iterator iter = m_devices.begin();
00016
00017 while((iter != m_devices.end()) && !m_devices.empty())
00018 {
00019 if((*iter)->GetName() == name)
00020 {
00021 return *iter;
00022 }
00023 iter++;
00024 }
00025 return NULL;
00026 }
|
|
|
Kill the thread. This returns immediately, but thread actually takes a long time to die. It is recommended to Join this thread to determine when done. Definition at line 86 of file rwil.cpp. References m_die, and m_mutex.
|
|
|
Remove a device by name. If the device does not exist, this call does nothing.
Definition at line 28 of file rwil.cpp. References m_devices, and m_mutex.
|
|
|
Represents the input messages.
Definition at line 11 of file rwil.h. Referenced by Function(). |
|
|
The list of devices.
Definition at line 43 of file rwil.h. Referenced by AddDevice(), Function(), GetDevice(), and RemoveDevice(). |
|
|
Indicates that it is time for the thread to die.
|
|
|
The mutex that maintains thread safety.
Reimplemented from rwil::Thread. Definition at line 45 of file rwil.h. Referenced by AddDevice(), Function(), GetDevice(), Kill(), and RemoveDevice(). |
|
|
Represents the output messages.
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001