-
Notifications
You must be signed in to change notification settings - Fork 16
/
updatedpages.cpp
61 lines (50 loc) · 1.45 KB
/
updatedpages.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "updatedpages.h"
using namespace vbit;
UpdatedPages::UpdatedPages(Debug *debug) :
_debug(debug)
{
_iter=_UpdatedPagesList.begin();
_page=nullptr;
}
UpdatedPages::~UpdatedPages()
{
}
void UpdatedPages::addPage(TTXPageStream* p)
{
_UpdatedPagesList.push_front(p);
}
TTXPageStream* UpdatedPages::NextPage()
{
if (_page == nullptr)
{
_iter=_UpdatedPagesList.begin();
_page = *_iter;
}
else
{
++_iter;
_page = *_iter;
}
loop:
if (_iter == _UpdatedPagesList.end())
{
_page = nullptr;
}
if (_page)
{
/* remove pointers from this list if the pages are marked for deletion */
if (_page->GetStatusFlag()==TTXPageStream::MARKED && _page->GetUpdatedFlag()) // only remove it once
{
_debug->Log(Debug::LogLevels::logINFO,"[UpdatedPages::NextPage] Deleted " + _page->GetSourcePage());
_iter = _UpdatedPagesList.erase(_iter);
_page->SetUpdatedFlag(false);
if (!(_page->GetSpecialFlag() || _page->GetCarouselFlag() || _page->GetNormalFlag()))
_page->SetState(TTXPageStream::GONE); // if we are last mark it gone.
_page = *_iter;
goto loop; // jump back to try for the next page
}
_iter = _UpdatedPagesList.erase(_iter); // remove page from this list after transmitting it
_page->SetUpdatedFlag(false);
}
return _page;
}