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/bom/BookingRequestStruct.hpp>
18 #include <stdair/service/Logger.hpp>
21 #include <simfqt/config/simfqt-paths.hpp>
44 template<
class T> std::ostream&
operator<< (std::ostream& os,
45 const std::vector<T>& v) {
46 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
52 stdair::Filename_T& ioFareInputFilename,
53 std::string& ioLogFilename) {
59 boost::program_options::options_description
generic (
"Generic options");
61 (
"prefix",
"print installation prefix")
62 (
"version,v",
"print version string")
63 (
"help,h",
"produce help message");
67 boost::program_options::options_description config (
"Configuration");
70 "The sample BOM tree can be either built-in or parsed from an input file. That latter must then be given with the -f/--fare option")
73 "(CSV) input file for the fare rules")
76 "Filename for the logs")
81 boost::program_options::options_description hidden (
"Hidden options");
84 boost::program_options::value< std::vector<std::string> >(),
85 "Show the copyright (license)");
87 boost::program_options::options_description cmdline_options;
88 cmdline_options.add(
generic).add(config).add(hidden);
90 boost::program_options::options_description config_file_options;
91 config_file_options.add(config).add(hidden);
93 boost::program_options::options_description visible (
"Allowed options");
94 visible.add(
generic).add(config);
96 boost::program_options::positional_options_description p;
97 p.add (
"copyright", -1);
99 boost::program_options::variables_map vm;
100 boost::program_options::
101 store (boost::program_options::command_line_parser (argc, argv).
102 options (cmdline_options).positional(p).run(), vm);
104 std::ifstream ifs (
"simfqt.cfg");
105 boost::program_options::store (parse_config_file (ifs, config_file_options),
107 boost::program_options::notify (vm);
if (vm.count (
"help")) {
108 std::cout << visible << std::endl;
112 if (vm.count (
"version")) {
113 std::cout << PACKAGE_NAME <<
", version " << PACKAGE_VERSION << std::endl;
117 if (vm.count (
"prefix")) {
118 std::cout <<
"Installation prefix: " << PREFIXDIR << std::endl;
122 if (vm.count (
"builtin")) {
125 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
126 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
128 if (ioIsBuiltin ==
false) {
131 if (vm.count (
"fare")) {
132 ioFareInputFilename = vm[
"fare"].as< std::string >();
133 std::cout <<
"Input fare filename is: " << ioFareInputFilename
139 std::cerr <<
"Either one among the -b/--builtin and -f/--fare "
140 <<
"options must be specified" << std::endl;
144 if (vm.count (
"log")) {
145 ioLogFilename = vm[
"log"].as< std::string >();
146 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
154 int main (
int argc,
char* argv[]) {
160 stdair::Filename_T lFareInputFilename;
163 stdair::Filename_T lLogFilename;
166 const int lOptionParserStatus =
174 std::ofstream logOutputFile;
176 logOutputFile.open (lLogFilename.c_str());
177 logOutputFile.clear();
180 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
185 STDAIR_LOG_DEBUG (
"Welcome to Simfqt");
188 stdair::TravelSolutionList_T lTravelSolutionList;
192 stdair::BookingRequestStruct lBookingRequest =
196 if (isBuiltin ==
true) {
210 const std::string& lTSCSVDump =
211 simfqtService.
csvDisplay (lTravelSolutionList);
212 STDAIR_LOG_DEBUG (lTSCSVDump);
215 simfqtService.
quotePrices (lBookingRequest, lTravelSolutionList);
218 const std::string& lBOMCSVDump = simfqtService.
csvDisplay();
219 STDAIR_LOG_DEBUG (
"BOM tree: " << lBOMCSVDump);
222 const std::string& lTSCSVDumpEnd
223 = simfqtService.
csvDisplay (lTravelSolutionList);
224 STDAIR_LOG_DEBUG (lTSCSVDumpEnd);
227 logOutputFile.close();