20 #ifndef EVENT_H_6174D929
21 #define EVENT_H_6174D929
26 #define ERROR_PLATFORM_THROW(msg) \
27 uscxml::ErrorEvent e; \
28 e.name = "error.platform"; \
29 e.data.compound["cause"] = uscxml::Data(msg, uscxml::Data::VERBATIM); \
30 e.data.compound["file"] = uscxml::Data(uscxml::toStr(__FILE__), uscxml::Data::VERBATIM); \
31 e.data.compound["line"] = uscxml::Data(uscxml::toStr(__LINE__), uscxml::Data::INTERPRETED); \
34 #define ERROR_EXECUTION(identifier, cause) \
35 uscxml::ErrorEvent identifier; \
36 identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
37 identifier.data.compound["file"] = uscxml::Data(uscxml::toStr(__FILE__), uscxml::Data::VERBATIM); \
38 identifier.data.compound["line"] = uscxml::Data(uscxml::toStr(__LINE__), uscxml::Data::INTERPRETED); \
39 identifier.name = "error.execution"; \
40 identifier.eventType = uscxml::Event::PLATFORM;
42 #define ERROR_EXECUTION2(identifier, cause, node) \
43 uscxml::ErrorEvent identifier; \
44 identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
45 identifier.data.compound["file"] = uscxml::Data(uscxml::toStr(__FILE__), uscxml::Data::VERBATIM); \
46 identifier.data.compound["line"] = uscxml::Data(uscxml::toStr(__LINE__), uscxml::Data::INTERPRETED); \
47 identifier.name = "error.execution"; \
48 identifier.data.compound["xpath"] = uscxml::Data(DOMUtils::xPathForNode(node), uscxml::Data::VERBATIM); \
49 identifier.eventType = uscxml::Event::PLATFORM;
51 #define ERROR_COMMUNICATION(identifier, cause) \
52 uscxml::ErrorEvent identifier; \
53 identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
54 identifier.data.compound["file"] = uscxml::Data(uscxml::toStr(__FILE__), uscxml::Data::VERBATIM); \
55 identifier.data.compound["line"] = uscxml::Data(uscxml::toStr(__LINE__), uscxml::Data::INTERPRETED); \
56 identifier.name = "error.communication"; \
57 identifier.eventType = uscxml::Event::PLATFORM;
59 #define ERROR_COMMUNICATION2(identifier, cause, node) \
60 uscxml::ErrorEvent identifier; \
61 identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
62 identifier.data.compound["file"] = uscxml::Data(uscxml::toStr(__FILE__), uscxml::Data::VERBATIM); \
63 identifier.data.compound["line"] = uscxml::Data(uscxml::toStr(__LINE__), uscxml::Data::INTERPRETED); \
64 identifier.name = "error.communication"; \
65 identifier.data.compound["xpath"] = uscxml::Data(DOMUtils::xPathForNode(node), uscxml::Data::VERBATIM); \
66 identifier.eventType = uscxml::Event::PLATFORM;
68 #define ERROR_EXECUTION_THROW(cause) \
70 ERROR_EXECUTION(exc, cause); \
74 #define ERROR_EXECUTION_THROW2(cause, node) \
76 ERROR_EXECUTION2(exc, cause, node); \
80 #define ERROR_COMMUNICATION_THROW(cause) \
82 ERROR_COMMUNICATION(exc, cause); \
86 #define ERROR_COMMUNICATION_THROW2(cause, node) \
88 ERROR_COMMUNICATION(exc, cause, node); \
102 Event() : eventType(INTERNAL), hideSendId(
false), uuid(UUID::getUUID()) {}
103 explicit Event(
const std::string& name, Type type = INTERNAL) : name(name), eventType(type), hideSendId(
false) {}
106 bool operator< (
const Event& other)
const {
107 return this < &other;
110 bool operator==(
const Event& other)
const {
111 return (this->name == other.name &&
112 this->sendid == other.sendid &&
113 this->invokeid == other.invokeid &&
114 this->data == other.data);
116 bool operator!=(
const Event& other)
const {
117 return !(*
this == other);
121 return name.size() > 0;
126 operator std::string() {
127 std::stringstream ss;
132 typedef std::multimap<std::string, Data> params_t;
133 typedef std::map<std::string, Data> namelist_t;
135 static bool getParam(
const params_t& params,
const std::string& name,
Data& target) {
136 if (params.find(name) != params.end()) {
137 target = params.find(name)->second;
143 static bool getParam(
const params_t& params,
const std::string& name, std::list<Data>& target) {
144 if (params.find(name) != params.end()) {
145 std::pair<params_t::const_iterator, params_t::const_iterator> rangeIter = params.equal_range(name);
146 while(rangeIter.first != rangeIter.second) {
147 target.push_back(rangeIter.first->second);
155 template <
typename T>
static bool getParam(
const params_t& params,
const std::string& name, T& target) {
156 if (params.find(name) != params.end()) {
157 target = strTo<T>(params.find(name)->second.atom);
163 static bool getParam(
const params_t& params,
const std::string& name,
bool& target) {
164 if (params.find(name) != params.end()) {
166 if (iequals(params.find(name)->second.atom,
"false")) {
168 }
else if(iequals(params.find(name)->second.atom,
"off")) {
170 }
else if(iequals(params.find(name)->second.atom,
"no")) {
172 }
else if(iequals(params.find(name)->second.atom,
"0")) {
180 template <
typename T>
static bool getParam(
const params_t& params,
const std::string& name, std::list<T>& target) {
181 if (params.find(name) != params.end()) {
182 std::pair<params_t::const_iterator, params_t::const_iterator> rangeIter = params.equal_range(name);
183 while(rangeIter.first != rangeIter.second) {
184 target.push_back(strTo<T>(rangeIter.first->second.atom));
196 std::string origintype;
199 std::string invokeid;
201 std::map<std::string, Data> namelist;
202 std::multimap<std::string, Data> params;
205 friend USCXML_API std::ostream& operator<< (std::ostream& os,
const Event& event);
208 USCXML_API std::ostream& operator<< (std::ostream& os,
const Event& event);
215 data.compound[
"msg"] =
Data(msg, Data::VERBATIM);
Definition: Breakpoint.cpp:26