$treeview $search $mathjax
TraDemGen Logo  1.00.2
$projectbrief
$projectbrief
$searchbox

DemandParserHelper.hpp

Go to the documentation of this file.
00001 #ifndef __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP
00002 #define __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <string>
00009 // STDAIR
00010 #include <stdair/command/CmdAbstract.hpp>
00011 // SEvMgr
00012 #include <sevmgr/SEVMGR_Types.hpp>
00013 // TRADEMGEN
00014 #include <trademgen/TRADEMGEN_Types.hpp>
00015 #include <trademgen/basic/BasParserTypes.hpp>
00016 #include <trademgen/bom/DemandStruct.hpp>
00017 
00018 // Forward declarations
00019 namespace stdair {
00020   struct RandomGeneration;
00021 }
00022 
00023 namespace TRADEMGEN {
00024 
00025   namespace DemandParserHelper {
00026     
00027     // ///////////////////////////////////////////////////////////////////
00028     //  Semantic actions
00029     // ///////////////////////////////////////////////////////////////////
00031     struct ParserSemanticAction {
00033       ParserSemanticAction (DemandStruct&);
00035       DemandStruct& _demand;
00036     };
00037   
00039     struct storePrefDepDateRangeStart : public ParserSemanticAction {
00041       storePrefDepDateRangeStart (DemandStruct&);
00043       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00044     };
00045 
00047     struct storePrefDepDateRangeEnd : public ParserSemanticAction {
00049       storePrefDepDateRangeEnd (DemandStruct&);
00051       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00052     };
00053 
00055     struct storeDow : public ParserSemanticAction {
00057       storeDow (DemandStruct&);
00059       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00060     };
00061 
00063     struct storeOrigin : public ParserSemanticAction {
00065       storeOrigin (DemandStruct&);
00067       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00068     };
00069   
00071     struct storeDestination : public ParserSemanticAction {
00073       storeDestination (DemandStruct&);
00075       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00076     };
00077 
00079     struct storePrefCabin : public ParserSemanticAction {
00081       storePrefCabin (DemandStruct&);
00083       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00084     };
00085 
00087     struct storeDemandMean : public ParserSemanticAction {
00089       storeDemandMean (DemandStruct&);
00091       void operator() (double iReal) const;
00092     };
00093   
00095     struct storeDemandStdDev : public ParserSemanticAction {
00097       storeDemandStdDev (DemandStruct&);
00099       void operator() (double iReal) const;
00100     };
00101   
00103     struct storeDemandChangeFeeProb : public ParserSemanticAction {
00105       storeDemandChangeFeeProb (DemandStruct&);
00107       void operator() (double iReal) const;
00108     };
00109   
00111     struct storeDemandChangeFeeDisutility : public ParserSemanticAction {
00113       storeDemandChangeFeeDisutility (DemandStruct&);
00115       void operator() (double iReal) const;
00116     };
00117   
00119     struct storeDemandNonRefundableProb : public ParserSemanticAction {
00121       storeDemandNonRefundableProb (DemandStruct&);
00123       void operator() (double iReal) const;
00124     };
00125   
00127     struct storeDemandNonRefundableDisutility : public ParserSemanticAction {
00129       storeDemandNonRefundableDisutility (DemandStruct&);
00131       void operator() (double iReal) const;
00132     };
00133   
00135     struct storePosCode : public ParserSemanticAction {
00137       storePosCode (DemandStruct&);
00139       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00140     };
00141   
00143     struct storePosProbMass : public ParserSemanticAction {
00145       storePosProbMass (DemandStruct&);
00147       void operator() (double iReal) const;
00148     };
00149   
00151     struct storeChannelCode : public ParserSemanticAction {
00153       storeChannelCode (DemandStruct&);
00155       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00156     };
00157   
00159     struct storeChannelProbMass : public ParserSemanticAction {
00161       storeChannelProbMass (DemandStruct&);
00163       void operator() (double iReal) const;
00164     };
00165   
00167     struct storeTripCode : public ParserSemanticAction {
00169       storeTripCode (DemandStruct&);
00171       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00172     };
00173   
00175     struct storeTripProbMass : public ParserSemanticAction {
00177       storeTripProbMass (DemandStruct&);
00179       void operator() (double iReal) const;
00180     };
00181   
00183     struct storeStayCode : public ParserSemanticAction {
00185       storeStayCode (DemandStruct&);
00187       void operator() (unsigned int iInteger) const;
00188     };
00189   
00191     struct storeStayProbMass : public ParserSemanticAction {
00193       storeStayProbMass (DemandStruct&);
00195       void operator() (double iReal) const;
00196     };
00197   
00199     struct storeFFCode : public ParserSemanticAction {
00201       storeFFCode (DemandStruct&);
00203       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00204     };
00205   
00207     struct storeFFProbMass : public ParserSemanticAction {
00209       storeFFProbMass (DemandStruct&);
00211       void operator() (double iReal) const;
00212     };
00213   
00216     struct storePrefDepTime : public ParserSemanticAction {
00218       storePrefDepTime (DemandStruct&);
00220       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00221     };    
00222     
00225     struct storePrefDepTimeProbMass : public ParserSemanticAction {
00227       storePrefDepTimeProbMass (DemandStruct&);
00229       void operator() (double iReal) const;
00230     };
00231   
00233     struct storeWTP : public ParserSemanticAction {
00235       storeWTP (DemandStruct&);
00237       void operator() (double iReal) const;
00238     };
00239     
00241     struct storeTimeValue : public ParserSemanticAction {
00243       storeTimeValue (DemandStruct&);
00245       void operator() (double iReal) const;
00246     };
00247   
00249     struct storeTimeValueProbMass : public ParserSemanticAction {
00251       storeTimeValueProbMass (DemandStruct&);
00253       void operator() (double iReal) const;
00254     };
00255   
00258     struct storeDTD : public ParserSemanticAction {
00260       storeDTD (DemandStruct&);
00262       void operator() (unsigned int iInteger) const;
00263     };    
00264     
00267     struct storeDTDProbMass : public ParserSemanticAction {
00269       storeDTDProbMass (DemandStruct&);
00271       void operator() (double iReal) const;
00272     };
00273   
00275     struct doEndDemand : public ParserSemanticAction {
00277       doEndDemand (SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration&,
00278                    const POSProbabilityMass_T&, DemandStruct&);
00280       void operator() (iterator_t iStr, iterator_t iStrEnd) const;
00282       SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr;
00283       stdair::RandomGeneration& _uniformGenerator;
00284       const POSProbabilityMass_T& _posProbabilityMass;
00285     };
00286   
00287 
00289     //
00290     //  (Boost Spirit) Grammar Definition
00291     //
00293 
00384     struct DemandParser : 
00385       public boost::spirit::classic::grammar<DemandParser> {
00386 
00387       DemandParser (SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration&,
00388                     const POSProbabilityMass_T&, DemandStruct&);
00389 
00390       template <typename ScannerT>
00391       struct definition {
00392         definition (DemandParser const& self);
00393         
00394         // Instantiation of rules
00395         boost::spirit::classic::rule<ScannerT> demand_list,
00396           not_to_be_parsed, demand, demand_end, pref_dep_date_range,
00397           date, dow, origin, destination, pref_cabin, demand_params,
00398           pos_dist, pos_pair, pos_code, pos_share,
00399           channel_dist, channel_pair, channel_code, channel_share,
00400           trip_dist, trip_pair, trip_code, trip_share,
00401           stay_dist, stay_pair, stay_share,
00402           ff_dist, ff_pair, ff_code, ff_share,
00403           change_fees,
00404           non_refundable,
00405           pref_dep_time_dist, pref_dep_time_pair, pref_dep_time_share, time,
00406           wtp,
00407           time_value_dist, time_value_pair, time_value_share,
00408           dtd_dist, dtd_pair, dtd_share;
00409 
00411         boost::spirit::classic::rule<ScannerT> const& start() const;
00412       };
00413 
00414       // Parser Context
00415       SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr;
00416       stdair::RandomGeneration& _uniformGenerator;
00417       const POSProbabilityMass_T& _posProbabilityMass;
00418       DemandStruct& _demand;
00419     };
00420 
00421   }
00422 
00423 
00425   //
00426   //  Entry class for the file parser
00427   //
00429 
00434   class DemandFileParser : public stdair::CmdAbstract {
00435   public:
00437     DemandFileParser (SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration&,
00438                       const POSProbabilityMass_T&,
00439                       const stdair::Filename_T& iDemandInputFilename);
00440 
00442     bool generateDemand ();
00443       
00444   private:
00446     void init();
00447       
00448   private:
00449     // Attributes
00451     stdair::Filename_T _filename;
00452 
00454     iterator_t _startIterator;
00455       
00457     iterator_t _endIterator;
00458       
00460     SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr;
00461 
00463     stdair::RandomGeneration& _uniformGenerator;
00464 
00466     const POSProbabilityMass_T& _posProbabilityMass;
00467 
00469     DemandStruct _demand;
00470   };
00471     
00472 }
00473 #endif // __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP