TraDemGen Logo  1.00.0
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
DemandParserHelper.hpp
Go to the documentation of this file.
1 #ifndef __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP
2 #define __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <string>
9 // STDAIR
10 #include <stdair/command/CmdAbstract.hpp>
11 // SEvMgr
12 #include <sevmgr/SEVMGR_Types.hpp>
13 // TRADEMGEN
17 
18 // Forward declarations
19 namespace stdair {
20  struct RandomGeneration;
21 }
22 
23 namespace TRADEMGEN {
24 
25  namespace DemandParserHelper {
26 
27  // ///////////////////////////////////////////////////////////////////
28  // Semantic actions
29  // ///////////////////////////////////////////////////////////////////
36  };
37 
43  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
44  };
45 
51  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
52  };
53 
55  struct storeDow : public ParserSemanticAction {
59  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
60  };
61 
67  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
68  };
69 
75  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
76  };
77 
83  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
84  };
85 
91  void operator() (double iReal) const;
92  };
93 
99  void operator() (double iReal) const;
100  };
101 
107  void operator() (double iReal) const;
108  };
109 
115  void operator() (double iReal) const;
116  };
117 
123  void operator() (double iReal) const;
124  };
125 
131  void operator() (double iReal) const;
132  };
133 
139  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
140  };
141 
147  void operator() (double iReal) const;
148  };
149 
155  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
156  };
157 
163  void operator() (double iReal) const;
164  };
165 
171  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
172  };
173 
179  void operator() (double iReal) const;
180  };
181 
187  void operator() (unsigned int iInteger) const;
188  };
189 
195  void operator() (double iReal) const;
196  };
197 
203  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
204  };
205 
211  void operator() (double iReal) const;
212  };
213 
220  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
221  };
222 
229  void operator() (double iReal) const;
230  };
231 
233  struct storeWTP : public ParserSemanticAction {
237  void operator() (double iReal) const;
238  };
239 
245  void operator() (double iReal) const;
246  };
247 
253  void operator() (double iReal) const;
254  };
255 
258  struct storeDTD : public ParserSemanticAction {
262  void operator() (unsigned int iInteger) const;
263  };
264 
271  void operator() (double iReal) const;
272  };
273 
277  doEndDemand (SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration&,
280  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
282  SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr;
283  stdair::RandomGeneration& _uniformGenerator;
285  };
286 
287 
289  //
290  // (Boost Spirit) Grammar Definition
291  //
293 
384  struct DemandParser :
385  public boost::spirit::classic::grammar<DemandParser> {
386 
387  DemandParser (SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration&,
389 
390  template <typename ScannerT>
391  struct definition {
392  definition (DemandParser const& self);
393 
394  // Instantiation of rules
395  boost::spirit::classic::rule<ScannerT> demand_list,
403  change_fees,
406  wtp,
409 
411  boost::spirit::classic::rule<ScannerT> const& start() const;
412  };
413 
414  // Parser Context
415  SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr;
416  stdair::RandomGeneration& _uniformGenerator;
419  };
420 
421  }
422 
423 
425  //
426  // Entry class for the file parser
427  //
429 
434  class DemandFileParser : public stdair::CmdAbstract {
435  public:
437  DemandFileParser (SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration&,
438  const POSProbabilityMass_T&,
439  const stdair::Filename_T& iDemandInputFilename);
440 
442  bool generateDemand ();
443 
444  private:
446  void init();
447 
448  private:
449  // Attributes
451  stdair::Filename_T _filename;
452 
454  iterator_t _startIterator;
455 
457  iterator_t _endIterator;
458 
460  SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr;
461 
463  stdair::RandomGeneration& _uniformGenerator;
464 
466  const POSProbabilityMass_T& _posProbabilityMass;
467 
469  DemandStruct _demand;
470  };
471 
472 }
473 #endif // __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP