X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/9d057db5601ca755277ff5869cc49301f8e9707e..7f17db9999a6762814f170ed2db0a55a86158338:/gameserv/list.h diff --git a/gameserv/list.h b/gameserv/list.h index 384e9ad..e51d6f5 100644 --- a/gameserv/list.h +++ b/gameserv/list.h @@ -1,11 +1,16 @@ #ifndef LIST_H #define LIST_H -#include +#include #include #include "listnode.h" #include "aClient.h" +#include "extern.h" +#include "options.h" +using std::cout; +using std::endl; +using std::flush; template class List { @@ -37,7 +42,9 @@ List::~List() { if (!isEmpty()) { - cout << "Destroying Nodes" << endl; + #ifdef DEBUGMODE + log("Destroying Nodes"); + #endif ListNode *currentPtr = firstPtr, *tempPtr; @@ -45,14 +52,16 @@ List::~List() { tempPtr = currentPtr; currentPtr = currentPtr->Next(); -// if (!tempPtr->getData()->stats || tempPtr->getData()->stats->started == 0) - cout << "Deleting Memory address: " << tempPtr->getData() << endl << flush; + + #ifdef DEBUGMODE + log("Deleting Memory address: %s", tempPtr->getData()); + #endif delete tempPtr; -// else -// tempPtr->getData()->stats->started = 0; } - cout << "All Nodes destroyed" << endl; + #ifdef DEBUGMODE + log("All Nodes destroyed"); + #endif } } @@ -160,6 +169,7 @@ ListNode *List::Find( T *value ) return NULL; } +#ifdef DEBUGMODE template void List::print() const { @@ -181,8 +191,8 @@ void List::print() const cout << endl; currentPtr = currentPtr->next; } - } +#endif template bool List::remove(T *remPtr) @@ -200,15 +210,18 @@ bool List::remove(T *remPtr) { if (firstPtr == lastPtr) { - cout << "One Element. Deleting it" << endl << flush; + #ifdef DEBUGMODE + log("One Element. Deleting it"); + #endif firstPtr = lastPtr = NULL; delete newPtr; return true; } else if (newPtr != lastPtr && newPtr != firstPtr) { - cout << "Many elements, this one is in the middle. Deleting it" - << ", linking front to back, and back to front." << endl << flush; + #ifdef DEBUGMODE + log("Many elements, this one is in the middle. Deleting it, linking front to back, and back to front."); + #endif newPtr->prev->next = newPtr->next; newPtr->next->prev = newPtr->prev; delete newPtr; @@ -216,8 +229,9 @@ bool List::remove(T *remPtr) } else if (newPtr == lastPtr) { - cout << "This was the last element. Deleting it, and pointing the tail to " - << "its previous element." << endl << flush; + #ifdef DEBUGMODE + log("This was the last element. Deleting it, and pointing the tail to its previous element."); + #endif lastPtr = newPtr->prev; lastPtr->next = 0; delete newPtr; @@ -225,8 +239,9 @@ bool List::remove(T *remPtr) } else if (newPtr == firstPtr) { - cout << "This was the first element. Deleting it, and pointing the head to " - << "its next element." << endl << flush; + #ifdef DEBUGMODE + log("This was the first element. Deleting it, and pointing the head to its next element."); + #endif firstPtr = newPtr->next; firstPtr->prev = 0; delete newPtr;