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[])
39 char* tmp = strrchr(argv[0], '/');
40 opt::program_name = (tmp ? tmp + 1 : argv[0]);
44 while ((c = getopt(*argc, argv, "bc:hV")) != -1) {
47 opt::bookkeeping = true;
50 opt::help_requested++;
53 opt::comp_cost = cost_func(optarg);
56 opt::version_requested = true;
59 ERROR1("invalid option -- '%c'", optopt);
64 if (opt::version_requested || opt::help_requested)
67 int rem_args = *argc - optind;
70 ERROR0("missing parameter -- <plaform_file>");
72 ERROR0("missing parameter -- <application_file>");
77 opt::platform_file = argv[optind];
78 opt::application_file = argv[optind + 1];
81 for (int i = optind + 2 ; i < *argc ; ++i)
82 ERROR1("unused parameter -- \"%s\"", argv[i]);
92 INFO0(",----[ Simulation parameters ]");
93 INFO1("| platform_file.......: \"%s\"", opt::platform_file);
94 INFO1("| application_file....: \"%s\"", opt::application_file);
95 INFO1("| bookkeeping.........: %s", on_off(opt::bookkeeping));
96 INFO1("| comp. cost factors..: [%s]", opt::comp_cost.to_string().c_str());
103 const int indent1 = 6;
104 const int indent2 = 12;
106 #define oo(opt, arg) std::setw(indent1) << (opt) << " " \
107 << std::setw(indent2) << std::left << (arg) << std::right
108 #define o(opt) oo(opt, "")
110 std::clog << "Usage: " << opt::program_name
111 << " [options] <platform_file> <application_file>\n";
114 << "print help and exit (use -hh or -hhh for extended help)\n";
115 if (opt::help_requested < 1)
118 std::clog << o("-V") << "print version and exit\n";
119 std::clog << o("-b") << "activate bookkeeping\n";
120 std::clog << oo("-c", "[fn,...]f0")
121 << "polynomial factors for computation cost ("
122 << opt::comp_cost.to_string() << ")\n";