当前位置: 首页>>代码示例>>C++>>正文


C++ Interpreter::addMonitor方法代码示例

本文整理汇总了C++中Interpreter::addMonitor方法的典型用法代码示例。如果您正苦于以下问题:C++ Interpreter::addMonitor方法的具体用法?C++ Interpreter::addMonitor怎么用?C++ Interpreter::addMonitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Interpreter的用法示例。


在下文中一共展示了Interpreter::addMonitor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv) {
	size_t iterations = 1;

	std::string documentURI;
//	el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%datetime %level %fbase:%line: %msg");

	if (argc < 2) {
		exit(EXIT_FAILURE);
	}

	int option;
	while ((option = getopt(argc, argv, "n:")) != -1) {
		switch(option) {
		case 'n':
			iterations = strTo<size_t>(optarg);
			break;
		default:
			break;
		}
	}

	documentURI = argv[optind];

	HTTPServer::getInstance(7080, 7443);

	while(iterations--) {
		try {
			Interpreter interpreter = Interpreter::fromURL(documentURI);

//			ActionLanguage al;
//			al.execContent = std::shared_ptr<ContentExecutorImpl>(new ContentExecutorBasic(interpreter.getImpl().get()));
//			interpreter.setActionLanguage(al);

			StateTransitionMonitor mon;
			interpreter.addMonitor(&mon);

			InterpreterState state = InterpreterState::USCXML_UNDEF;
			while(state != USCXML_FINISHED) {
				state = interpreter.step();
			}
			assert(interpreter.isInState("pass"));
		} catch (Event e) {
			std::cerr << "Thrown Event out of Interpreter: " << e;
			return EXIT_FAILURE;
		}
	}

	return 0;
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例2: main

int main(int argc, char** argv) {
	using namespace uscxml;

	std::set_terminate(customTerminate);

#if defined(HAS_SIGNAL_H) && !defined(WIN32)
	signal(SIGPIPE, SIG_IGN);
#endif

	if (argc < 2) {
		exit(EXIT_FAILURE);
	}

	HTTPServer::getInstance(32954, 32955, NULL); // bind to some random tcp sockets for ioprocessor tests

	google::InitGoogleLogging(argv[0]);
	google::LogToStderr();

//  for (int i = 0; i < argc; i++)
//    std::cout << argv[i] << std::endl;
//  std::cout << optind << std::endl;

	LOG(INFO) << "Processing " << argv[1];
	Interpreter interpreter = Interpreter::fromURI(argv[1]);
	if (interpreter) {
//		interpreter.setCmdLineOptions(argc, argv);
//		interpreter->setCapabilities(Interpreter::CAN_NOTHING);
//		interpreter->setCapabilities(Interpreter::CAN_BASIC_HTTP | Interpreter::CAN_GENERIC_HTTP);

		W3CStatusMonitor* vm = new W3CStatusMonitor();
		interpreter.addMonitor(vm);

//		if (interpreter.getDataModel().getNames().find("ecmascript") != interpreter.getDataModel().getNames().end()) {
//		}

		interpreter.start();
		while(interpreter.runOnMainThread(25));
	}

	return EXIT_SUCCESS;
}
开发者ID:enricop,项目名称:uscxml,代码行数:41,代码来源:test-w3c.cpp

示例3: main

int main(int argc, char** argv) {
	using namespace uscxml;

	std::set_terminate(customTerminate);

#if defined(HAS_SIGNAL_H) && !defined(WIN32)
	signal(SIGPIPE, SIG_IGN);
#endif

	if (argc < 2) {
		printUsageAndExit();
	}

	google::InitGoogleLogging(argv[0]);
	google::LogToStderr();

	HTTPServer::getInstance(8088, 8089);
#ifndef _WIN32
	opterr = 0;
#endif
	int option;
	while ((option = getopt(argc, argv, "vl:p:")) != -1) {
		switch(option) {
		case 'l':
			google::InitGoogleLogging(optarg);
			break;
		case 'p':
			uscxml::Factory::setDefaultPluginPath(optarg);
			break;
		case '?':
			break;
		default:
			printUsageAndExit();
			break;
		}
	}

#if 0
	while(true) {
		Interpreter interpreter = Interpreter::fromURI("/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/ecma/test235.scxml");
		interpreter.interpret();
	}
#else

	DirectoryWatch* watcher = new DirectoryWatch(argv[optind], true);
	watcher->updateEntries(true);
	std::map<std::string, struct stat> entries = watcher->getAllEntries();

	StatusMonitor vm;

	std::map<std::string, struct stat>::iterator entryIter = entries.begin();
	while(entryIter != entries.end()) {
		if (!boost::ends_with(entryIter->first, ".scxml")) {
			entryIter++;
			continue;
		}

		startedAt = time(NULL);
		lastTransitionAt = time(NULL);

		LOG(INFO) << "Processing " << entryIter->first;
		Interpreter interpreter = Interpreter::fromURL(std::string(argv[optind]) + PATH_SEPERATOR + entryIter->first);
		if (interpreter) {
//			interpreter.setCmdLineOptions(argc, argv);

			interpreter.addMonitor(&vm);

			interpreter.start();
			int now = time(NULL);
			while(now - startedAt < 20 && now - lastTransitionAt < 2) {
				// let the interpreter run for a bit
				tthread::this_thread::sleep_for(tthread::chrono::seconds(1));
				now = time(NULL);
			}

		}
		entryIter++;
	}

	delete watcher;
#endif
	return EXIT_SUCCESS;
}
开发者ID:su6838354,项目名称:uscxml,代码行数:83,代码来源:test-stress.cpp

示例4: main

int main(int argc, char** argv) {

	google::InitGoogleLogging(argv[0]);
	google::LogToStderr();

	int iterations = 1;

	while(iterations--) {

		if (1) {
			// Potential endless loop

			const char* xml =
			    "<scxml datamodel=\"ecmascript\">"
			    "	<datamodel><data id=\"counter\" expr=\"5\" /></datamodel>"
			    "	<state id=\"foo\">"
			    "		<onentry><script>counter--;</script></onentry>"
			    "		<transition target=\"foo\" cond=\"counter > 0\" />"
			    "		<transition target=\"bar\" cond=\"counter == 0\" />"
			    " </state>"
			    "	<state id=\"bar\" final=\"true\" />"
			    "</scxml>";

			IssueMonitor monitor;
			Interpreter interpreter = Interpreter::fromXML(xml, "");
			interpreter.addMonitor(&monitor);
			interpreter.interpret();

			// first reiteration is not counted as it might be valid when raising internal errors
			assert(runtimeIssues == 3);
		}

		if (1) {
			// Unreachable states 1

			const char* xml =
			    "<scxml datamodel=\"ecmascript\">"
			    "	<state id=\"foo\">"
			    "		<parallel id=\"foz\">"
			    "			<state id=\"s0\" />"
			    "			<state id=\"s1\" />"
			    "			<state id=\"s2\" />"
			    "		</parallel>"
			    " </state>"
			    "	<state id=\"bar\" />"
			    "</scxml>";

			std::set<std::string> issueLocations = issueLocationsForXML(xml);
			assert(issueLocations.find("//state[@id=\"bar\"]") != issueLocations.end());
			assert(issueLocations.size() == 1);
		}

		if (1) {
			// Invalid parents
			const char* xml =
			    "<scxml datamodel=\"ecmascript\">"
			    "		<onentry>"
			    "			<cancel sendidexpr=\"foo\" />"
			    "		</onentry>"
			    "</scxml>";

			std::set<std::string> issueLocations = issueLocationsForXML(xml);
			assert(issueLocations.find("/scxml[1]/onentry[1]") != issueLocations.end());
			assert(issueLocations.size() == 1);
		}

		if (0) {
			// State has no 'id' attribute
            // *** This is not actually an error! ***
			const char* xml =
			    "<scxml datamodel=\"ecmascript\">"
			    "	<state>"
			    "		<transition/>"
			    " </state>"
			    "</scxml>";

			std::set<std::string> issueLocations = issueLocationsForXML(xml);
			assert(issueLocations.find("/scxml[1]/state[1]") != issueLocations.end());
			assert(issueLocations.size() == 1);
		}

		if (1) {
			// Duplicate state with id
			const char* xml =
			    "<scxml datamodel=\"ecmascript\">"
			    "	<state id=\"start\" />"
			    " <state id=\"start\" />"
			    "</scxml>";

			std::set<std::string> issueLocations = issueLocationsForXML(xml);
			assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end());
			assert(issueLocations.size() == 1);
		}

		if (1) {
			// Transition has non-existant target state

			const char* xml =
			    "<scxml datamodel=\"ecmascript\">"
			    "	<state id=\"start\">"
//.........这里部分代码省略.........
开发者ID:sradomski,项目名称:uscxml,代码行数:101,代码来源:test-issue-reporting.cpp


注:本文中的Interpreter::addMonitor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。