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

EventQueue.hpp

Go to the documentation of this file.
00001 #ifndef __SEVMGR_BOM_EVENTQUEUE_HPP
00002 #define __SEVMGR_BOM_EVENTQUEUE_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <iosfwd>
00009 #include <string>
00010 // StdAir
00011 #include <stdair/stdair_basic_types.hpp>
00012 #include <stdair/stdair_date_time_types.hpp>
00013 #include <stdair/basic/ProgressStatusSet.hpp>
00014 #include <stdair/basic/EventType.hpp>
00015 #include <stdair/bom/BomAbstract.hpp>
00016 #include <stdair/bom/EventTypes.hpp>
00017 // SEvMgr
00018 #include <sevmgr/bom/EventQueueKey.hpp>
00019 #include <sevmgr/bom/EventQueueTypes.hpp>
00020 #include <sevmgr/SEVMGR_Types.hpp>
00021 
00023 namespace stdair {
00024   class FacBomManager;
00025   template <typename BOM> class FacBom;
00026 }
00027 
00028 namespace SEVMGR {
00029 
00068   class EventQueue : public stdair::BomAbstract {
00069     template <typename BOM> friend class stdair::FacBom;
00070     friend class stdair::FacBomManager;
00071 
00072   public:
00073     // ////////// Type definitions ////////////
00077     typedef EventQueueKey Key_T;
00078     
00079 
00080   public:
00081     // /////////// Getters ///////////////
00083     const Key_T& getKey () const {
00084       return _key;
00085     }
00086 
00088     BomAbstract* const getParent () const {
00089       return _parent;
00090     } 
00091 
00093     const stdair::EventList_T& getEventList () const {
00094       return _eventList;
00095     }
00096     
00098     const stdair::HolderMap_T& getHolderMap () const {
00099       return _holderMap;
00100     }
00101     
00103     const stdair::ProgressStatus& getStatus () const {
00104       return _progressStatus;
00105     }
00107     const stdair::Count_T& getCurrentNbOfEvents () const {
00108       return _progressStatus.getCurrentNb();
00109     }
00111     const stdair::Count_T& getExpectedTotalNbOfEvents () const {
00112       return _progressStatus.getExpectedNb();
00113     }
00115     const stdair::Count_T& getActualTotalNbOfEvents () const {
00116       return _progressStatus.getActualNb();
00117     }
00118 
00123     const stdair::ProgressStatus& getStatus (const stdair::EventType::EN_EventType&) const;
00124 
00126     const stdair::Count_T& getCurrentNbOfEvents (const stdair::EventType::EN_EventType&) const;
00127 
00129     const stdair::Count_T& getExpectedTotalNbOfEvents (const stdair::EventType::EN_EventType&) const;
00130 
00132     const stdair::Count_T& getActualTotalNbOfEvents (const stdair::EventType::EN_EventType&) const;  
00133 
00136     bool hasProgressStatus (const stdair::EventType::EN_EventType&) const;
00137 
00138   public:
00139     // /////////// Setters ///////////////
00141     void setStatus (const stdair::ProgressStatus& iProgressStatus) {
00142       _progressStatus = iProgressStatus;
00143     }
00145     void setStatus (const stdair::Count_T& iCurrentNbOfEvents,
00146                     const stdair::Count_T& iExpectedTotalNbOfEvents,
00147                     const stdair::Count_T& iActualTotalNbOfEvents) {
00148       _progressStatus.setCurrentNb (iCurrentNbOfEvents);
00149       _progressStatus.setExpectedNb (iExpectedTotalNbOfEvents);
00150       _progressStatus.setActualNb (iActualTotalNbOfEvents);
00151     }
00153     void setStatus (const stdair::Count_T& iCurrentNbOfEvents,
00154                     const stdair::Count_T& iActualTotalNbOfEvents) {
00155       _progressStatus.setCurrentNb (iCurrentNbOfEvents);
00156       _progressStatus.setActualNb (iActualTotalNbOfEvents);
00157     }
00159     void setCurrentNbOfEvents (const stdair::Count_T& iCurrentNbOfEvents) {
00160       _progressStatus.setCurrentNb (iCurrentNbOfEvents);
00161     }
00163     void setExpectedTotalNbOfEvents (const stdair::Count_T& iExpectedTotalNbOfEvents) {
00164       _progressStatus.setExpectedNb (iExpectedTotalNbOfEvents);
00165     }
00166 
00171     void setStatus (const stdair::EventType::EN_EventType& iType,
00172                     const stdair::ProgressStatus& iProgressStatus);
00173 
00174 
00175   public:
00176     // /////////// Display support methods /////////
00182     void toStream (std::ostream& ioOut) const {
00183       ioOut << toString();
00184     }
00185 
00191     void fromStream (std::istream& ioIn) {
00192     }
00193 
00197     std::string toString () const; 
00198 
00202     std::string list () const;
00203  
00208     std::string list (const stdair::EventType::EN_EventType&) const;
00209     
00213     const std::string describeKey () const {
00214       return _key.toString();
00215     }
00216     
00217     /*
00218      * Display the full content of the event queue, with all its
00219      * event structure.
00220      *
00221      * That method can be very consuming (in time, CPU and memory)
00222      * when there are a lot of event structures (e.g., several hundreds
00223      * of thousands). Call it only for debug purposes.
00224     */
00225     std::string display () const;
00226     
00227     
00228   public:
00229     // ////////// Business methods /////////
00234     void reset ();
00235     
00249      stdair::ProgressStatusSet popEvent (stdair::EventStruct&);
00250 
00271     bool addEvent (stdair::EventStruct&);
00272 
00276     bool hasEventDateTime (const stdair::DateTime_T&);
00277 
00283     bool isQueueDone () const;
00284 
00298     void addStatus (const stdair::EventType::EN_EventType&,
00299                     const stdair::NbOfRequests_T& iExpectedTotalNbOfEvents);
00300 
00309     void updateStatus (const stdair::EventType::EN_EventType&,
00310                        const stdair::ProgressStatus& iProgressStatus);
00311 
00325     void updateStatus (const stdair::EventType::EN_EventType&,
00326                        const stdair::NbOfEvents_T& iActualTotalNbOfEvents);
00327 
00338     stdair::ProgressPercentage_T calculateProgress () const {
00339       return _progressStatus.progress();
00340     }
00341 
00352     stdair::ProgressPercentage_T calculateProgress (const stdair::EventType::EN_EventType&)const;
00353 
00354 
00355   public:
00356     // ////////// Debug methods /////////
00358     stdair::Count_T getQueueSize () const;
00359 
00361     bool isQueueEmpty () const;
00362 
00363     
00364   protected:
00365     // ////////// Constructors and destructors /////////
00367     EventQueue (const Key_T&);
00369     EventQueue (const EventQueue&);
00371     ~EventQueue ();
00372   private:
00374     EventQueue ();
00375     
00376 
00377   protected:
00378     // ////////// Attributes /////////
00382     Key_T _key;
00383 
00387     BomAbstract* _parent;
00388 
00394     stdair::HolderMap_T _holderMap;
00395 
00399     stdair::EventList_T _eventList;
00400     
00404     stdair::ProgressStatus _progressStatus;
00405 
00411     ProgressStatusMap_T _progressStatusMap;
00412   };
00413 
00414 }
00415 #endif // __SEVMGR_BOM_EVENTQUEUE_HPP