SEvMgr Logo  1.00.0
C++ Simulation-Oriented Discrete Event Management Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
EventQueue.hpp
Go to the documentation of this file.
1 #ifndef __SEVMGR_BOM_EVENTQUEUE_HPP
2 #define __SEVMGR_BOM_EVENTQUEUE_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iosfwd>
9 #include <string>
10 // StdAir
11 #include <stdair/stdair_basic_types.hpp>
12 #include <stdair/stdair_date_time_types.hpp>
13 #include <stdair/basic/ProgressStatusSet.hpp>
14 #include <stdair/basic/EventType.hpp>
15 #include <stdair/bom/BomAbstract.hpp>
16 #include <stdair/bom/EventTypes.hpp>
17 // SEvMgr
20 #include <sevmgr/SEVMGR_Types.hpp>
21 
23 namespace stdair {
24  class FacBomManager;
25  template <typename BOM> class FacBom;
26 }
27 
28 namespace SEVMGR {
29 
68  class EventQueue : public stdair::BomAbstract {
69  template <typename BOM> friend class stdair::FacBom;
70  friend class stdair::FacBomManager;
71 
72  public:
73  // ////////// Type definitions ////////////
78 
79 
80  public:
81  // /////////// Getters ///////////////
83  const Key_T& getKey () const {
84  return _key;
85  }
86 
88  BomAbstract* const getParent () const {
89  return _parent;
90  }
91 
93  const stdair::EventList_T& getEventList () const {
94  return _eventList;
95  }
96 
98  const stdair::HolderMap_T& getHolderMap () const {
99  return _holderMap;
100  }
101 
103  const stdair::ProgressStatus& getStatus () const {
104  return _progressStatus;
105  }
107  const stdair::Count_T& getCurrentNbOfEvents () const {
108  return _progressStatus.getCurrentNb();
109  }
111  const stdair::Count_T& getExpectedTotalNbOfEvents () const {
112  return _progressStatus.getExpectedNb();
113  }
115  const stdair::Count_T& getActualTotalNbOfEvents () const {
116  return _progressStatus.getActualNb();
117  }
118 
123  const stdair::ProgressStatus& getStatus (const stdair::EventType::EN_EventType&) const;
124 
126  const stdair::Count_T& getCurrentNbOfEvents (const stdair::EventType::EN_EventType&) const;
127 
129  const stdair::Count_T& getExpectedTotalNbOfEvents (const stdair::EventType::EN_EventType&) const;
130 
132  const stdair::Count_T& getActualTotalNbOfEvents (const stdair::EventType::EN_EventType&) const;
133 
136  bool hasProgressStatus (const stdair::EventType::EN_EventType&) const;
137 
138  public:
139  // /////////// Setters ///////////////
141  void setStatus (const stdair::ProgressStatus& iProgressStatus) {
142  _progressStatus = iProgressStatus;
143  }
145  void setStatus (const stdair::Count_T& iCurrentNbOfEvents,
146  const stdair::Count_T& iExpectedTotalNbOfEvents,
147  const stdair::Count_T& iActualTotalNbOfEvents) {
148  _progressStatus.setCurrentNb (iCurrentNbOfEvents);
149  _progressStatus.setExpectedNb (iExpectedTotalNbOfEvents);
150  _progressStatus.setActualNb (iActualTotalNbOfEvents);
151  }
153  void setStatus (const stdair::Count_T& iCurrentNbOfEvents,
154  const stdair::Count_T& iActualTotalNbOfEvents) {
155  _progressStatus.setCurrentNb (iCurrentNbOfEvents);
156  _progressStatus.setActualNb (iActualTotalNbOfEvents);
157  }
159  void setCurrentNbOfEvents (const stdair::Count_T& iCurrentNbOfEvents) {
160  _progressStatus.setCurrentNb (iCurrentNbOfEvents);
161  }
163  void setExpectedTotalNbOfEvents (const stdair::Count_T& iExpectedTotalNbOfEvents) {
164  _progressStatus.setExpectedNb (iExpectedTotalNbOfEvents);
165  }
166 
171  void setStatus (const stdair::EventType::EN_EventType& iType,
172  const stdair::ProgressStatus& iProgressStatus);
173 
174 
175  public:
176  // /////////// Display support methods /////////
182  void toStream (std::ostream& ioOut) const {
183  ioOut << toString();
184  }
185 
191  void fromStream (std::istream& ioIn) {
192  }
193 
197  std::string toString () const;
198 
202  std::string list () const;
203 
208  std::string list (const stdair::EventType::EN_EventType&) const;
209 
213  const std::string describeKey () const {
214  return _key.toString();
215  }
216 
217  /*
218  * Display the full content of the event queue, with all its
219  * event structure.
220  *
221  * That method can be very consuming (in time, CPU and memory)
222  * when there are a lot of event structures (e.g., several hundreds
223  * of thousands). Call it only for debug purposes.
224  */
225  std::string display () const;
226 
227 
228  public:
229  // ////////// Business methods /////////
234  void reset ();
235 
249  stdair::ProgressStatusSet popEvent (stdair::EventStruct&);
250 
271  bool addEvent (stdair::EventStruct&);
272 
276  bool hasEventDateTime (const stdair::DateTime_T&);
277 
283  bool isQueueDone () const;
284 
298  void addStatus (const stdair::EventType::EN_EventType&,
299  const stdair::NbOfRequests_T& iExpectedTotalNbOfEvents);
300 
309  void updateStatus (const stdair::EventType::EN_EventType&,
310  const stdair::ProgressStatus& iProgressStatus);
311 
325  void updateStatus (const stdair::EventType::EN_EventType&,
326  const stdair::NbOfEvents_T& iActualTotalNbOfEvents);
327 
338  stdair::ProgressPercentage_T calculateProgress () const {
339  return _progressStatus.progress();
340  }
341 
352  stdair::ProgressPercentage_T calculateProgress (const stdair::EventType::EN_EventType&)const;
353 
354 
355  public:
356  // ////////// Debug methods /////////
358  stdair::Count_T getQueueSize () const;
359 
361  bool isQueueEmpty () const;
362 
363 
364  protected:
365  // ////////// Constructors and destructors /////////
367  EventQueue (const Key_T&);
369  EventQueue (const EventQueue&);
371  ~EventQueue ();
372  private:
374  EventQueue ();
375 
376 
377  protected:
378  // ////////// Attributes /////////
383 
388 
394  stdair::HolderMap_T _holderMap;
395 
399  stdair::EventList_T _eventList;
400 
404  stdair::ProgressStatus _progressStatus;
405 
412  };
413 
414 }
415 #endif // __SEVMGR_BOM_EVENTQUEUE_HPP