From bf0fc6e9cab82a73d1d31047cc0ffd0faf409fb5 Mon Sep 17 00:00:00 2001 From: lotodore Date: Fri, 12 Jun 2009 16:42:38 +0000 Subject: [PATCH] Removing unused files. --- pokerth_lib.pro | 4 - src/core/common/timermanager.cpp | 134 ----------------------------- src/core/timermanager.h | 61 ------------- src/net/common/senderinterface.cpp | 26 ------ src/net/senderinterface.h | 41 --------- 5 files changed, 266 deletions(-) delete mode 100644 src/core/common/timermanager.cpp delete mode 100644 src/core/timermanager.h delete mode 100644 src/net/common/senderinterface.cpp delete mode 100644 src/net/senderinterface.h diff --git a/pokerth_lib.pro b/pokerth_lib.pro index 2e08eb58..5596c3fe 100644 --- a/pokerth_lib.pro +++ b/pokerth_lib.pro @@ -57,7 +57,6 @@ HEADERS += \ src/core/crypthelper.h \ src/core/avatarmanager.h \ src/core/pokerthexception.h \ - src/core/timermanager.h \ src/engine/boardinterface.h \ src/engine/enginefactory.h \ src/engine/handinterface.h \ @@ -74,7 +73,6 @@ HEADERS += \ src/net/genericsocket.h \ src/net/netpacket.h \ src/net/resolverthread.h \ - src/net/senderinterface.h \ src/net/senderhelper.h \ src/net/sendercallback.h \ src/net/servercontext.h \ @@ -142,7 +140,6 @@ SOURCES += \ src/core/common/crypthelper.cpp \ src/core/common/avatarmanager.cpp \ src/core/common/pokerthexception.cpp \ - src/core/common/timermanager.cpp \ src/third_party/tinyxml/tinystr.cpp \ src/third_party/tinyxml/tinyxml.cpp \ src/third_party/tinyxml/tinyxmlerror.cpp \ @@ -176,7 +173,6 @@ SOURCES += \ src/net/common/downloaderthread.cpp \ src/net/common/netpacket.cpp \ src/net/common/resolverthread.cpp \ - src/net/common/senderinterface.cpp \ src/net/common/senderhelper.cpp \ src/net/common/sendercallback.cpp \ src/net/common/servercontext.cpp \ diff --git a/src/core/common/timermanager.cpp b/src/core/common/timermanager.cpp deleted file mode 100644 index baf6b7be..00000000 --- a/src/core/common/timermanager.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Lothar May * - * * - * 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. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include - - -using namespace std; - - -TimerManager::TimerManager(boost::shared_ptr ioService) -: m_ioService(ioService), m_curTimerId(0) -{ -} - -unsigned -TimerManager::RegisterTimer(unsigned timeoutMsec, boost::function timerHandler, bool autoRestart) -{ - // Register a new timer callback. - boost::recursive_mutex::scoped_lock lock(m_timerMutex); - // Use a unique id for each timer. - unsigned id = GetNextTimerId(); - boost::shared_ptr data(new TimerData); - data->timer.reset( - new boost::asio::deadline_timer(*m_ioService, boost::posix_time::milliseconds(timeoutMsec))); - data->id = id; - data->userHandler = timerHandler; - data->durationMsec = timeoutMsec; - data->autoRestart = autoRestart; - data->cancelled = false; - data->timer->async_wait(boost::bind(&TimerManager::Handler, this, boost::asio::placeholders::error, data)); - m_timerMap.insert(TimerMap::value_type(id, data)); - - return id; -} - -bool -TimerManager::UnregisterTimer(unsigned timerId) -{ - // Remove a timer callback from the map. - boost::recursive_mutex::scoped_lock lock(m_timerMutex); - bool unregistered = false; - TimerMap::iterator pos = m_timerMap.find(timerId); - if (pos != m_timerMap.end()) - { - pos->second->cancelled = true; - m_timerMap.erase(pos); - unregistered = true; - } - return unregistered; -} - -void -TimerManager::Handler(const boost::system::error_code &ec, boost::shared_ptr data) -{ - boost::recursive_mutex::scoped_lock lock(m_timerMutex); - if (!ec && data && !data->cancelled) - { - data->userHandler(); - if (data->autoRestart) - { - data->timer.reset( - new boost::asio::deadline_timer(*m_ioService, boost::posix_time::milliseconds(data->durationMsec))); - data->timer->async_wait(boost::bind(&TimerManager::Handler, this, boost::asio::placeholders::error, data)); - } - else - UnregisterTimer(data->id); - } -} - -/*void -TimerManager::Process() -{ - boost::recursive_mutex::scoped_lock lock(m_timerMutex); - bool timerOccurred; - do - { - timerOccurred = false; - TimerMap::iterator i = m_timerMap.begin(); - if (i != m_timerMap.end()) - { - // Check whether the timer occured. - unsigned currentTicks = static_cast(m_softwareTimer.elapsed().total_milliseconds()); - unsigned timerTicks = i->first; - if (currentTicks >= timerTicks) - { - // Grab a copy of the timer. - TimerData timer = i->second; - // Remove the timer, re-add if it is repeating. - m_timerMap.erase(i); - if (timer.repeat) - { - // Re-add the repeating timer. - // Try to be precise. - unsigned absoluteTimer = currentTicks + timer.msec; - unsigned tickDiff = currentTicks - timerTicks; - if (absoluteTimer >= tickDiff) - absoluteTimer -= tickDiff; - m_timerMap.insert( - TimerMap::value_type(absoluteTimer, timer)); - } - - // The callback may register/unregister a timer (a recursive mutex is used). - timer.handler(); - timerOccurred = true; - } - } - } while (timerOccurred); -}*/ - -unsigned -TimerManager::GetNextTimerId() -{ - ++m_curTimerId; - if (m_curTimerId == 0) // Id 0 is invalid. - ++m_curTimerId; - return m_curTimerId; -} - diff --git a/src/core/timermanager.h b/src/core/timermanager.h deleted file mode 100644 index 8f511002..00000000 --- a/src/core/timermanager.h +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Lothar May * - * * - * 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. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -/* A manager for asynchronous software timer. */ - -#ifndef _TIMERMANAGER_H_ -#define _TIMERMANAGER_H_ - -#include -#include -#include -#include - -class TimerManager -{ -public: - TimerManager(boost::shared_ptr ioService); - - unsigned RegisterTimer(unsigned timeoutMsec, boost::function timerHandler, bool autoRestart = false); - bool UnregisterTimer(unsigned timerId); - -protected: - - struct TimerData - { - unsigned id; - boost::shared_ptr timer; - boost::function userHandler; - unsigned durationMsec; - bool autoRestart; - bool cancelled; - }; - - void Handler(const boost::system::error_code &ec, boost::shared_ptr data); - typedef std::map > TimerMap; - - unsigned GetNextTimerId(); - -private: - boost::shared_ptr m_ioService; - mutable boost::recursive_mutex m_timerMutex; - TimerMap m_timerMap; - unsigned m_curTimerId; -}; - -#endif diff --git a/src/net/common/senderinterface.cpp b/src/net/common/senderinterface.cpp deleted file mode 100644 index 0300299c..00000000 --- a/src/net/common/senderinterface.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Lothar May * - * * - * 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. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include - - -SenderInterface::~SenderInterface() -{ -} - diff --git a/src/net/senderinterface.h b/src/net/senderinterface.h deleted file mode 100644 index b2e391f1..00000000 --- a/src/net/senderinterface.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Lothar May * - * * - * 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. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -/* Interface for network sender functions. */ - -#ifndef _SENDERINTERFACE_H_ -#define _SENDERINTERFACE_H_ - -#include -#include - -class SenderInterface -{ -public: - virtual ~SenderInterface(); - - virtual void Send(boost::shared_ptr session, boost::shared_ptr packet) = 0; - virtual void Send(boost::shared_ptr session, const NetPacketList &packetList) = 0; - - virtual void Process() = 0; - - virtual void SignalSessionTerminated(unsigned sessionId) = 0; -}; - -#endif -