int main(int argc, char **argv) { Args args(argc, argv, "DRIVER FILE"); DebugReplay *replay = CreateDebugReplay(args); if (replay == NULL) return EXIT_FAILURE; args.ExpectEnd(); Result result; Run(*replay, result); delete replay; const ContestStatistics olc_plus = SolveContest(Contest::OLC_PLUS); const ContestStatistics dmst = SolveContest(Contest::DMST); TextWriter writer("/dev/stdout", true); { JSON::ObjectWriter root(writer); WriteResult(root, result); root.WriteElement("phases", WritePhaseList, flight_phase_detector.GetPhases()); root.WriteElement("performance", WritePerformanceStats, flight_phase_detector.GetTotals()); root.WriteElement("contests", WriteContests, olc_plus, dmst); } }
int main(int argc, char **argv) { unsigned full_max_points = 512, triangle_max_points = 1024, sprint_max_points = 64; Args args(argc, argv, "[options] DRIVER FILE\n" "Options:\n" " --full-points=512 Maximum number of full trace points (default = 512)\n" " --triangle-points=1024 Maximum number of triangle trace points (default = 1024)\n" " --sprint-points=64 Maximum number of sprint trace points (default = 64)"); const char *arg; while ((arg = args.PeekNext()) != nullptr && *arg == '-') { args.Skip(); const char *value; if ((value = StringAfterPrefix(arg, "--full-points=")) != nullptr) { unsigned _points = strtol(value, NULL, 10); if (_points > 0) full_max_points = _points; else { fputs("The start parameter could not be parsed correctly.\n", stderr); args.UsageError(); } } else if ((value = StringAfterPrefix(arg, "--triangle-points=")) != nullptr) { unsigned _points = strtol(value, NULL, 10); if (_points > 0) triangle_max_points = _points; else { fputs("The start parameter could not be parsed correctly.\n", stderr); args.UsageError(); } } else if ((value = StringAfterPrefix(arg, "--sprint-points=")) != nullptr) { unsigned _points = strtol(value, NULL, 10); if (_points > 0) sprint_max_points = _points; else { fputs("The start parameter could not be parsed correctly.\n", stderr); args.UsageError(); } } else { args.UsageError(); } } DebugReplay *replay = CreateDebugReplay(args); if (replay == NULL) return EXIT_FAILURE; args.ExpectEnd(); static Trace full_trace(0, Trace::null_time, full_max_points); static Trace triangle_trace(0, Trace::null_time, triangle_max_points); static Trace sprint_trace(0, 9000, sprint_max_points); Result result; Run(*replay, result, full_trace, triangle_trace, sprint_trace); delete replay; const ContestStatistics olc_plus = SolveContest(Contest::OLC_PLUS, full_trace, triangle_trace, sprint_trace); const ContestStatistics dmst = SolveContest(Contest::DMST, full_trace, triangle_trace, sprint_trace); TextWriter writer("/dev/stdout", true); { JSON::ObjectWriter root(writer); WriteResult(root, result); root.WriteElement("phases", WritePhaseList, flight_phase_detector.GetPhases()); root.WriteElement("performance", WritePerformanceStats, flight_phase_detector.GetTotals()); root.WriteElement("contests", WriteContests, olc_plus, dmst); } }