Files
25Sep01_EventQueue/code/EventQueue.cpp

47 lines
1006 B
C++

#include "EventQueue.h"
bool EventQueue::EventQueue_AddEvent(int tInputCmd, void *pInputParam)
{
cmdParam.push_back(pInputParam);
cmdList.push_back(tInputCmd);
return true;
}
bool EventQueue::EventQueue_AddEventToFront(int tInputCmd, void *pInputParam)
{
cmdParam.push_front(pInputParam);
cmdList.push_front(tInputCmd);
return true;
}
bool EventQueue::EventQueue_PeekEvent(int *pOutputCmd, void **ppOutputParam)
{
if (cmdList.empty())
return false;
(*pOutputCmd) = cmdList.front();
(*ppOutputParam) = cmdParam.front();
return true;
}
void EventQueue::EventQueue_PopEvent(void)
{
if (!cmdList.empty())
{
cmdList.pop_front();
cmdParam.pop_front();
}
}
bool EventQueue::EventQueue_GetEvent(int *pOutputCmd, void **ppOutputParam)
{
if (cmdList.empty())
return false;
(*pOutputCmd) = cmdList.front();
(*ppOutputParam) = cmdParam.front();
cmdList.pop_front();
cmdParam.pop_front();
return true;
}