Exemplo n.º 1
0
int	main()
{
	Master master;

	try
	{
		master.init();
		master.run();
	}
	catch (Exception e)
	{
		e.showError();
		master.quit();
		getchar();
	}
	return 0;
}
Exemplo n.º 2
0
int main() {
	Master *m = new Master();
	m->run();

	return 0;
	/*string filename = root + prefixr + "/" + prefixr + "_" + toString(75) + suffix;*/
	/*IplImage *test = cvLoadImage(filename.c_str(), 0);
	cvNamedWindow("img");
	cvShowImage("img", test);
	cvWaitKey(-1);*/
	/*Mat m = imread(filename);
	for (int i = 0; i < 65536; i++) {
		int p = (int)m.at<unsigned char>(i / 256, i % 256);
		if (p != 0)
			cout << p << endl;
	}
	imshow("img", m);
	cvWaitKey(-1);
	system("pause");*/
}
Exemplo n.º 3
0
int main(int argc, char *argv[]) {
	// Library container should be alive during exception catching
	Library::List libraries;

	try {
		// check if all arguments are provided
		if (argc < 2) {
			fprintf(stderr, "GolemInteropLoader <configuration_file>\n");
			return 1;
		}

		/*************************************************************************
		*
		* Initialisation
		*
		**************************************************************************/

		// read config
		std::ifstream ifsconfig(argv[1]);
		if (!ifsconfig.good())
			throw std::runtime_error("golem::interop::GolemInteropLoader: Unable to open: " + std::string(argv[1]));
		boost::property_tree::ptree ptconfig;
		boost::property_tree::read_xml(ifsconfig, ptconfig);

		// extract interface info, load libraries and interfaces
		Interface::Map interfaces;
		Master* master = nullptr;
		BOOST_FOREACH(const boost::property_tree::ptree::value_type& value, ptconfig.get_child("golem.loader")) {
			if (value.first == "library") {
				const Interface::Info info(value.second.get<std::string>("<xmlattr>.library"), value.second.get<std::string>("<xmlattr>.param"));
				if (interfaces.find(info) == interfaces.end()) {
					// load library and create interface
					Interface *pinterface = libraries.insert(info.library)->getInterface(info.param);
					// find Master interface
					if (!master)
						master = Interface::is<Master>(pinterface);
					// update interface container
					interfaces.insert(std::make_pair(info, pinterface));
				}
			}
		}

		if (!master)
			throw std::runtime_error("golem::interop::GolemInteropLoader: No Master interfaces specified: " + std::string(argv[1]));

		/*************************************************************************
		*
		* Run master
		*
		**************************************************************************/

		master->run(interfaces);
	}
	catch (const std::exception& ex) {
		fprintf(stderr, "%s\n", ex.what());
		return 1;
	}
	catch (...) {
		fprintf(stderr, "golem::interop::GolemInteropLoader: unknown exception\n");
		return 1;
	}

	return 0;
}