/* * main.cpp * FAUST - Framework for Adaptive Ubiquitous Scalable Tasks * Website: https://macpro01.cct.lsu.edu/trac/faust * * Created by Ole Weidner on 01/10/09. * Copyright 2008-2009 Center for Computation & Technology. * * Distributed under the Boost Software License, Version 1.0. (See accompanying * LICENSE file or copy at http://www.boost.org/LICENSE_1_0.txt) */ #include #include #include #include #include #include namespace po = boost::program_options; static bool test_mode = false; /////////////////////////////////////////////////////////////////////////////// // bool parse_commandline(int argc, char *argv[], po::variables_map& vm) { po::options_description desc_cmdline ("Usage: "+std::string("faust_agent")+" [options]"); try { desc_cmdline.add_options() ("test, t", "Run tests.") ("help, h", "Display this information and exit.") ("version, v", "Print version information and exit.") ("endpoint, e", po::value(), "Advert endpoint this agent should register with.") ("identifier, i", po::value(), "Unique identifier for this agent.") ; po::positional_options_description p; po::store(po::parse_command_line(argc, argv, desc_cmdline), vm); po::notify(vm); if (vm.count("test")) { std::cout << "Entering test mode" << std::endl; test_mode = true; return true; } if (vm.count("help")) { std::cout << std::endl << desc_cmdline << std::endl; return false; } if (vm.count("version")) { std::cout << std::endl << "FAUST - Framework for Adaptive Ubiquitous Scalable Tasks 0.1" << std::endl; return false; } if (!vm.count("endpoint")) { std::cerr << "Missing endpoint URL: use --endpoint=" << std::endl << std::endl << desc_cmdline << std::endl; return false; } if (!vm.count("identifier")) { std::cerr << "Missing unique identifier: use --identifier=" << std::endl << std::endl << desc_cmdline << std::endl; return false; } } catch (std::exception const& e) { std::cerr << std::endl << e.what() << std::endl << std::endl << desc_cmdline << std::endl; return false; } return true; } /////////////////////////////////////////////////////////////////////////////// // int main( int argc, char** argv ) { using namespace faust::agent; po::variables_map vm; if (!parse_commandline(argc, argv, vm)) return -2; // extract command line arguments std::string endpoint (vm["endpoint"].as()); std::string identifier (vm["identifier"].as()); // main application loop app faust_agent(endpoint, identifier); if(test_mode) { faust_agent.run_tests(); return 0; } else { faust_agent.run(); } return 0; }