/////////////////////////////////////////////////////////////////////////
//
-std::map<QString, std::map<QString, std::map<QString, Fleet> > >& BSDoc::Battles()
+const std::map<QString, std::map<QString, std::map<QString, Fleet> > >& BSDoc::Battles() const
{
return m_Battles;
}
* change it.
* \todo remove this, and replace it with a better more closed interface.
*/
- std::map<QString, std::map<QString, std::map<QString, Fleet> > >& Battles();
+ const std::map<QString, std::map<QString, std::map<QString, Fleet> > >& Battles() const;
signals:
void documentChanged();
{
m_NumberView->clear();
- map<QString, map<QString, map<QString, Fleet> > >& battles = m_doc->Battles();
+ const map<QString, map<QString, map<QString, Fleet> > >& battles = m_doc->Battles();
- for (map<QString, map<QString, map<QString, Fleet> > >::iterator i = battles.begin(); i != battles.end(); i++)
+ for (map<QString, map<QString, map<QString, Fleet> > >::const_iterator i = battles.begin(); i != battles.end(); ++i)
{
QString b = (*i).first;
QListViewItem* battle = new QListViewItem(m_NumberView, b);
- for (map<QString, map<QString, Fleet> >::iterator j = battles[b].begin(); j != battles[b].end(); j++)
+ for (map<QString, map<QString, Fleet> >::const_iterator j = i->second.begin(); j != i->second.end(); ++j)
{
QString g = (*j).first;
QListViewItem* group = new QListViewItem(battle, g);
int groupShips = 0;
- for (map<QString, Fleet>::iterator k = battles[b][g].begin(); k != battles[b][g].end(); k++)
+ for (map<QString, Fleet>::const_iterator k = j->second.begin(); k != j->second.end(); ++k)
{
- int ships = battles[b][g][(*k).first].NumberOfShips();
+ int ships = k->second.NumberOfShips();
groupShips += ships;
- (void) new QListViewItem(group, (*k).first, QString("%1").arg(ships), QString("%1").arg(battles[b][g][(*k).first].ETA()));
+ (void) new QListViewItem(group, (*k).first, QString("%1").arg(ships), QString("%1").arg(k->second.ETA()));
}
group->setText(1, QString("%1").arg(groupShips));
}
//////////////////////////////////////////////////////////////////////////
//
-string Fleet::Name()
+string Fleet::Name() const
{
return m_sName;
}
* s_Races and checks if it finds the race it returns true, if it reaches
* the end without finding it it returns false.
*/
-bool Fleet::setRace(std::string sRace)
+bool Fleet::setRace(string sRace)
{
m_sRace = sRace;
for (map<string, vector<int> >::iterator i = s_Races.begin(); i != s_Races.end(); i++)
//////////////////////////////////////////////////////////////////////////
//
-string Fleet::Race()
+string Fleet::Race() const
{
return m_sRace;
}
/** This function iterates through m_Fleet and adds all numbers together to
* produce a total.
*/
-int Fleet::NumberOfShips()
+int Fleet::NumberOfShips() const
{
int total = 0;
- for (map<string, vector<int> >::iterator i = m_Fleet.begin(); i != m_Fleet.end(); i++)
+ for (map<string, vector<int> >::const_iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i)
{
- total += m_Fleet[(*i).first][0];
+ total += i->second[0];
}
return total;
//////////////////////////////////////////////////////////////////////////
//
-int Fleet::ETA()
+int Fleet::ETA() const
{
return m_iETA;
}
//////////////////////////////////////////////////////////////////////////
//
-void Fleet::setRaces(std::map<std::string, std::vector<int> >& races)
+void Fleet::setRaces(map<string, vector<int> >& races)
{
s_Races = races;
}
//////////////////////////////////////////////////////////////////////////
//
-void Fleet::setUnits(map<std::string, UnitType>& units)
+void Fleet::setUnits(map<string, UnitType>& units)
{
s_Units = units;
for (map<string, UnitType >::iterator i = s_Units.begin(); i != s_Units.end(); i++)
{
- cerr << s_Units[(*i).first].Name() << "\t"
+ cerr << s_Units[(*i).first].Name() << "\t\t"
<< s_Units[(*i).first].Race() <<"\t"
<< s_Units[(*i).first].Class() << "\t"
<< s_Units[(*i).first].Target(0) << "\t"
}
}
+//////////////////////////////////////////////////////////////////////////
+//
+const map<string, vector<int> >& Fleet::Races()
+{
+ return s_Races;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+const map<string, UnitType>& Fleet::Units()
+{
+ return s_Units;
+}
+
+
+
/**Returns the name of this fleet.
* \see setName
*/
- std::string Name();
+ std::string Name() const;
/**The race string decides what type of ships this fleet can have.
* The values must be feeded into this class.
* \return The race, represented as a string.
* \see setRace
*/
- std::string Race();
+ std::string Race() const;
/**Returns the total number of ships in this fleet
*/
- int NumberOfShips();
+ int NumberOfShips() const;
/**Sets the estimated time of arrival. The time as a single integer,
* in relation to the current time. For example if the current time is
void setETA(int eta);
/**Return the estimated time of arrival. It's counted from the current time (tick).
*/
- int ETA();
+ int ETA() const;
static void setRaces(std::map<std::string, std::vector<int> >& races);
static void setUnits(std::map<std::string, UnitType>& units);
+ static const std::map<std::string, std::vector<int> >& Races();
+ static const std::map<std::string, UnitType>& Units();
+
protected:
std::string m_sName;
std::string m_sRace;