X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fbsdoc.h;h=4cd0ee6d9a28cbb6a479e21ed0672472b2007404;hb=e0be1e6e8f7a246acf49e1f315c8d5bc5a65bfa3;hp=0c02c6fa3fe0a19773ba8acb44356d4f03c27f22;hpb=1bb3da557a983d00ec3ff37ff94152e6f109ee4a;p=hbs.git diff --git a/bs/bsdoc.h b/bs/bsdoc.h index 0c02c6f..4cd0ee6 100644 --- a/bs/bsdoc.h +++ b/bs/bsdoc.h @@ -20,10 +20,20 @@ // include files for QT #include +// standard library +#include + // application specific includes +#include "fleet.h" -/** - * the Document Class +typedef std::map > > BattleList; +//! The document class +/** This class is holding all the data, handles the transportation of the + * data to a couple of different mediums and informs users of the data + * if it's changed (through the documentChnaged() signal) + * \bug it's too open.. + * \todo make this class more closed. + * \author Michael Andreen */ class BSDoc : public QObject @@ -31,7 +41,7 @@ class BSDoc : public QObject Q_OBJECT public: - BSDoc(); + BSDoc(); ~BSDoc(); void newDoc(); bool save(); @@ -39,11 +49,49 @@ class BSDoc : public QObject bool load(const QString &filename); bool isModified() const; + /**Adds a new battle to the dokument and emits documentChanged. + * \todo add some checks to see if the battle exist and so and return the status. + * \return returns 0 if everything is ok. + */ + int newBattle(QString name); + + /**This returns the the data structure, so other can work on it, but not supposed + * change it. + * \todo remove this, and replace it with a better more closed interface. + */ + const BattleList& battles() const; + + + /**Looks for the fleet with the specified name, in the specified group in the + * specified battle. + * \return Returns '\0' (NULL) if the fleet isn't found, if it is found it + * returns a const pointer to the fleet. + */ + const Fleet* specificFleet(QString battle, QString group, QString fleet) const; + + void changeFleet(QString battle, QString group, QString fleet, const Fleet* fl); + + void newFleet(QString battle, QString group, QString fleet, Fleet* fl); + + void removeFleet(QString battle, QString group, QString fleet); + + void runBattleSimulation(); + + void parseScan(); signals: void documentChanged(); protected: bool modified; + + /**This is the main datastructure of the battlecalc, it's more or less the + * core that everything else works around. A short explanation of the fields: + * -# The name of the battle (usually coordinates) + * -# The name of the group (ie. Friendly/Hostile) + * -# The fleetname (Home Planet, coordinates, irc nicks and so on) + * - and in the end you got the actual Fleet object with it's data. + */ + BattleList m_Battles; }; #endif