diff options
author | Paul Gilbert | 2016-03-08 20:33:57 -0500 |
---|---|---|
committer | Paul Gilbert | 2016-03-08 20:33:57 -0500 |
commit | 34ade1f8cbd964314ebb603ffe4c8a76fbdb32c9 (patch) | |
tree | a6717f82fdb7742432a8b40075030330f52f6b94 | |
parent | eff4ed1ac1b432744de77014f3a7001753580b0e (diff) | |
download | scummvm-rg350-34ade1f8cbd964314ebb603ffe4c8a76fbdb32c9.tar.gz scummvm-rg350-34ade1f8cbd964314ebb603ffe4c8a76fbdb32c9.tar.bz2 scummvm-rg350-34ade1f8cbd964314ebb603ffe4c8a76fbdb32c9.zip |
TITANIC: Add const suffix to many tree item methods
-rw-r--r-- | engines/titanic/core/project_item.cpp | 14 | ||||
-rw-r--r-- | engines/titanic/core/project_item.h | 14 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.cpp | 21 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 17 |
4 files changed, 24 insertions, 42 deletions
diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index e1f5ec4b34..488cdba6c9 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -124,7 +124,7 @@ void CProjectItem::load(SimpleFile *file) { CTreeItem::load(file); } -CGameManager *CProjectItem::getGameManager() { +CGameManager *CProjectItem::getGameManager() const { return _gameManager; } @@ -276,7 +276,7 @@ void CProjectItem::gameLoaded() { petControl->gameLoaded(); } -CPetControl *CProjectItem::getPetControl() { +CPetControl *CProjectItem::getPetControl() const { CDontSaveFileItem *fileItem = getDontSaveFileItem(); CTreeItem *treeItem; @@ -294,11 +294,11 @@ CPetControl *CProjectItem::getPetControl() { return nullptr; } -CRoomItem *CProjectItem::findFirstRoom() { +CRoomItem *CProjectItem::findFirstRoom() const { return dynamic_cast<CRoomItem *>(findChildInstance(*CRoomItem::_type)); } -CTreeItem *CProjectItem::findChildInstance(ClassDef &classDef) { +CTreeItem *CProjectItem::findChildInstance(ClassDef &classDef) const { CTreeItem *treeItem = getFirstChild(); if (treeItem == nullptr) return nullptr; @@ -316,11 +316,11 @@ CTreeItem *CProjectItem::findChildInstance(ClassDef &classDef) { return nullptr; } -CRoomItem *CProjectItem::findNextRoom(CRoomItem *priorRoom) { +CRoomItem *CProjectItem::findNextRoom(CRoomItem *priorRoom) const { return dynamic_cast<CRoomItem *>(findSiblingInstanceOf(*CRoomItem::_type, priorRoom)); } -CTreeItem *CProjectItem::findSiblingInstanceOf(ClassDef &classDef, CTreeItem *startItem) { +CTreeItem *CProjectItem::findSiblingInstanceOf(ClassDef &classDef, CTreeItem *startItem) const { CTreeItem *treeItem = startItem->getParent()->getNextSibling(); if (treeItem == nullptr) return nullptr; @@ -328,7 +328,7 @@ CTreeItem *CProjectItem::findSiblingInstanceOf(ClassDef &classDef, CTreeItem *st return findChildInstance(classDef); } -CDontSaveFileItem *CProjectItem::getDontSaveFileItem() { +CDontSaveFileItem *CProjectItem::getDontSaveFileItem() const { for (CTreeItem *treeItem = getFirstChild(); treeItem; treeItem = treeItem->getNextSibling()) { if (treeItem->isInstanceOf(*CDontSaveFileItem::_type)) return dynamic_cast<CDontSaveFileItem *>(treeItem); diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h index 07a585237b..2ec3a73647 100644 --- a/engines/titanic/core/project_item.h +++ b/engines/titanic/core/project_item.h @@ -81,12 +81,12 @@ private: /** * Finds the first child instance of a given class type */ - CTreeItem *findChildInstance(ClassDef &classDef); + CTreeItem *findChildInstance(ClassDef &classDef) const; /** * Finds the next sibling occurance of a given class type */ - CTreeItem *findSiblingInstanceOf(ClassDef &classDef, CTreeItem *startItem); + CTreeItem *findSiblingInstanceOf(ClassDef &classDef, CTreeItem *startItem) const; private: /** * Load project data from the passed file @@ -119,12 +119,12 @@ public: /** * Get the game manager for the project */ - virtual CGameManager *getGameManager(); + virtual CGameManager *getGameManager() const; /** * Get a reference to the PET control */ - CPetControl *getPetControl(); + CPetControl *getPetControl() const; /** * Resets the game manager field @@ -154,17 +154,17 @@ public: /** * Returns a reference to the first room item in the project */ - CRoomItem *findFirstRoom(); + CRoomItem *findFirstRoom() const; /** * Returns a reference to the next room following the specified room */ - CRoomItem *findNextRoom(CRoomItem *priorRoom); + CRoomItem *findNextRoom(CRoomItem *priorRoom) const; /** * Returns the don't save file item, if it exists in the project */ - CDontSaveFileItem *getDontSaveFileItem(); + CDontSaveFileItem *getDontSaveFileItem() const; CRoomItem *findHiddenRoom() const; diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index ee89a0532e..22c4e1ddac 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -40,7 +40,7 @@ void CTreeItem::load(SimpleFile *file) { CMessageTarget::load(file); } -CGameManager *CTreeItem::getGameManager() { +CGameManager *CTreeItem::getGameManager() const { return _parent ? _parent->getGameManager() : nullptr; } @@ -64,17 +64,17 @@ CTreeItem *CTreeItem::getLastSibling() { return item; } -CTreeItem *CTreeItem::getLastChild() { +CTreeItem *CTreeItem::getLastChild() const { if (!_firstChild) return nullptr; return _firstChild->getLastSibling(); } -CTreeItem *CTreeItem::scan(CTreeItem *item) { +CTreeItem *CTreeItem::scan(CTreeItem *item) const { if (_firstChild) return _firstChild; - CTreeItem *treeItem = this; + const CTreeItem *treeItem = this; while (treeItem != item) { if (treeItem->_nextSibling) return treeItem->_nextSibling; @@ -87,19 +87,6 @@ CTreeItem *CTreeItem::scan(CTreeItem *item) { return nullptr; } -CDontSaveFileItem *CTreeItem::getDontSaveFileItem() { - CTreeItem *item = getFirstChild(); - while (item) { - CDontSaveFileItem *fileItem = dynamic_cast<CDontSaveFileItem *>(item); - if (fileItem) - return fileItem; - - item = item->getNextSibling(); - } - - return nullptr; -} - void CTreeItem::addUnder(CTreeItem *newParent) { if (newParent->_firstChild) addSibling(newParent->getLastSibling()); diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index 4e1581b1f6..acfd8bf2f4 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -54,7 +54,7 @@ public: /** * Get the game manager for the project */ - virtual CGameManager *getGameManager(); + virtual CGameManager *getGameManager() const; /** * Returns true if the item is a file item @@ -74,12 +74,12 @@ public: /** * Get the next sibling */ - CTreeItem *getNextSibling() { return _nextSibling; } + CTreeItem *getNextSibling() const { return _nextSibling; } /** * Get the prior sibling */ - CTreeItem *getPriorSibling() { return _priorSibling; } + CTreeItem *getPriorSibling() const { return _priorSibling; } /** * Get the last sibling of this sibling @@ -89,23 +89,18 @@ public: /** * Get the first child of the item, if any */ - CTreeItem *getFirstChild() { return _firstChild; } + CTreeItem *getFirstChild() const { return _firstChild; } /** * Get the last child of the item, if any */ - CTreeItem *getLastChild(); + CTreeItem *getLastChild() const; /** * Given all the recursive children of the tree item, gives the next * item in sequence to the passed starting item */ - CTreeItem *scan(CTreeItem *item); - - /** - * Get any dont save file item in the immediate children - */ - CDontSaveFileItem *getDontSaveFileItem(); + CTreeItem *scan(CTreeItem *item) const; /** * Adds the item under another tree item |