-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
46 lines (40 loc) · 1.55 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <string>
#include <algorithm>
#include <functional>
#include <csignal>
#include <iostream>
#include "rds/rds.hpp"
#include "io/output.hpp"
#include "io/parameters.hpp"
#include <fstream>
extern const char* gitversion;
std::vector<std::string> get_graphs_names(const std::string& batchname) {
std::ifstream batch(batchname);
std::vector<std::string> result;
std::copy(line_iter{batch}, line_iter{}, std::back_inserter(result));
return result;
}
void main_batch(const std::vector<std::string>& graphs, std::function<algorithm_run(std::string)> solve, std::function<void(const algorithm_run&)> save) {
std::vector<algorithm_run> results;
std::transform(graphs.begin(), graphs.end(), std::back_inserter(results), solve);
std::for_each(results.begin(), results.end(), save);
}
int main(int argc, char* argv[])
{
fprintf(stderr, "Russian-Doll-Search, build %s\n\n", gitversion);
pr_();
if(argc < 2 || std::string(argv[1]) == parameters::PARAM_HELP || std::string(argv[1]) == "-?") {
parameters::show_usage(argv[0]);
return 0;
}
signal(SIGINT, print_lb_atomic);
std::string filename(argv[argc-1]);
auto processor = parameters::parse_args(argc, argv);
std::cerr<<"Parsed processor parameters"<<std::endl;
auto graphs = parameters::parse_is_batch(argc, argv)?
(get_graphs_names(filename)):(std::vector<std::string>{filename});
using namespace std::placeholders;
auto out = std::bind(parameters::parse_to_latex(argc, argv)?(output::latex):(output::fancy), ref(std::cout), _1);
main_batch(graphs, processor, out);
return 0;
}