]> ruin.nu Git - hbs.git/blob - bs/bsdoc.h
adding, removing and chaning fleets now works.
[hbs.git] / bs / bsdoc.h
1 /***************************************************************************
2                           bcdoc.h  -  description
3                              -------------------
4     begin                : Sun May 27 22:13:58 CEST 2001
5     copyright            : (C) 2001 by Michael Andreen
6     email                : whale@linux.nu
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 #ifndef BCDOC_H
18 #define BCDOC_H
19
20 // include files for QT
21 #include <qobject.h>
22
23 // standard library
24 #include <map>
25
26 // application specific includes
27 #include "fleet.h"
28
29 typedef std::map<QString, std::map<QString, std::map<QString, Fleet*> > > BattleList;
30 //! The document class
31 /** This class is holding all the data, handles the transportation of the
32   * data to a couple of different mediums and informs users of the data
33   * if it's changed (through the documentChnaged() signal)
34   * \bug it's too open.. 
35   * \todo make this class more closed.
36   * \author Michael Andreen
37   */
38
39 class BSDoc : public QObject
40 {
41   Q_OBJECT
42
43   public:
44         BSDoc();
45     ~BSDoc();
46     void newDoc();
47     bool save();
48     bool saveAs(const QString &filename);
49     bool load(const QString &filename);
50     bool isModified() const;
51
52         /**Adds a new battle to the dokument and emits documentChanged.
53          * \todo add some checks to see if the battle exist and so and return the status.
54          * \return returns 0 if everything is ok.
55          */
56         int newBattle(QString name);
57
58         /**This returns the the data structure, so other can work on it, but not supposed
59          * change it.
60          * \todo remove this, and replace it with a better more closed interface.
61          */
62         const BattleList& battles() const;
63
64         
65         /**Looks for the fleet with the specified name, in the specified group in the
66          * specified battle.
67          * \return Returns '\0' (NULL) if the fleet isn't found, if it is found it
68          * returns a const pointer to the fleet.
69          */
70         const Fleet* specificFleet(QString battle, QString group, QString fleet) const;
71
72         void changeFleet(QString battle, QString group, QString fleet, const Fleet* fl);
73
74         void newFleet(QString battle, QString group, QString fleet, Fleet* fl);
75
76         void removeFleet(QString battle, QString group, QString fleet);
77
78         void runBattleSimulation();
79   signals:
80     void documentChanged();
81
82   protected:
83     bool modified;
84
85         /**This is the main datastructure of the battlecalc, it's more or less the
86          * core that everything else works around. A short explanation of the fields:
87          * -# The name of the battle (usually coordinates)
88          * -# The name of the group (ie. Friendly/Hostile)
89          * -# The fleetname (Home Planet, coordinates, irc nicks and so on)
90          * - and in the end you got the actual Fleet object with it's data.
91          */
92          BattleList m_Battles;
93 };
94
95 #endif