LCOV - code coverage report
Current view: top level - builds/barbot/Cosmos/src/Simulator - EventsQueue.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 6 100.0 %
Date: 2021-06-16 15:43:28 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  *                                                                             *
       3             :  * Cosmos:(C)oncept et (O)utils (S)tatistique pour les (Mo)deles               *
       4             :  * (S)tochastiques                                                             *
       5             :  *                                                                             *
       6             :  * Copyright (C) 2009-2012 LSV & LACL                                          *
       7             :  * Authors: Paolo Ballarini & Hilal Djafri                                     *
       8             :  * Website: http://www.lsv.ens-cachan.fr/Software/cosmos                       *
       9             :  *                                                                             *
      10             :  * This program is free software; you can redistribute it and/or modify        *
      11             :  * it under the terms of the GNU General Public License as published by        *
      12             :  * the Free Software Foundation; either version 3 of the License, or           *
      13             :  * (at your option) any later version.                                         *
      14             :  *                                                                             *
      15             :  * This program is distributed in the hope that it will be useful,             *
      16             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
      18             :  * GNU General Public License for more details.                                *
      19             :  *                                                                             *
      20             :  * You should have received a copy of the GNU General Public License along     *
      21             :  * with this program; if not, write to the Free Software Foundation, Inc.,     *
      22             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 *
      23             :  *******************************************************************************
      24             :  */
      25             : 
      26             : 
      27             : #ifndef _EVENTSQUEUE_HPP
      28             : #define _EVENTSQUEUE_HPP
      29             : 
      30             : #include <vector>
      31             : #include "Event.hpp"
      32             : #include "spn.hpp"
      33             : 
      34             : using namespace std;
      35             : 
      36             : typedef vector <int> Tab;
      37             : typedef vector <Event> EQueue;
      38             : typedef vector <Event>::iterator EQit;
      39             : 
      40             : class EventsQueue {
      41             : public:
      42             :     //EventsQueue(size_t);
      43             :     EventsQueue(const std::vector<size_t> &sizes);
      44             :         
      45             :     EventsQueue(const EventsQueue& orig);
      46             :     virtual ~EventsQueue();
      47             :         
      48             :     void insert(const Event &);
      49             :     void replace(const Event &);
      50             :         void pause(double,size_t,size_t);
      51             :         bool restart(double,size_t,size_t);
      52             :     void remove(size_t,size_t);
      53             :         bool isScheduled(size_t,size_t)const;
      54             :     Event& getEvent(size_t,size_t);
      55             :         
      56             :     bool isEmpty()const;
      57             :     void printSedCmd(const std::vector<std::string> &labels,ostream&)const;
      58             :     void view(const std::vector<std::string> &labels)const;
      59             :         
      60             :     void reset();
      61             :     size_t getSize()const {return evtHeap.size();};
      62             :         
      63             :         
      64             :     const Event& InPosition(size_t)const ;
      65             :     
      66             :         
      67             : private:
      68             :         
      69             :         /**
      70             :          * The Events Heap Index vector allow to retrive the index
      71             :          * of an event in the Events Heap (evtHeap) given its transition
      72             :          * and binding index in constant time.
      73             :          * If the return value is -1 the corresponding event is not in the event heap.
      74             :          */
      75             :         vector<vector< long int > > evtHeapIndex;
      76             :         
      77             :         /**
      78             :          * This is the vector of events, all the events of every transition
      79             :          * and every binding must occurs in this vector.
      80             :          * the first index is allong transition and the second along binding index.
      81             :          */
      82             :         vector<vector< Event > > evtTbl;
      83             :         
      84             :         /**
      85             :          * The event heap is a vector of pairs. each pairs are the transition index
      86             :          * and binding index of an event in the event table.
      87             :          * This vector is a heap for the relation Event::isPriorer.
      88             :          * The first element of the heap is the most urgent event.
      89             :          */
      90             :         vector< sizeSq > evtHeap;
      91             : 
      92    99004682 :     size_t getLeftChildIndex(size_t nodeIndex)const {
      93    99004682 :         return 2 * nodeIndex + 1;
      94             :     }
      95             :         
      96    99004682 :     size_t getRightChildIndex(size_t nodeIndex)const {
      97    99004682 :         return 2 * nodeIndex + 2;
      98             :     }
      99             :         
     100    31866301 :     size_t getParentIndex(size_t nodeIndex)const {
     101    31866301 :         return (nodeIndex - 1) / 2;
     102             :     }
     103             :         
     104             :         void siftUp(size_t);
     105             :     void siftDown(size_t);
     106             :         void swapEvt(size_t,size_t);
     107             :         
     108             : };
     109             : 
     110             : 
     111             : #endif  /* _EVENTSQUEUE_HPP */
     112             : 

Generated by: LCOV version 1.13