forked from schulmar/Templar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentryinfohandler.cpp
70 lines (54 loc) · 1.36 KB
/
entryinfohandler.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 "entryinfohandler.h"
#include "traceentry.h"
#include "entryinfo.h"
namespace Templar {
void EntryInfoHandler::handleEvent(const TraceEntry &entry)
{
showEntry(entry);
undoStack.push_back(entry);
}
void EntryInfoHandler::undoEvent()
{
if (undoStack.empty())
return;
undoStack.pop_back();
if (undoStack.empty())
return;
TraceEntry entry = undoStack.back();
showEntry(entry);
}
void EntryInfoHandler::inspect(const TraceEntry& entry)
{
showEntry(entry);
}
void EntryInfoHandler::showEntry(const TraceEntry &entry)
{
entryInfo->setEventType((entry.isBegin)?"Begin":"End");
entryInfo->setKind(entry.kind);
entryInfo->setName(entry.context);
entryInfo->setFilePosition(entry.position);
}
void EntryInfoHandler::reset()
{
undoStack.clear();
entryInfo->setEventType("");
entryInfo->setKind("");
entryInfo->setName("");
entryInfo->setFilePosition("");
}
void EntryInfoHandler::forward(const std::vector<TraceEntry> &vec)
{
for (unsigned int i = 0; i < vec.size(); ++i)
{
undoStack.push_back(vec[i]);
}
if (!undoStack.empty())
showEntry(undoStack.back());
}
void EntryInfoHandler::rewind(unsigned int count)
{
undoStack.erase(undoStack.end() - count, undoStack.end());
if (!undoStack.empty())
showEntry(undoStack.back());
}
} // namespace Templar