8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu);
12 const char* program_name;
14 const char* platform_file;
15 const char* application_file;
17 int help_requested = 0;
18 bool version_requested = false;
20 bool bookkeeping = false;
22 cost_func comp_cost("1e9, 0"); // fixme: find better defaults
28 const char* on_off(bool b)
30 return b ? "on" : "off";
35 int opt::parse_args(int* argc, char* argv[])
37 char* tmp = strrchr(argv[0], '/');
38 opt::program_name = (tmp ? tmp + 1 : argv[0]);
42 while ((c = getopt(*argc, argv, "bc:hV")) != -1) {
45 opt::bookkeeping = true;
48 opt::help_requested++;
51 opt::comp_cost = cost_func(optarg);
54 opt::version_requested = true;
57 WARN1("invalid option -- '%c'", optopt);
61 if (opt::version_requested || opt::help_requested)
64 switch (*argc - optind) {
66 ERROR0("missing parameter -- <plaform_file>");
68 ERROR0("missing parameter -- <application_file>");
72 opt::platform_file = argv[optind];
73 opt::application_file = argv[optind + 1];
74 for (int i = optind + 2 ; i < *argc ; ++i)
75 WARN1("unused parameter -- \"%s\"", argv[i]);
84 INFO0(",----[ Simulation parameters ]");
85 INFO1("| platform_file.......: \"%s\"", opt::platform_file);
86 INFO1("| application_file....: \"%s\"", opt::application_file);
87 INFO1("| bookkeeping.........: %s", on_off(opt::bookkeeping));
88 INFO1("| comp. cost factors..: [%s]", opt::comp_cost.to_string().c_str());
95 const int indent1 = 6;
96 const int indent2 = 12;
98 #define oo(opt, arg) std::setw(indent1) << (opt) << " " \
99 << std::setw(indent2) << std::left << (arg) << std::right
100 #define o(opt) oo(opt, "")
102 std::clog << "Usage: " << opt::program_name
103 << " [options] <platform_file> <application_file>\n";
106 << "print help and exit (use -hh or -hhh for extended help)\n";
107 if (opt::help_requested < 1)
109 std::clog << o("-V") << "print version and exit\n";
110 std::clog << o("-b") << "activate bookkeeping\n";
111 std::clog << oo("-c", "[fn,...]f0")
112 << "polynomial factors for computation cost ("
113 << opt::comp_cost.to_string() << ")\n";