9 #include <stdair/stdair_inventory_types.hpp>
10 #include <stdair/stdair_maths_types.hpp>
11 #include <stdair/stdair_exceptions.hpp>
12 #include <stdair/basic/BasConst_DefaultObject.hpp>
13 #include <stdair/basic/BasConst_Inventory.hpp>
14 #include <stdair/basic/BasFileMgr.hpp>
15 #include <stdair/bom/BomRetriever.hpp>
16 #include <stdair/bom/BomManager.hpp>
17 #include <stdair/bom/BomRoot.hpp>
18 #include <stdair/bom/Inventory.hpp>
19 #include <stdair/bom/FlightDate.hpp>
20 #include <stdair/bom/SegmentDate.hpp>
21 #include <stdair/bom/SegmentCabin.hpp>
22 #include <stdair/bom/LegDate.hpp>
23 #include <stdair/bom/LegCabin.hpp>
24 #include <stdair/bom/BookingClass.hpp>
25 #include <stdair/bom/VirtualClassStruct.hpp>
26 #include <stdair/factory/FacBom.hpp>
27 #include <stdair/factory/FacBomManager.hpp>
28 #include <stdair/service/Logger.hpp>
37 stdair::BomRoot& ioBomRoot) {
38 bool hasReadBeenSuccessful =
false;
41 const bool doesExistAndIsReadable =
42 stdair::BasFileMgr::doesExistAndIsReadable (iInputFileName);
43 if (doesExistAndIsReadable ==
false) {
44 std::ostringstream oMessage;
45 oMessage <<
"The input file, '" << iInputFileName
46 <<
"', can not be retrieved on the file-system";
47 throw stdair::FileNotFoundException (oMessage.str());
51 stdair::LegCabin& lLegCabin =
52 stdair::BomRetriever::retrieveDummyLegCabin (ioBomRoot);
55 stdair::SegmentCabin& lSegmentCabin =
56 stdair::BomRetriever::retrieveDummySegmentCabin (ioBomRoot);
59 std::ifstream inputFile (iInputFileName.c_str());
61 STDAIR_LOG_ERROR (
"Can not open input file '" << iInputFileName <<
"'");
62 throw new stdair::FileNotFoundException (
"Can not open input file '"
63 + iInputFileName +
"'");
69 bool hasAllPArams =
true;
70 stdair::Yield_T lYield;
71 stdair::MeanValue_T lMean;
72 stdair::StdDevValue_T lStdDev;
73 stdair::BookingClassKey lBCKey (stdair::DEFAULT_CLASS_CODE);
75 while (inputFile.getline (buffer, sizeof (buffer),
';')) {
76 std::istringstream iStringStr (buffer);
82 if (iStringStr >> dval) {
102 if (hasAllPArams && i == 1) {
103 stdair::BookingClass& lBookingClass =
104 stdair::FacBom<stdair::BookingClass>::instance().create (lBCKey);
105 stdair::FacBomManager::addToList (lSegmentCabin, lBookingClass);
106 lBookingClass.setYield (lYield);
107 lBookingClass.setMean (lMean);
108 lBookingClass.setStdDev (lStdDev);
109 stdair::BookingClassList_T lBookingClassList;
110 lBookingClassList.push_back(&lBookingClass);
111 stdair::VirtualClassStruct lVirtualClass (lBookingClassList);
112 lVirtualClass.setYield (lYield);
113 lVirtualClass.setMean (lMean);
114 lVirtualClass.setStdDev (lStdDev);
115 lLegCabin.addVirtualClass (lVirtualClass);
120 if (!inputFile.eof()) {
121 STDAIR_LOG_ERROR (
"Problem when reading input file '" << iInputFileName
123 return hasReadBeenSuccessful;
127 hasReadBeenSuccessful =
true;
128 return hasReadBeenSuccessful;