TraDemGen Logo  0.2.2
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros 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 // TRADEMGEN
15 
16 // Forward declarations
17 namespace stdair {
18  class EventQueue;
19  struct RandomGeneration;
20 }
21 
22 namespace TRADEMGEN {
23 
24  namespace DemandParserHelper {
25 
26  // ///////////////////////////////////////////////////////////////////
27  // Semantic actions
28  // ///////////////////////////////////////////////////////////////////
35  };
36 
42  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
43  };
44 
50  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
51  };
52 
54  struct storeDow : public ParserSemanticAction {
58  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
59  };
60 
66  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
67  };
68 
74  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
75  };
76 
82  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
83  };
84 
90  void operator() (double iReal) const;
91  };
92 
98  void operator() (double iReal) const;
99  };
100 
106  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
107  };
108 
114  void operator() (double iReal) const;
115  };
116 
122  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
123  };
124 
130  void operator() (double iReal) const;
131  };
132 
138  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
139  };
140 
146  void operator() (double iReal) const;
147  };
148 
154  void operator() (unsigned int iInteger) const;
155  };
156 
162  void operator() (double iReal) const;
163  };
164 
170  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
171  };
172 
178  void operator() (double iReal) const;
179  };
180 
187  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
188  };
189 
196  void operator() (double iReal) const;
197  };
198 
200  struct storeWTP : public ParserSemanticAction {
204  void operator() (double iReal) const;
205  };
206 
212  void operator() (double iReal) const;
213  };
214 
220  void operator() (double iReal) const;
221  };
222 
225  struct storeDTD : public ParserSemanticAction {
229  void operator() (unsigned int iInteger) const;
230  };
231 
238  void operator() (double iReal) const;
239  };
240 
244  doEndDemand (stdair::EventQueue&, stdair::RandomGeneration&,
247  void operator() (iterator_t iStr, iterator_t iStrEnd) const;
249  stdair::EventQueue& _eventQueue;
250  stdair::RandomGeneration& _uniformGenerator;
252  };
253 
254 
256  //
257  // (Boost Spirit) Grammar Definition
258  //
260 
345  struct DemandParser :
346  public boost::spirit::classic::grammar<DemandParser> {
347 
348  DemandParser (stdair::EventQueue&, stdair::RandomGeneration&,
350 
351  template <typename ScannerT>
352  struct definition {
353  definition (DemandParser const& self);
354 
355  // Instantiation of rules
356  boost::spirit::classic::rule<ScannerT> demand_list,
365  wtp,
368 
370  boost::spirit::classic::rule<ScannerT> const& start() const;
371  };
372 
373  // Parser Context
374  stdair::EventQueue& _eventQueue;
375  stdair::RandomGeneration& _uniformGenerator;
378  };
379 
380  }
381 
382 
384  //
385  // Entry class for the file parser
386  //
388 
393  class DemandFileParser : public stdair::CmdAbstract {
394  public:
396  DemandFileParser (stdair::EventQueue&, stdair::RandomGeneration&,
397  const POSProbabilityMass_T&,
398  const stdair::Filename_T& iDemandInputFilename);
399 
401  bool generateDemand ();
402 
403  private:
405  void init();
406 
407  private:
408  // Attributes
410  stdair::Filename_T _filename;
411 
413  iterator_t _startIterator;
414 
416  iterator_t _endIterator;
417 
419  stdair::EventQueue& _eventQueue;
420 
422  stdair::RandomGeneration& _uniformGenerator;
423 
425  const POSProbabilityMass_T& _posProbabilityMass;
426 
428  DemandStruct _demand;
429  };
430 
431 }
432 #endif // __TRADEMGEN_CMD_DEMANDPARSERHELPER_HPP