summaryrefslogtreecommitdiffstats
path: root/src/uscxml/messages/Event.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/messages/Event.h')
-rw-r--r--src/uscxml/messages/Event.h145
1 files changed, 29 insertions, 116 deletions
diff --git a/src/uscxml/messages/Event.h b/src/uscxml/messages/Event.h
index 94bc386..8b7bb91 100644
--- a/src/uscxml/messages/Event.h
+++ b/src/uscxml/messages/Event.h
@@ -21,28 +21,35 @@
#define EVENT_H_6174D929
#include "uscxml/messages/Data.h"
+#include "uscxml/util/UUID.h"
+
+#define ERROR_PLATFORM_THROW(msg) \
+ ErrorEvent e; \
+ e.name = "error.platform"; \
+ e.data.compound["cause"] = Data(msg, Data::VERBATIM); \
+ throw e; \
#define ERROR_EXECUTION(identifier, cause) \
- uscxml::Event identifier; \
+ uscxml::ErrorEvent identifier; \
identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
identifier.name = "error.execution"; \
identifier.eventType = uscxml::Event::PLATFORM;
#define ERROR_EXECUTION2(identifier, cause, node) \
- uscxml::Event identifier; \
+ uscxml::ErrorEvent identifier; \
identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
identifier.name = "error.execution"; \
identifier.data.compound["xpath"] = uscxml::Data(DOMUtils::xPathForNode(node), uscxml::Data::VERBATIM); \
identifier.eventType = uscxml::Event::PLATFORM;
#define ERROR_COMMUNICATION(identifier, cause) \
- uscxml::Event identifier; \
+ uscxml::ErrorEvent identifier; \
identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
identifier.name = "error.communication"; \
identifier.eventType = uscxml::Event::PLATFORM;
#define ERROR_COMMUNICATION2(identifier, cause, node) \
- uscxml::Event identifier; \
+ uscxml::ErrorEvent identifier; \
identifier.data.compound["cause"] = uscxml::Data(cause, uscxml::Data::VERBATIM); \
identifier.name = "error.communication"; \
identifier.data.compound["xpath"] = uscxml::Data(DOMUtils::xPathForNode(node), uscxml::Data::VERBATIM); \
@@ -82,9 +89,8 @@ public:
PLATFORM = 3
};
- Event() : eventType(INTERNAL), hideSendId(false) {}
+ Event() : eventType(INTERNAL), hideSendId(false), uuid(UUID::getUUID()) {}
Event(const std::string& name, Type type = INTERNAL) : name(name), eventType(type), hideSendId(false) {}
- Event(const Arabica::DOM::Node<std::string>& xmlString) : eventType(INTERNAL), hideSendId(false) {};
bool operator< (const Event& other) const {
return this < &other;
}
@@ -99,105 +105,8 @@ public:
return !(*this == other);
}
- std::string getName() const {
- return name;
- }
- void setName(const std::string& name) {
- this->name = name;
- }
-
- Type getEventType() const {
- return eventType;
- }
- void setEventType(const Type type) {
- this->eventType = type;
- }
-
- std::string getOrigin() const {
- return origin;
- }
- void setOrigin(const std::string& origin) {
- this->origin = origin;
- }
-
- std::string getOriginType() const {
- return origintype;
- }
- void setOriginType(const std::string& originType) {
- this->origintype = originType;
- }
-
- Arabica::DOM::Node<std::string> getDOM() const {
- return dom;
- }
- void setDOM(const Arabica::DOM::Node<std::string>& dom) {
- this->dom = dom;
- }
-
-// Arabica::DOM::Node<std::string> getFirstDOMElement() const;
-// Arabica::DOM::Document<std::string> getStrippedDOM() const;
-//
-// static Arabica::DOM::Node<std::string> getFirstDOMElement(const Arabica::DOM::Document<std::string> dom);
-// static Arabica::DOM::Document<std::string> getStrippedDOM(const Arabica::DOM::Document<std::string> dom);
-
- std::string getRaw() const {
- return raw;
- }
- void setRaw(const std::string& raw) {
- this->raw = raw;
- }
-
- std::string getContent() const {
- return content;
- }
- void setContent(const std::string& content) {
- this->content = content;
- }
-
- std::string getXML() const {
- return xml;
- }
- void setXML(const std::string& xml) {
- this->xml = xml;
- }
-
- std::string getSendId() const {
- return sendid;
- }
- void setSendId(const std::string& sendId) {
- this->sendid = sendId;
- }
-
- std::string getInvokeId() const {
- return invokeid;
- }
- void setInvokeId(const std::string& invokeId) {
- this->invokeid = invokeId;
- }
-
- Data getData() const {
- return data;
- }
- void setData(const Data& data) {
- this->data = data;
- }
-
- static Event fromXML(const std::string& xmlString);
- Arabica::DOM::Document<std::string> toDocument();
- std::string toXMLString();
-
- std::map<std::string, Data>& getNameList() {
- return namelist;
- }
- std::multimap<std::string, Data>& getParams() {
- return params;
- }
-
- void setNameList(const std::map<std::string, Data>& nameList) {
- this->namelist = nameList;
- }
- void setParams(const std::multimap<std::string, Data>& params) {
- this->params = params;
+ operator bool() {
+ return name.size() > 0;
}
typedef std::multimap<std::string, Data> params_t;
@@ -225,7 +134,7 @@ public:
template <typename T> static bool getParam(const params_t& params, const std::string& name, T& target) {
if (params.find(name) != params.end()) {
- target = boost::lexical_cast<T>(params.find(name)->second.atom);
+ target = strTo<T>(params.find(name)->second.atom);
return true;
}
return false;
@@ -252,7 +161,7 @@ public:
if (params.find(name) != params.end()) {
std::pair<params_t::const_iterator, params_t::const_iterator> rangeIter = params.equal_range(name);
while(rangeIter.first != rangeIter.second) {
- target.push_back(boost::lexical_cast<T>(rangeIter.first->second.atom));
+ target.push_back(strTo<T>(rangeIter.first->second.atom));
rangeIter.first++;
}
return true;
@@ -260,31 +169,35 @@ public:
return false;
}
-
-#ifdef SWIGIMPORTED
-protected:
-#endif
-
std::string raw;
- std::string xml;
std::string name;
Type eventType;
std::string origin;
std::string origintype;
- Arabica::DOM::Node<std::string> dom;
std::string sendid;
- bool hideSendId;
+ bool hideSendId; // sendid is assumed to be undef with some ecma tests
std::string invokeid;
Data data;
- std::string content;
std::map<std::string, Data> namelist;
std::multimap<std::string, Data> params;
+ std::string uuid; // the sendid is not necessarily unique!
friend USCXML_API std::ostream& operator<< (std::ostream& os, const Event& event);
};
USCXML_API std::ostream& operator<< (std::ostream& os, const Event& event);
+
+class USCXML_API ErrorEvent : public Event {
+public:
+ ErrorEvent() : Event() {}
+ ErrorEvent(const std::string& msg) : Event("error.platform") {
+ data.compound["msg"] = msg;
+ }
+};
+
}
+
+
#endif /* end of include guard: EVENT_H_6174D929 */