Planeshift
questionmanager.h
Go to the documentation of this file.
1 /*
2  * questionmanager.h
3  *
4  * Copyright (C) 2005 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef QUESTION_MANAGER_HEADER
21 #define QUESTION_MANAGER_HEADER
22 //=============================================================================
23 // Crystal Space Includes
24 //=============================================================================
25 #include <csutil/csstring.h>
26 
27 //=============================================================================
28 // Project Includes
29 //=============================================================================
30 #include "net/messages.h"
31 
32 //=============================================================================
33 // Local Includes
34 //=============================================================================
35 #include "msgmanager.h"
36 
37 
38 class psQuestionCancelEvent;
39 
67 {
68 public:
69  unsigned id; // unique id
70  static unsigned nextID;
71  bool ok; // Set to false to stop sending
72 
75 
79  csString question;
80 
81  int clientnum; // the questioned client
82  psQuestionCancelEvent* event;
83 
85  {
86  event = NULL;
87  }
88  PendingQuestion(int clientnum, const csString &question, psQuestionMessage::questionType_t type);
89  virtual ~PendingQuestion() {};
90 
91 
97  virtual void HandleAnswer(const csString &answer) {};
98  virtual void HandleTimeout() {};
99 };
100 
105 class QuestionManager : public MessageManager<QuestionManager>
106 {
107 public:
108 
109  QuestionManager();
110  virtual ~QuestionManager();
111 
113  void SendQuestion(PendingQuestion* question);
114 
116  void CancelQuestion(PendingQuestion* question);
117 
118 protected:
119 
120  void HandleQuestionResponse(MsgEntry* pMsg,Client* client);
121 
122  csHash<PendingQuestion*> questions;
123 };
124 
125 
126 #endif
psQuestionMessage::questionType_t type
type of question - clients handles each question type differently
virtual void HandleAnswer(const csString &answer)
This is called when user sends answer to this question, or when the question times out (because the u...
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
csString question
Holds data that will be somehow displayed to user.
virtual void HandleTimeout()
QuestionManager keeps track of all the questions of any kind that are pending.
"Questions" are general requests of information from user.
csHash< PendingQuestion * > questions
virtual ~PendingQuestion()
This class collects data of a netclient.
Definition: client.h:95
questionType_t
Various questions that are posed to the user.
Definition: messages.h:3726
static unsigned nextID
psQuestionCancelEvent * event
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106