-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcarousel.cpp
70 lines (60 loc) · 1.86 KB
/
carousel.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
62
63
64
65
66
67
68
69
70
#include "carousel.h"
using namespace vbit;
Carousel::Carousel(Debug *debug) :
_debug(debug)
{
//ctor
}
Carousel::~Carousel()
{
//dtor
}
void Carousel::addPage(TTXPageStream* p)
{
// @todo Don't allow duplicate entries
p->SetTransitionTime(p->GetCycleTime());
_carouselList.push_front(p);
}
void Carousel::deletePage(TTXPageStream* p)
{
_carouselList.remove(p);
}
TTXPageStream* Carousel::nextCarousel()
{
TTXPageStream* p;
if (_carouselList.size()==0) return NULL;
for (std::list<TTXPageStream*>::iterator it=_carouselList.begin();it!=_carouselList.end();++it)
{
p=*it;
if (p->GetStatusFlag()==TTXPageStream::MARKED && p->GetCarouselFlag()) // only remove it once
{
_debug->Log(Debug::LogLevels::logINFO,"[Carousel::nextCarousel] Deleted " + p->GetSourcePage());
p->SetCarouselFlag(false);
if (!(p->GetNormalFlag() || p->GetSpecialFlag() || _page->GetUpdatedFlag()))
p->SetState(TTXPageStream::GONE); // if we are last mark it gone
_carouselList.erase(it--);
}
else if ((!(p->IsCarousel())) || (p->Special()))
{
std::stringstream ss;
ss << "[Carousel::nextCarousel] no longer a carousel " << std::hex << p->GetPageNumber();
_debug->Log(Debug::LogLevels::logINFO,ss.str());
p->SetCarouselFlag(false);
_carouselList.erase(it--);
}
else
{
if (p->Expired())
{
// We found a carousel that is ready to step
if (p->GetCarouselPage()->GetPageStatus() & PAGESTATUS_C9_INTERRUPTED)
{
// carousel should go out now out of sequence
return p;
}
}
}
p=nullptr;
}
return p;
}