1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
23
24
25
26
27
28
29
30
31
32
33
34
35
36
40
41
45
46
50
51
54
55
56
57
58
59
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef nvs_pagemanager_hpp
#define nvs_pagemanager_hpp
#include <memory>
#include <list>
#include "nvs_types.hpp"
#include "nvs_page.hpp"
#include "partition.hpp"
#include "intrusive_list.h"6 includes
namespace nvs
{
class PageManager
{
using TPageList = intrusive_list<Page>;
using TPageListIterator = TPageList::iterator;
public:
PageManager() {}
esp_err_t load(Partition *partition, uint32_t baseSector, uint32_t sectorCount);
TPageListIterator begin()
{
return mPageList.begin();
}{ ... }
TPageListIterator end()
{
return mPageList.end();
}{ ... }
Page& back()
{
return mPageList.back();
}{ ... }
uint32_t getPageCount() {
return mPageCount;
}{ ... }
esp_err_t requestNewPage();
esp_err_t fillStats(nvs_stats_t& nvsStats);
uint32_t getBaseSector()
{
return mBaseSector;
}{ ... }
...protected:
friend class Iterator;
esp_err_t activatePage();
TPageList mPageList;
TPageList mFreePageList;
std::unique_ptr<Page[]> mPages;
uint32_t mBaseSector;
uint32_t mPageCount;
uint32_t mSeqNumber;...
}{ ... };
}{...}
/* ... */
#endif