10 #include <boost/date_time/posix_time/posix_time.hpp>
11 #include <boost/date_time/gregorian/gregorian.hpp>
12 #include <boost/tokenizer.hpp>
13 #include <boost/program_options.hpp>
15 #include <stdair/STDAIR_Service.hpp>
16 #include <stdair/bom/TravelSolutionStruct.hpp>
17 #include <stdair/service/Logger.hpp>
20 #include <airrac/config/airrac-paths.hpp>
43 template<
class T> std::ostream&
operator<< (std::ostream& os,
44 const std::vector<T>& v) {
45 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
51 stdair::Filename_T& ioYieldInputFilename,
52 std::string& ioLogFilename) {
58 boost::program_options::options_description
generic (
"Generic options");
60 (
"prefix",
"print installation prefix")
61 (
"version,v",
"print version string")
62 (
"help,h",
"produce help message");
66 boost::program_options::options_description config (
"Configuration");
69 "The sample BOM tree can be either built-in or parsed from an input file. That latter must then be given with the -y/--yield option")
72 "(CSV) input file for the yield rules")
75 "Filename for the logs")
80 boost::program_options::options_description hidden (
"Hidden options");
83 boost::program_options::value< std::vector<std::string> >(),
84 "Show the copyright (license)");
86 boost::program_options::options_description cmdline_options;
87 cmdline_options.add(
generic).add(config).add(hidden);
89 boost::program_options::options_description config_file_options;
90 config_file_options.add(config).add(hidden);
92 boost::program_options::options_description visible (
"Allowed options");
93 visible.add(
generic).add(config);
95 boost::program_options::positional_options_description p;
96 p.add (
"copyright", -1);
98 boost::program_options::variables_map vm;
99 boost::program_options::
100 store (boost::program_options::command_line_parser (argc, argv).
101 options (cmdline_options).positional(p).run(), vm);
103 std::ifstream ifs (
"airrac.cfg");
104 boost::program_options::store (parse_config_file (ifs, config_file_options),
106 boost::program_options::notify (vm);
if (vm.count (
"help")) {
107 std::cout << visible << std::endl;
111 if (vm.count (
"version")) {
112 std::cout << PACKAGE_NAME <<
", version " << PACKAGE_VERSION << std::endl;
116 if (vm.count (
"prefix")) {
117 std::cout <<
"Installation prefix: " << PREFIXDIR << std::endl;
121 if (vm.count (
"builtin")) {
124 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
125 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
127 if (ioIsBuiltin ==
false) {
130 if (vm.count (
"yield")) {
131 ioYieldInputFilename = vm[
"yield"].as< std::string >();
132 std::cout <<
"Input yield filename is: " << ioYieldInputFilename
138 std::cerr <<
"Either one among the -b/--builtin and -y/--yield "
139 <<
"options must be specified" << std::endl;
143 if (vm.count (
"log")) {
144 ioLogFilename = vm[
"log"].as< std::string >();
145 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
153 int main (
int argc,
char* argv[]) {
159 stdair::Filename_T lYieldInputFilename;
162 stdair::Filename_T lLogFilename;
165 const int lOptionParserStatus =
173 std::ofstream logOutputFile;
175 logOutputFile.open (lLogFilename.c_str());
176 logOutputFile.clear();
179 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
184 STDAIR_LOG_DEBUG (
"Welcome to AirRAC");
187 stdair::TravelSolutionList_T lTravelSolutionList;
191 if (isBuiltin ==
true) {
205 const std::string& lBOMCSVDump = airracService.
csvDisplay();
206 STDAIR_LOG_DEBUG (
"BOM tree: " << lBOMCSVDump);
209 const std::string& lTSCSVDump =
210 airracService.
csvDisplay (lTravelSolutionList);
211 STDAIR_LOG_DEBUG (lTSCSVDump);
214 logOutputFile.close();