Bitstream Interpretation Library (BIL)
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
bitstream
V5BitstreamSyntaxChecker.cpp
Go to the documentation of this file.
1
6
#include <
bitstream/V5BitstreamSyntaxChecker.hpp
>
7
#include <
exception/Exception.hpp
>
8
9
using namespace
bil;
10
11
12
V5BitstreamSyntaxChecker::V5BitstreamSyntaxChecker
()
13
{
14
reset
();
15
}
16
17
18
bool
V5BitstreamSyntaxChecker::behindSyncWord
()
const
19
{
20
return
m_behindSyncWord;
21
}
22
23
24
bool
V5BitstreamSyntaxChecker::lastPacketWasType1
()
const
25
{
26
return
m_lastPacketWasType1;
27
}
28
29
30
RegisterAddress::address_t
V5BitstreamSyntaxChecker::lastType1Address
()
const
31
{
32
return
m_lastType1Address;
33
}
34
35
36
void
V5BitstreamSyntaxChecker::reset
()
37
{
38
// reset status flags
39
m_behindSyncWord =
false
;
40
m_lastPacketWasType1 =
false
;
41
m_lastType1Address = 0;
42
}
43
44
45
void
V5BitstreamSyntaxChecker::visit
(
const
BuswidthPattern
&)
46
{
47
// buswidth pattern is only allowed somewhere in front of sync word
48
if
(m_behindSyncWord)
throw
Exception
();
49
m_lastPacketWasType1 =
false
;
50
}
51
52
53
void
V5BitstreamSyntaxChecker::visit
(
const
DummyWord
&)
54
{
55
// dummy words are allowed everywhere
56
m_lastPacketWasType1 =
false
;
57
}
58
59
60
void
V5BitstreamSyntaxChecker::visit
(
const
SyncWord
&)
61
{
62
// sync word is only allowed one time
63
if
(m_behindSyncWord)
throw
Exception
();
64
m_behindSyncWord =
true
;
65
m_lastPacketWasType1 =
false
;
66
}
67
68
69
void
V5BitstreamSyntaxChecker::visit
(
const
Type1Packet
& type1Packet)
70
{
71
// type 1 data packets are only allowed somewhere behind sync word
72
if
(!m_behindSyncWord)
throw
Exception
();
73
m_lastPacketWasType1 =
true
;
74
// store packet's register address
75
m_lastType1Address = type1Packet.
registerAddress
();
76
}
77
78
79
void
V5BitstreamSyntaxChecker::visit
(
const
Type2Packet
&)
80
{
81
// type 2 data packets are only allowed somewhere behind sync word and
82
// have to be immediately behind a type 1 packet
83
if
(!m_behindSyncWord)
throw
Exception
();
84
if
(!m_lastPacketWasType1)
throw
Exception
();
85
m_lastPacketWasType1 =
false
;
86
}
Generated on Wed Aug 8 2012 21:57:40 for Bitstream Interpretation Library (BIL) by
1.8.1.1