-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventTrigger.cpp
executable file
·68 lines (55 loc) · 1.84 KB
/
EventTrigger.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
#include "EventTrigger.h"
#include <iostream>
std::vector<TriggerEvent*>& EventTrigger::getTriggerEvent()
{
return this->events;
}
unsigned EventTrigger::getPriority()
{
return this->priority;
}
void EventTrigger::setEvent(std::vector<TriggerEvent* > eventTrigger)
{
this->events = eventTrigger;
}
void EventTrigger::setPriority(unsigned priority)
{
this->priority = priority;
}
EventTrigger::~EventTrigger()
{
for(int i = 0; i < this->events.size(); i++){
free(this->events.at(i)->events);
free(this->events.at(i)->eventParameter);
free(this->events.at(i));
}
}
EventTrigger::EventTrigger()
{
this->priority = 0;
}
void EventTrigger::parsingEventTrigger(DOMElement* raiz)
{
DOMElement *element = NULL;
for(int i = 0; i < raiz->getElementsByTagName(XMLString::transcode("Event"))->getLength(); i++){
TriggerEvent *et = (TriggerEvent*) malloc(sizeof(TriggerEvent));
element = dynamic_cast<DOMElement*>(raiz->getElementsByTagName(XMLString::transcode("Event"))->item(i));
std::string s = XMLString::transcode(element->getTextContent());
int sz = s.size();
et->events = (char*)malloc(sizeof(char)*sz);
const char *c;
c = s.c_str();
std::cout<<"events :"<<c<<std::endl;
strcpy(et->events, c);
s = XMLString::transcode(element->getAttribute(XMLString::transcode("EventParameter1")));
c = s.c_str();
sz = s.size();
et->eventParameter = (char*)malloc(sizeof(char)*sz);
strcpy(et->eventParameter,c );
this->events.push_back(et);
}
element = dynamic_cast<DOMElement*>(raiz->getElementsByTagName(XMLString::transcode("Priority"))->item(0));
if(element != NULL){
this->priority = stoi(XMLString::transcode(element->getTextContent()), nullptr, 10);
}
}