forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
carousel.cpp
66 lines (56 loc) · 1.49 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
#include "carousel.h"
using namespace vbit;
Carousel::Carousel()
{
//ctor
//std::cerr << "[Carousel::Carousel] enters" << std::endl;
}
Carousel::~Carousel()
{
//std::cerr << "[Carousel::Carousel] deleted";
//dtor
}
void Carousel::addPage(TTXPageStream* p)
{
// @todo Don't allow duplicate entries
p->SetTransitionTime(p->GetCycleTime());
_carouselList.push_front(p);
//std::cerr << "[Carousel::addPage]";
}
void Carousel::deletePage(TTXPageStream* p)
{
//std::cerr << "[Carousel::deletePage]";
_carouselList.remove(p);
}
TTXPageStream* Carousel::nextCarousel()
{
TTXPageStream* p;
// std::cerr << "[nextCarousel] list size = " << _carouselList.size() << std::endl;
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)
{
std::cerr << "[Carousel::nextCarousel] Deleted " << p->GetSourcePage() << std::endl;
p->SetState(TTXPageStream::GONE);
_carouselList.remove(p);
return nullptr;
}
if (p->Expired())
{
// We found a carousel that is ready to step
p->StepNextSubpage();
p->SetTransitionTime(p->GetCarouselPage()->GetCycleTime());
break;
}
p=nullptr;
}
#if 0
char c;
std::cin >> c;
if (c=='x')
exit(3);
#endif
return p;
}