components/nvs: make some methods const

This commit is contained in:
Ivan Grokhotkov 2016-08-22 10:30:35 +08:00
parent 49b2dfea1e
commit 3ce433cfd1
3 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@ public:
return mData; return mData;
} }
Tenum get(size_t index) Tenum get(size_t index) const
{ {
assert(index >= 0 && index < Nitems); assert(index >= 0 && index < Nitems);
size_t wordIndex = index / ITEMS_PER_WORD; size_t wordIndex = index / ITEMS_PER_WORD;

View File

@ -536,7 +536,7 @@ esp_err_t Page::alterPageState(PageState state)
return ESP_OK; return ESP_OK;
} }
esp_err_t Page::readEntry(size_t index, Item& dst) esp_err_t Page::readEntry(size_t index, Item& dst) const
{ {
auto rc = spi_flash_read(getEntryAddress(index), reinterpret_cast<uint32_t*>(&dst), sizeof(dst)); auto rc = spi_flash_read(getEntryAddress(index), reinterpret_cast<uint32_t*>(&dst), sizeof(dst));
if (rc != ESP_OK) { if (rc != ESP_OK) {
@ -658,7 +658,7 @@ void Page::invalidateCache()
mFindInfo = CachedFindInfo(); mFindInfo = CachedFindInfo();
} }
void Page::debugDump() void Page::debugDump() const
{ {
printf("state=%x addr=%x seq=%d\nfirstUsed=%d nextFree=%d used=%d erased=%d\n", mState, mBaseAddress, mSeqNumber, static_cast<int>(mFirstUsedEntry), static_cast<int>(mNextFreeEntry), mUsedEntryCount, mErasedEntryCount); printf("state=%x addr=%x seq=%d\nfirstUsed=%d nextFree=%d used=%d erased=%d\n", mState, mBaseAddress, mSeqNumber, static_cast<int>(mFirstUsedEntry), static_cast<int>(mNextFreeEntry), mUsedEntryCount, mErasedEntryCount);
size_t skip = 0; size_t skip = 0;

View File

@ -162,7 +162,7 @@ public:
void invalidateCache(); void invalidateCache();
void debugDump(); void debugDump() const;
protected: protected:
@ -195,7 +195,7 @@ protected:
esp_err_t alterPageState(PageState state); esp_err_t alterPageState(PageState state);
esp_err_t readEntry(size_t index, Item& dst); esp_err_t readEntry(size_t index, Item& dst) const;
esp_err_t writeEntry(const Item& item); esp_err_t writeEntry(const Item& item);
@ -210,7 +210,7 @@ protected:
return static_cast<uint8_t>(type) & 0x0f; return static_cast<uint8_t>(type) & 0x0f;
} }
uint32_t getEntryAddress(size_t entry) uint32_t getEntryAddress(size_t entry) const
{ {
assert(entry < ENTRY_COUNT); assert(entry < ENTRY_COUNT);
return mBaseAddress + ENTRY_DATA_OFFSET + static_cast<uint32_t>(entry) * ENTRY_SIZE; return mBaseAddress + ENTRY_DATA_OFFSET + static_cast<uint32_t>(entry) * ENTRY_SIZE;