forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttxpagestream.cpp
96 lines (86 loc) · 2.26 KB
/
ttxpagestream.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "ttxpagestream.h"
TTXPageStream::TTXPageStream() :
_isCarousel(false),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_isSpecial(false),
_updateCount(0)
{
//ctor
}
TTXPageStream::TTXPageStream(std::string filename) :
TTXPage(filename),
_isCarousel(false),
_transitionTime(0),
_CarouselPage(NULL),
_fileStatus(NEW),
_isSpecial(false),
_updateCount(0)
{
struct stat attrib; // create a file attribute structure
stat(filename.c_str(), &attrib); // get the attributes of the file
_modifiedTime=attrib.st_mtime;
}
TTXPageStream::~TTXPageStream()
{
//dtor
}
TTXLine* TTXPageStream::GetTxRow(uint8_t row)
{
// Return a line OR NULL if the row does not exist
TTXLine* line=NULL;
if (IsCarousel())
{
line=_CarouselPage->GetRow(row);
}
else // single page
{
line=GetRow(row); // _lineCounter is implied
}
if (line!=NULL) // Found a line
{
// std::cerr << " (R" << (int)row << ") ";
return line;
}
// No more lines? return NULL.
// std::cerr << " GetNextRow " << _lineCounter << std::endl;
return NULL;
}
void TTXPageStream::StepNextSubpageNoLoop()
{
if (_CarouselPage==NULL)
_CarouselPage=this;
else
_CarouselPage=_CarouselPage->Getm_SubPage();
}
void TTXPageStream::StepNextSubpage()
{
StepNextSubpageNoLoop();
if (_CarouselPage==NULL) // Last carousel subpage? Loop to beginning
_CarouselPage=this;
}
void TTXPageStream::printList()
{
std::cerr << "DUMP TODO" << std::endl;
}
bool TTXPageStream::LoadPage(std::string filename)
{
bool Loaded=false;
// std::cerr << "[TTXPage] file constructor loading " << filename<< std::endl;
//m_Init(); // Careful! We should move inits to the initialisation list and call the default constructor
m_PageNumber=FIRSTPAGE; // Force to replace the root page rather than add to the carousel
if (m_LoadTTI(filename))
Loaded=true;
return Loaded;
}
bool TTXPageStream::operator==(const TTXPageStream& rhs) const
{
// std::cerr << "operator overloaded == " << rhs.GetSourcePage();
if (this->GetSourcePage()==rhs.GetSourcePage())
return true;
return false;
}
void TTXPageStream::IncrementUpdateCount(){
_updateCount = (_updateCount + 1) % 8;
}