From 07675230038a24dd251581591379c8fe5cc7bfd1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 26 Apr 2016 20:11:07 +0300 Subject: Add memory count functions into MapLayer and SpecailLayer. Also change all memory count functions into const methods. --- src/resources/sprite/spritedef.cpp | 14 +++++++------- src/resources/sprite/spritedef.h | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/resources/sprite') diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp index ba3abaec9..066d0b827 100644 --- a/src/resources/sprite/spritedef.cpp +++ b/src/resources/sprite/spritedef.cpp @@ -594,7 +594,7 @@ bool SpriteDef::addSequence(const int start, return false; } -int SpriteDef::calcMemoryLocal() +int SpriteDef::calcMemoryLocal() const { int sz = sizeof(SpriteDef) + sizeof(ImageSets) + @@ -608,20 +608,20 @@ int SpriteDef::calcMemoryLocal() return sz; } -int SpriteDef::calcMemoryChilds(const int level) +int SpriteDef::calcMemoryChilds(const int level) const { int sz = 0; - FOR_EACH (ImageSets::iterator, it, mImageSets) + FOR_EACH (ImageSets::const_iterator, it, mImageSets) { sz += (*it).first.capacity(); - ImageSet *const imageSet = (*it).second; + const ImageSet *const imageSet = (*it).second; sz += imageSet->calcMemory(level + 1); } - FOR_EACH (ActionsIter, it, mActions) + FOR_EACH (ActionsCIter, it, mActions) { sz += sizeof(unsigned); - ActionMap *const actionMap = (*it).second; - FOR_EACHP (ActionMap::iterator, it2, actionMap) + const ActionMap *const actionMap = (*it).second; + FOR_EACHP (ActionMap::const_iterator, it2, actionMap) { sz += (*it2).first.capacity(); Action *const action = (*it2).second; diff --git a/src/resources/sprite/spritedef.h b/src/resources/sprite/spritedef.h index aea602cee..2fdd1987b 100644 --- a/src/resources/sprite/spritedef.h +++ b/src/resources/sprite/spritedef.h @@ -68,9 +68,9 @@ class SpriteDef final : public Resource void addAction(const unsigned hp, const std::string &name, Action *const action); - int calcMemoryLocal() override final; + int calcMemoryLocal() const override final; - int calcMemoryChilds(const int level) override final; + int calcMemoryChilds(const int level) const override final; static bool addSequence(const int start, const int end, @@ -154,6 +154,7 @@ class SpriteDef final : public Resource typedef std::map Actions; typedef Actions::const_iterator ActionsConstIter; typedef Actions::iterator ActionsIter; + typedef Actions::const_iterator ActionsCIter; ImageSets mImageSets; Actions mActions; -- cgit v1.2.3-70-g09d2