[go: up one dir, main page]

Menu

[r14]: / ai / trunk / aimanager.h  Maximize  Restore  History

Download this file

77 lines (68 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// C++ Interface: aimanager
//
// Description:
//
//
// Author: Hendrik Hochstetter <hochsthk@studi.informatik.uni-stuttgart.de>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef _AIMANAGER_H
#define _AIMANAGER_H
#include "globals.h"
#include "aiplayer.h"
#include <QtCore/QString>
#include <QtCore/QObject>
#include <QtCore/QDebug>
#include <QtCore/QTimer>
#include <QtCore/QList>
#include <QtCore/QEvent>
#include <QtCore/QMap>
#include <QtCore/QHash>
#include <QtCore/QStack>
#include <QtCore/QQueue>
#include <cheppcl.h>
#include <msgame.h>
#include <msggmgt.h>
#include <msgconv.h>
inline bool operator== (GameBrief gb1, GameBrief gb2)
{
return stringOfGameBrief (gb1) == stringOfGameBrief (gb2);
};
class CheppResponse;
class CheppCommand;
/** @brief Management f&uuml;r Ai-Spieler-Instanzen
* @details Verwaltet einzelne Instanzen von AiPlayer (maxusers viele).
* wenn Spiele beendet werden werden neue gestartet. neu angelegte Spiele
* werden (irgenwann) in einer Liste gespeichert.
* wenn AiPlayer instanzen aus der Ausführung zurückkommen werden sie
* gelöscht und neue instanzen können beim refresh angelegt werden.
**/
class AiManager : public QObject
{
Q_OBJECT
public:
AiManager (QObject *parent = 0);
void run ();
void readSettings ();
void writeSettings ();
private:
int aiStatus;
Cheppcl *cheppcl;
QTimer *timer;
AiSettings aiManagerSettings;
QHash<QString, AiPlayer*> aiPlayers;
QList<GameBrief> games;
QStack<GameBrief> toDelete;
void updateThreads ();
private slots:
void receive (const CheppResponse *rspns);
void wakeUp ();
void clientFinished ();
void returning (QString);
signals:
void send (const CheppCommand*);
};
#endif