From 8e278873d4bd35a7cd7f3b6d9d7852fa422370b8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Dec 2008 12:09:27 -0500 Subject: Merged CHECK macro branch --- sigmod/MapWildList.cpp | 95 +++----------------------------------------------- 1 file changed, 5 insertions(+), 90 deletions(-) (limited to 'sigmod/MapWildList.cpp') diff --git a/sigmod/MapWildList.cpp b/sigmod/MapWildList.cpp index 1a385632..27820147 100644 --- a/sigmod/MapWildList.cpp +++ b/sigmod/MapWildList.cpp @@ -85,97 +85,13 @@ QDomElement Sigmod::MapWildList::save() const return xml; } -void Sigmod::MapWildList::setName(const QString& name) -{ - CHECK(name); -} +SETTER(MapWildList, QString&, Name, name) -QString Sigmod::MapWildList::name() const -{ - return m_name; -} +GETTER(MapWildList, QString, name) -const Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounter(const int index) const -{ - if (index < encounterCount()) - return m_encounters.at(index); - return NULL; -} - -Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounter(const int index) -{ - if (index < encounterCount()) - return m_encounters[index]; - return NULL; -} - -const Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounterById(const int id) const -{ - return encounter(encounterIndex(id)); -} - -Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounterById(const int id) -{ - return encounter(encounterIndex(id)); -} - -int Sigmod::MapWildList::encounterIndex(const int id) const -{ - for (int i = 0; i < encounterCount(); ++i) - { - if (m_encounters[i]->id() == id) - return i; - } - return INT_MAX; -} - -int Sigmod::MapWildList::encounterCount() const -{ - return m_encounters.size(); -} +CHECK(MapWildList, QString&, name) -Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter() -{ - return newEncounter(new MapWildListEncounter(this, newEncounterId())); -} - -Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter(const QDomElement& xml) -{ - return newEncounter(new MapWildListEncounter(xml, this, newEncounterId())); -} - -Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter(const MapWildListEncounter& encounter) -{ - return newEncounter(new MapWildListEncounter(encounter, this, newEncounterId())); -} - -Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter(MapWildListEncounter* encounter) -{ - m_encounters.append(encounter); - return encounter; -} - -void Sigmod::MapWildList::deleteEncounter(const int index) -{ - if (index < encounterCount()) - { - delete m_encounters[index]; - m_encounters.removeAt(index); - } -} - -void Sigmod::MapWildList::deleteEncounterById(const int id) -{ - deleteEncounter(encounterIndex(id)); -} - -int Sigmod::MapWildList::newEncounterId() const -{ - int i = 0; - while ((i < encounterCount()) && (encounterIndex(i) != INT_MAX)) - ++i; - return i; -} +SUBCLASS(MapWildList, Encounter, encounter, encounters) Sigmod::MapWildList& Sigmod::MapWildList::operator=(const MapWildList& rhs) { @@ -189,6 +105,5 @@ Sigmod::MapWildList& Sigmod::MapWildList::operator=(const MapWildList& rhs) void Sigmod::MapWildList::clear() { - qDeleteAll(m_encounters); - m_encounters.clear(); + SUBCLASS_CLEAR(encounters); } -- cgit