Planeshift
|
00001 /* 00002 * questionmanager.h 00003 * 00004 * Copyright (C) 2005 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 #ifndef QUESTION_MANAGER_HEADER 00021 #define QUESTION_MANAGER_HEADER 00022 //============================================================================= 00023 // Crystal Space Includes 00024 //============================================================================= 00025 #include <csutil/csstring.h> 00026 00027 //============================================================================= 00028 // Project Includes 00029 //============================================================================= 00030 #include "net/messages.h" 00031 00032 //============================================================================= 00033 // Local Includes 00034 //============================================================================= 00035 #include "msgmanager.h" 00036 00037 00038 class psQuestionCancelEvent; 00039 00066 class PendingQuestion 00067 { 00068 public: 00069 unsigned id; // unique id 00070 static unsigned nextID; 00071 bool ok; // Set to false to stop sending 00072 00074 psQuestionMessage::questionType_t type; 00075 00079 csString question; 00080 00081 int clientnum; // the questioned client 00082 psQuestionCancelEvent* event; 00083 00084 PendingQuestion() 00085 { 00086 event = NULL; 00087 } 00088 PendingQuestion(int clientnum, const csString &question, psQuestionMessage::questionType_t type); 00089 virtual ~PendingQuestion() {}; 00090 00091 00097 virtual void HandleAnswer(const csString &answer) {}; 00098 virtual void HandleTimeout() {}; 00099 }; 00100 00105 class QuestionManager : public MessageManager<QuestionManager> 00106 { 00107 public: 00108 00109 QuestionManager(); 00110 virtual ~QuestionManager(); 00111 00113 void SendQuestion(PendingQuestion* question); 00114 00116 void CancelQuestion(PendingQuestion* question); 00117 00118 protected: 00119 00120 void HandleQuestionResponse(MsgEntry* pMsg,Client* client); 00121 00122 csHash<PendingQuestion*> questions; 00123 }; 00124 00125 00126 #endif