From 58cccdbe67f6e1966116b3d2f4c83d77863daadc Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 31 Oct 2006 00:31:43 +0000 Subject: Added the new linkmessenger class that will act as a base-class for anything that wants to send messages to a containing programlink. Also fiddled with other things...aparently. --- src/linkmessenger.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/linkmessenger.cpp (limited to 'src/linkmessenger.cpp') diff --git a/src/linkmessenger.cpp b/src/linkmessenger.cpp new file mode 100644 index 0000000..3bd401a --- /dev/null +++ b/src/linkmessenger.cpp @@ -0,0 +1,41 @@ +#include "linkmessenger.h" + +LinkMessenger::LinkMessenger() : + pFirst( NULL ), + pLast( NULL ) +{ +} + +LinkMessenger::~LinkMessenger() +{ +} + +void LinkMessenger::enqueueMessage( LinkMessage *pMsg ) +{ + if( pLast == NULL ) + { + pFirst = pLast = new Link; + pLast->pMsg = pMsg; + pLast->pNext = NULL; + } + else + { + pLast->pNext = new Link; + pLast = pLast->pNext; + pLast->pMsg = pMsg; + pLast->pNext = NULL; + } +} + +LinkMessage *LinkMessenger::dequeueMessage() +{ + if( pFirst == NULL ) + return NULL; + + Link *pTmp = pFirst; + pFirst = pFirst->pNext; + LinkMessage *pRet = pTmp->pMsg; + delete pTmp; + return pRet; +} + -- cgit v1.2.3