summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-03-28 23:28:46 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-03-28 23:28:46 (GMT)
commit2317f2bf8beb03c60463a9482dbef23540f5c1e0 (patch)
tree9983553e5289cf622e782d0132bb1810276364d2 /apps
parent7279ab2caf72b68126bf0c1d7e62c7d89024f9a0 (diff)
downloaduscxml-2317f2bf8beb03c60463a9482dbef23540f5c1e0.zip
uscxml-2317f2bf8beb03c60463a9482dbef23540f5c1e0.tar.gz
uscxml-2317f2bf8beb03c60463a9482dbef23540f5c1e0.tar.bz2
Refactoring and W3C tests
- Moved core of interpreter to support various versions - Added experimental setConfiguration() - There can be more than one initial state
Diffstat (limited to 'apps')
-rw-r--r--apps/mmi-browser.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/apps/mmi-browser.cpp b/apps/mmi-browser.cpp
index 5127d7b..b62aaee 100644
--- a/apps/mmi-browser.cpp
+++ b/apps/mmi-browser.cpp
@@ -10,11 +10,25 @@
#include "XGetopt.h"
#endif
-#ifdef HAS_SIGNAL_H
-void handler(int s) {
- printf("Caught SIGPIPE ############\n");
-}
-#endif
+class VerboseMonitor : public uscxml::InterpreterMonitor {
+ void onStableConfiguration(uscxml::Interpreter* interpreter) {
+ printConfig(interpreter->getConfiguration());
+ }
+
+ void beforeCompletion(uscxml::Interpreter* interpreter) {
+ printConfig(interpreter->getConfiguration());
+ }
+
+ void printConfig(const Arabica::XPath::NodeSet<std::string>& config) {
+ std::string seperator;
+ std::cout << "Config: {";
+ for (int i = 0; i < config.size(); i++) {
+ std::cout << seperator << ATTR(config[i], "id");
+ seperator = ", ";
+ }
+ std::cout << "}" << std::endl;
+ }
+};
void printUsageAndExit() {
printf("mmi-browser version " USCXML_VERSION " (" CMAKE_BUILD_TYPE " build - " CMAKE_COMPILER_STRING ")\n");
@@ -25,8 +39,9 @@ void printUsageAndExit() {
#endif
printf(" URL\n");
printf("\n");
- // printf("Options\n");
- // printf("\t-l loglevel : loglevel to use\n");
+ printf("Options\n");
+ printf("\t-v : be verbose\n");
+ printf("\n");
exit(1);
}
@@ -34,35 +49,20 @@ int main(int argc, char** argv) {
using namespace uscxml;
#ifdef HAS_SIGNAL_H
- // disable SIGPIPE
-// struct sigaction act;
-// act.sa_handler=SIG_IGN;
-// sigemptyset(&act.sa_mask);
-// act.sa_flags=0;
-// sigaction(SIGPIPE, &act, NULL);
-
- // signal(SIGPIPE, handler);
-
signal(SIGPIPE, SIG_IGN);
-
- // struct sigaction act;
- // int r;
- // memset(&act, 0, sizeof(act));
- // act.sa_handler = SIG_IGN;
- // act.sa_flags = SA_RESTART;
- // r = sigaction(SIGPIPE, &act, NULL);
-
#endif
if (argc < 2) {
printUsageAndExit();
}
+ bool verbose = false;
+
#ifndef _WIN32
opterr = 0;
#endif
int option;
- while ((option = getopt(argc, argv, "l:p:")) != -1) {
+ while ((option = getopt(argc, argv, "vl:p:")) != -1) {
switch(option) {
case 'l':
google::InitGoogleLogging(optarg);
@@ -70,6 +70,9 @@ int main(int argc, char** argv) {
case 'p':
uscxml::Factory::pluginPath = optarg;
break;
+ case 'v':
+ verbose = true;
+ break;
case '?':
break;
default:
@@ -87,9 +90,14 @@ int main(int argc, char** argv) {
interpreter->setCmdLineOptions(argc, argv);
// interpreter->setCapabilities(Interpreter::CAN_NOTHING);
// interpreter->setCapabilities(Interpreter::CAN_BASIC_HTTP | Interpreter::CAN_GENERIC_HTTP);
+
+ if (verbose) {
+ VerboseMonitor* vm = new VerboseMonitor();
+ interpreter->addMonitor(vm);
+ }
+
interpreter->start();
while(interpreter->runOnMainThread(25));
- // interpreter->interpret();
delete interpreter;
}