TraDemGen Logo  0.2.2
C++ Simulated Travel Demand Generation Library
DemandParser.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 // StdAir
00007 #include <stdair/basic/BasFileMgr.hpp>
00008 #include <stdair/basic/RandomGeneration.hpp>
00009 #include <stdair/bom/Inventory.hpp>
00010 // TraDemGen
00011 #include <trademgen/command/DemandParserHelper.hpp>
00012 #include <trademgen/command/DemandParser.hpp>
00013 
00014 namespace TRADEMGEN {
00015 
00016   // //////////////////////////////////////////////////////////////////////
00017   void DemandParser::
00018   generateDemand (const stdair::Filename_T& iFilename,
00019                   stdair::EventQueue& ioEventQueue,
00020                   stdair::RandomGeneration& ioSharedGenerator,
00021                   const POSProbabilityMass_T& iDefaultPOSProbablityMass) {
00022 
00023     // Check that the file path given as input corresponds to an actual file
00024     const bool doesExistAndIsReadable =
00025       stdair::BasFileMgr::doesExistAndIsReadable (iFilename);
00026     if (doesExistAndIsReadable == false) {
00027       STDAIR_LOG_ERROR ("The demand input file '" << iFilename
00028                         << "' does not exist or can not be read");
00029       
00030       throw DemandInputFileNotFoundException ("The demand file '" + iFilename
00031                                               + "' does not exist or can not "
00032                                               "be read");
00033     }
00034 
00035     // Initialise the demand file parser.
00036     DemandFileParser lDemandParser (ioEventQueue, ioSharedGenerator,
00037                                     iDefaultPOSProbablityMass, iFilename);
00038 
00039     // Parse the CSV-formatted demand input file, and generate the
00040     // corresponding DemandCharacteristic objects.
00041     lDemandParser.generateDemand();
00042   }
00043 
00044 }