/* GNU General Public License version 3 notice Copyright (C) 2012 Mihawk . All rights reserved. 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 3 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, see < http://www.gnu.org/licenses/ >. */ #ifndef SERVERQUERYTHREAD_H #define SERVERQUERYTHREAD_H #include #include "ServerQuery.h" class QReadWriteLock; class ServerQueryThread : public QRunnable { public: ServerQueryThread(); virtual ~ServerQueryThread(); void setAddress(const QHostAddress& serverAddress, quint16 serverPort); bool startQueryThread(); void stopQueryThread(); quint8 playerCount() const; bool isRunning() const; const QHostAddress& serverAddress() const; quint16 serverPort() const; protected: void run(); private: QReadWriteLock* myStopMutex; /* For reading thread state and for stopping the thread */ QReadWriteLock* myServerInfoMutex; /* For retrieving server information regarding the player count */ bool myStopThreadFlag; bool myThreadRunningFlag; QHostAddress myServerAddress; quint16 myServerPort; quint8 myServerPlayerCount; }; #endif // SERVERQUERYTHREAD_H