-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.cpp
More file actions
51 lines (43 loc) · 978 Bytes
/
Event.cpp
File metadata and controls
51 lines (43 loc) · 978 Bytes
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
#include "Event.h"
#include "Entity.h"
#include "TimeStamp.h"
#include <string>
#include <vector>
#include <map>
#include <sstream>
Event::Event()
{
//ctor
}
Event::Event(std::string payload)
{
parsePayload(payload);
}
std::string Event::getDirectionAsString()
{
return directionToString[getDirection()];
}
void Event::setDirectionFromString(std::string directionString)
{
if (directionString == directionToString[In])
{
setDirection(In);
}
else if (directionString == directionToString[Out])
{
setDirection(Out);
}
}
void Event::parsePayload(std::string payload)
{
char splitDelimiter = ' ';
std::vector<std::string> values;
std::stringstream stringStream(payload);
std::string item;
while (getline(stringStream, item, splitDelimiter)) {
values.push_back(item);
}
setTime(stoi(values[0]), stoi(values[1]));
setEntityId(stoi(values[2]));
setDirectionFromString(values[3]);
}