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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#ifndef EVENT_H_XZAQ4HR
#define EVENT_H_XZAQ4HR
#include <map>
#include <list>
#include <vector>
#include <string>
#include <DOM/Document.hpp>
#include <DOM/io/Stream.hpp>
#include <inttypes.h>
#define TAGNAME(elem) ((Arabica::DOM::Element<std::string>)elem).getTagName()
#define LOCALNAME(elem) ((Arabica::DOM::Element<std::string>)elem).getLocalName()
#define ATTR(elem, attr) ((Arabica::DOM::Element<std::string>)elem).getAttribute(attr)
#define HAS_ATTR(elem, attr) ((Arabica::DOM::Element<std::string>)elem).hasAttribute(attr)
namespace uscxml {
class Data {
public:
enum Type {
VERBATIM,
INTERPRETED
};
Data() {}
Data(const std::string& atom_, Type type_ = INTERPRETED) : atom(atom_), type(type_) {}
Data(const Arabica::DOM::Node<std::string>& dom);
virtual ~Data() {}
static Data fromJSON(const std::string& jsonString);
static Data fromXML(const std::string& xmlString);
Arabica::DOM::Document<std::string> toDocument();
std::string toXMLString() {
std::stringstream ss;
ss << toDocument();
return ss.str();
}
std::map<std::string, Data> compound;
std::list<Data> array;
std::string atom;
Type type;
protected:
Arabica::DOM::Document<std::string> toNode(const Arabica::DOM::Document<std::string>& factory, const Data& data);
#ifndef SWIGJAVA
friend std::ostream& operator<< (std::ostream& os, const Data& data);
#endif
};
class Event : public Data {
public:
enum Type {
INTERNAL = 1,
EXTERNAL = 2,
PLATFORM = 3
};
Event() : type(INTERNAL) {}
Event(const Arabica::DOM::Node<std::string>& xmlString) : type(INTERNAL) {};
std::string name;
Type type;
std::string origin;
std::string origintype;
Arabica::DOM::Node<std::string> dom;
std::string sendid;
std::string invokeid;
static Event fromXML(const std::string& xmlString);
Arabica::DOM::Document<std::string> toDocument();
std::string toXMLString() {
std::stringstream ss;
ss << toDocument();
return ss.str();
}
#ifndef SWIGJAVA
friend std::ostream& operator<< (std::ostream& os, const Event& event);
#endif
};
class InvokeRequest : public Event {
public:
InvokeRequest(Event event) : Event(event) {}
InvokeRequest() {}
std::string type;
std::string src;
std::map<std::string, std::string> namelist;
typedef std::map<std::string, std::string> namelist_t;
bool autoForward;
std::multimap<std::string, std::string> params;
typedef std::multimap<std::string, std::string> params_t;
std::string content;
static InvokeRequest fromXML(const std::string& xmlString);
Arabica::DOM::Document<std::string> toDocument();
std::string toXMLString() {
std::stringstream ss;
ss << toDocument();
return ss.str();
}
#ifndef SWIGJAVA
friend std::ostream& operator<< (std::ostream& os, const InvokeRequest& sendReq);
#endif
};
class SendRequest : public Event {
public:
SendRequest() {}
SendRequest(Event event) : Event(event) {}
std::string target;
std::string type;
uint32_t delayMs;
std::map<std::string, std::string> namelist;
typedef std::map<std::string, std::string> namelist_t;
std::multimap<std::string, std::string> params;
typedef std::multimap<std::string, std::string> params_t;
std::string content;
static SendRequest fromXML(const std::string& xmlString);
Arabica::DOM::Document<std::string> toDocument();
std::string toXMLString() {
std::stringstream ss;
ss << toDocument();
// std::cout << ss.str() << std::endl;
return ss.str();
}
#ifndef SWIGJAVA
friend std::ostream& operator<< (std::ostream& os, const SendRequest& sendReq);
#endif
};
}
#endif /* end of include guard: EVENT_H_XZAQ4HR */
|