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/connection.cpp | 2 +- src/connectionmonitor.cpp | 17 ----------------- src/linkedlist.cpp | 17 ----------------- src/linkmessage.cpp | 9 --------- src/linkmessenger.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/linkmessenger.h | 32 ++++++++++++++++++++++++++++++++ src/list.cpp | 17 ----------------- src/programlink.cpp | 17 ----------------- src/protocol.cpp | 9 --------- src/tokenstring.cpp | 9 --------- 10 files changed, 74 insertions(+), 96 deletions(-) create mode 100644 src/linkmessenger.cpp create mode 100644 src/linkmessenger.h diff --git a/src/connection.cpp b/src/connection.cpp index 3d3c094..748d56d 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -311,7 +311,7 @@ void Connection::waitForInput( int nBytesIn, int nSec, int nUSec ) { if( nSec == 0 && nUSec == 0 ) { - throw ConnectionException( excodeSocketTimeout, "Socket Timeout"); + throw ConnectionException( excodeSocketTimeout, "Timed out while waiting for %d bytes.", nBytesIn ); } readInput( nSec, nUSec, &nSec, &nUSec ); rlen = getInputAmnt(); diff --git a/src/connectionmonitor.cpp b/src/connectionmonitor.cpp index 1b49f5d..14e46f7 100644 --- a/src/connectionmonitor.cpp +++ b/src/connectionmonitor.cpp @@ -1,20 +1,3 @@ -/*************************************************************************** - connectionmonitor.cpp - description - ------------------- - begin : Mon Sep 8 2003 - copyright : (C) 2003 by Mike Buland - email : eichlan@yf-soft.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - #include "connectionmonitor.h" ConnectionMonitor::ConnectionMonitor(){ diff --git a/src/linkedlist.cpp b/src/linkedlist.cpp index 78a615a..a9902bc 100644 --- a/src/linkedlist.cpp +++ b/src/linkedlist.cpp @@ -1,20 +1,3 @@ -/*************************************************************************** - linkedlist.cpp - description - ------------------- - begin : Sun Oct 19 2003 - copyright : (C) 2003 by Mike Buland - email : eichlan@yf-soft.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - #include "linkedlist.h" LinkedList::LinkedList( ) diff --git a/src/linkmessage.cpp b/src/linkmessage.cpp index ce838f5..cf3df42 100644 --- a/src/linkmessage.cpp +++ b/src/linkmessage.cpp @@ -1,12 +1,3 @@ -/*************************************************************************** - * Copyright (C) 2003 by Mike Buland * - * eichlan@yf-soft.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - ***************************************************************************/ #include "linkmessage.h" #include 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; +} + diff --git a/src/linkmessenger.h b/src/linkmessenger.h new file mode 100644 index 0000000..ed52639 --- /dev/null +++ b/src/linkmessenger.h @@ -0,0 +1,32 @@ +#ifndef LINK_MESSENGER_H +#define LINK_MESSENGER_H + +#include +#include +#include "linkmessage.h" + +class LinkMessenger +{ +public: + LinkMessenger(); + virtual ~LinkMessenger(); + + void enqueueMessage( LinkMessage *pMsg ); + LinkMessage *dequeueMessage(); + bool hasMessages() + { + return (pFirst != NULL); + } + +private: + typedef struct Link + { + LinkMessage *pMsg; + Link *pNext; + }; + Link *pFirst; + Link *pLast; + +}; + +#endif diff --git a/src/list.cpp b/src/list.cpp index c8b88c1..18f1a66 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -1,20 +1,3 @@ -/*************************************************************************** - list.cpp - description - ------------------- - begin : Sun Oct 19 2003 - copyright : (C) 2003 by Mike Buland - email : eichlan@yf-soft.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - #include "list.h" List::List( ) diff --git a/src/programlink.cpp b/src/programlink.cpp index de13be8..21c6fe4 100644 --- a/src/programlink.cpp +++ b/src/programlink.cpp @@ -1,20 +1,3 @@ -/*************************************************************************** - programlink.cpp - description - ------------------- - begin : Sat Sep 6 2003 - copyright : (C) 2003 by Mike Buland - email : eichlan@yf-soft.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - #include "programlink.h" #include "programchain.h" diff --git a/src/protocol.cpp b/src/protocol.cpp index 1b2621f..70c8a02 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,12 +1,3 @@ -/*************************************************************************** - * Copyright (C) 2003 by Mike Buland * - * eichlan@yf-soft.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - ***************************************************************************/ #include "protocol.h" Protocol::Protocol() diff --git a/src/tokenstring.cpp b/src/tokenstring.cpp index 0c861ac..e57ba69 100644 --- a/src/tokenstring.cpp +++ b/src/tokenstring.cpp @@ -1,12 +1,3 @@ -/*************************************************************************** - * Copyright (C) 2003 by Mike Buland * - * eichlan@Xagafinelle * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - ***************************************************************************/ #include "tokenstring.h" #include -- cgit v1.2.3