]> ruin.nu Git - hbs.git/blob - bs/bsdoc.h
Can now load the stats and race configurations..
[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 //! The document class
30 /** This class is holding all the data, handles the transportation of the
31   * data to a couple of different mediums and informs users of the data
32   * if it's changed (through the documentChnaged() signal)
33   * \bug it's too open.. 
34   * \todo make this class more closed.
35   * \author Michael Andreen
36   */
37
38 class BSDoc : public QObject
39 {
40   Q_OBJECT
41
42   public:
43         BSDoc();
44     ~BSDoc();
45     void newDoc();
46     bool save();
47     bool saveAs(const QString &filename);
48     bool load(const QString &filename);
49     bool isModified() const;
50
51         /**Adds a new battle to the dokument and emits documentChanged.
52          * \todo add some checks to see if the battle exist and so and return the status.
53          * \return returns 0 if everything is ok.
54          */
55         int newBattle(QString name);
56
57         /**This returns the the data structure, so other can work on it, but not supposed
58          * change it.
59          * \todo remove this, and replace it with a better more closed interface.
60          */
61         std::map<QString, std::map<QString, std::map<QString, Fleet> > >& Battles();
62
63   signals:
64     void documentChanged();
65
66   protected:
67     bool modified;
68
69         /**This is the main datastructure of the battlecalc, it's more or less the
70          * core that everything else works around. A short explanation of the fields:
71          * -# The name of the battle (usually coordinates)
72          * -# The name of the group (ie. Friendly/Hostile)
73          * -# The fleetname (Home Planet, coordinates, irc nicks and so on)
74          * - and in the end you got the actual Fleet object with it's data.
75          */
76         std::map<QString, std::map<QString, std::map<QString, Fleet> > > m_Battles;
77 };
78
79 #endif