summaryrefslogtreecommitdiffstats
path: root/examples/cpp/library/lambdas/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cpp/library/lambdas/main.cpp')
-rw-r--r--examples/cpp/library/lambdas/main.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/examples/cpp/library/lambdas/main.cpp b/examples/cpp/library/lambdas/main.cpp
index 316576b..33440fb 100644
--- a/examples/cpp/library/lambdas/main.cpp
+++ b/examples/cpp/library/lambdas/main.cpp
@@ -3,13 +3,39 @@
int main(int argc, char *argv[])
{
- if (argc < 2) {
- std::cerr << "Expected URL with SCXML document as first argument" << std::endl;
- return -1;
- }
+ std::string scxmlURL("https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/w3c/null/test436.scxml");
- uscxml::Interpreter sc = uscxml::Interpreter::fromURL(argv[1]);
+ uscxml::Interpreter sc = uscxml::Interpreter::fromURL(scxmlURL);
uscxml::InterpreterState state;
+
+ sc.on().enterState([](const std::string& sessionId,
+ const std::string& stateName,
+ const xercesc_3_1::DOMElement* state) {
+ std::cout << "Entered " << stateName << std::endl;
+ });
+
+ sc.on().exitState([](const std::string& sessionId,
+ const std::string& stateName,
+ const xercesc_3_1::DOMElement* state) {
+ std::cout << "Exited " << stateName << std::endl;
+ });
+
+ sc.on().transition([](const std::string& sessionId,
+ const std::string& targetList,
+ const xercesc_3_1::DOMElement* transition) {
+ std::cout << "Transition to " << targetList << std::endl;
+ });
+
+ sc.on().completion([](const std::string& sessionId){
+ std::cout << "Completed!" << std::endl;
+ });
+
+ sc.on().executeContent([](const std::string& sessionId,
+ const xercesc_3_1::DOMElement* element){
+ std::cout << "Executing content" << std::endl;
+
+ });
+
while ((state = sc.step()) != uscxml::USCXML_FINISHED) {
}