StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventQueue.hpp
Go to the documentation of this file.
1 #ifndef __STDAIR_BOM_EVENTQUEUE_HPP
2 #define __STDAIR_BOM_EVENTQUEUE_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iosfwd>
9 #include <string>
10 // StdAir
18 
19 namespace stdair {
20 
59  class EventQueue : public BomAbstract {
60  template <typename BOM> friend class FacBom;
61  friend class FacBomManager;
62 
63  public:
64  // ////////// Type definitions ////////////
69 
75  typedef std::map<EventType::EN_EventType,
77 
78 
79  public:
80  // /////////// Getters ///////////////
82  const Key_T& getKey() const {
83  return _key;
84  }
85 
87  BomAbstract* const getParent() const {
88  return _parent;
89  }
90 
92  const HolderMap_T& getHolderMap() const {
93  return _holderMap;
94  }
95 
97  const ProgressStatus& getStatus() const {
98  return _progressStatus;
99  }
101  const Count_T& getCurrentNbOfEvents() const {
102  return _progressStatus.getCurrentNb();
103  }
107  }
110  return _progressStatus.getActualNb();
111  }
112 
118 
121 
124 
127 
128  public:
129  // /////////// Setters ///////////////
131  void setStatus (const ProgressStatus& iProgressStatus) {
132  _progressStatus = iProgressStatus;
133  }
135  void setStatus (const Count_T& iCurrentNbOfEvents,
136  const Count_T& iExpectedTotalNbOfEvents,
137  const Count_T& iActualTotalNbOfEvents) {
138  _progressStatus.setCurrentNb (iCurrentNbOfEvents);
139  _progressStatus.setExpectedNb (iExpectedTotalNbOfEvents);
140  _progressStatus.setActualNb (iActualTotalNbOfEvents);
141  }
143  void setStatus (const Count_T& iCurrentNbOfEvents,
144  const Count_T& iActualTotalNbOfEvents) {
145  _progressStatus.setCurrentNb (iCurrentNbOfEvents);
146  _progressStatus.setActualNb (iActualTotalNbOfEvents);
147  }
149  void setCurrentNbOfEvents (const Count_T& iCurrentNbOfEvents) {
150  _progressStatus.setCurrentNb (iCurrentNbOfEvents);
151  }
153  void setExpectedTotalNbOfEvents (const Count_T& iExpectedTotalNbOfEvents) {
154  _progressStatus.setExpectedNb (iExpectedTotalNbOfEvents);
155  }
157  void setActualTotalNbOfEvents (const Count_T& iActualTotalNbOfEvents) {
158  _progressStatus.setActualNb (iActualTotalNbOfEvents);
159  }
160 
165  void setStatus (const EventType::EN_EventType& iType,
166  const ProgressStatus& iProgressStatus);
167 
168 
169  public:
170  // /////////// Display support methods /////////
176  void toStream (std::ostream& ioOut) const {
177  ioOut << toString();
178  }
179 
185  void fromStream (std::istream& ioIn) {
186  }
187 
191  std::string toString() const;
192 
196  const std::string describeKey() const {
197  return _key.toString();
198  }
199 
200  /*
201  * Display the full content of the event queue, with all its
202  * demand streams.
203  *
204  * That method can be very consuming (in time, CPU and memory)
205  * when there are a lot of demand streams (e.g., several hundreds
206  * of thousands). Call it only for debug purposes.
207  */
208  std::string display() const;
209 
210 
211  public:
212  // ////////// Business methods /////////
217  void reset();
218 
233 
254  bool addEvent (EventStruct&);
255 
261  bool isQueueDone() const;
262 
276  void addStatus (const EventType::EN_EventType&,
277  const NbOfRequests_T& iExpectedTotalNbOfEvents);
278 
288  const ProgressStatus& iProgressStatus);
289 
304  const NbOfEvents_T& iActualTotalNbOfEvents);
305 
317  return _progressStatus.progress();
318  }
319 
331 
332 
333  public:
334  // ////////// Debug methods /////////
336  Count_T getQueueSize() const;
337 
339  bool isQueueEmpty() const;
340 
341 
342  protected:
343  // ////////// Constructors and destructors /////////
345  EventQueue (const Key_T&);
347  EventQueue (const EventQueue&);
349  ~EventQueue();
350  private:
352  EventQueue();
353 
354 
355  protected:
356  // ////////// Attributes /////////
361 
366 
373 
378 
383 
390  };
391 
392 }
393 #endif // __STDAIR_BOM_EVENTQUEUE_HPP