LCOV - code coverage report
Current view: top level - builds/DaniloBorquez/flex-net-sim/src - connection.cpp (source / functions) Hit Total Coverage
Test: commit SHA1 Lines: 22 70 31.4 %
Date: 2025-08-25 21:30:02 Functions: 3 16 18.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "connection.hpp"
       2             : 
       3       53416 : Connection::Connection(long long id, double time, std::shared_ptr<const BitRate> bitRate) {
       4       53416 :   this->id = id;
       5       53416 :   this->links = std::vector<int>();
       6       53416 :   this->slots = std::vector<std::vector<int> >();
       7       53416 :   this->cores = std::vector<int>();
       8       53416 :   this->modes = std::vector<int>();
       9       53416 :   this->bands = std::vector<char>();
      10       53416 :   this->timeConnection = time;
      11       53416 :   this->bitRate = bitRate;
      12       53416 : }
      13             : 
      14           2 : void Connection::addLink(int idLink, std::vector<int> slots) {
      15           2 :   this->links.push_back(idLink);
      16             :   //this->modes.push_back(0);
      17             :   //this->cores.push_back(0);
      18           2 :   this->slots.push_back(slots);
      19           2 : }
      20           0 : void Connection::addLink(int idLink, char band, std::vector<int> slots) {
      21           0 :   this->links.push_back(idLink);
      22           0 :   this->bands.push_back(band);
      23             :   //this->modes.push_back(0);
      24             :   //this->cores.push_back(0);
      25           0 :   this->bandsSlots[band].push_back(slots);
      26           0 : }
      27             : 
      28      100655 : void Connection::addLink(int idLink, int fromSlot, int toSlot) {
      29      100655 :   this->links.push_back(idLink);
      30      100655 :   this->slots.push_back(std::vector<int>(toSlot - fromSlot));
      31      100655 :   int j = 0;
      32     2608234 :   for (int i = fromSlot; i < toSlot; i++) {
      33     2507579 :     this->slots.back()[j] = i;
      34     2507579 :     j++;
      35             :   }
      36      100655 : }
      37           0 : void Connection::addLink(int idLink, char band, int fromSlot, int toSlot) {
      38           0 :   this->links.push_back(idLink);
      39           0 :   this->bands.push_back(band);
      40           0 :   this->bandsSlots[band].push_back(std::vector<int>(toSlot - fromSlot));
      41           0 :   int j = 0;
      42           0 :   for (int i = fromSlot; i < toSlot; i++) {
      43           0 :     this->bandsSlots[band].back()[j] = i;
      44           0 :     j++;
      45             :   }
      46           0 : }
      47             : 
      48           0 : void Connection::addLink(int idLink, int core, int mode, int fromSlot, int toSlot) {
      49           0 :   this->links.push_back(idLink);
      50           0 :   this->modes.push_back(mode);
      51           0 :   this->cores.push_back(core);
      52           0 :   this->slots.push_back(std::vector<int>(toSlot - fromSlot));
      53           0 :   int j = 0;
      54           0 :   for (int i = fromSlot; i < toSlot; i++) {
      55           0 :     this->slots.back()[j] = i;
      56           0 :     j++;
      57             :   }
      58           0 : }
      59             : 
      60           0 : void Connection::moveSlots(int from, int to) {
      61           0 :   this->slots.clear();
      62           0 :   for (auto linkId: this->links) {
      63           0 :     this->slots.push_back(std::vector<int>(to - from));
      64           0 :     int j = 0;
      65           0 :     for (int i = from; i < to; i++) {
      66           0 :       this->slots.back()[j] = i;
      67           0 :       j++;
      68             :     }
      69             :   }
      70           0 : }
      71             : 
      72           0 : bool Connection::isSlotUsed(int slotPos) {
      73           0 :   std::vector<int> slots = this->slots.back();
      74           0 :   for (int i = 0; i < slots.size(); i++) {
      75           0 :     if (slots[i] == slotPos) {
      76           0 :       return true;
      77             :     }
      78             :   }
      79           0 :   return false;
      80             : }
      81             : 
      82           0 : std::vector<int> Connection::getLinks(void) { return this->links; }
      83           0 : std::vector<int> Connection::getCores(void) { return this->cores; }
      84           0 : std::vector<int> Connection::getModes(void) { return this->modes; }
      85           0 : std::vector<char> Connection::getBands(void) { return this->bands; }
      86           0 : std::vector<std::vector<int> > Connection::getSlots(void) const {
      87           0 :   return this->slots;
      88             : }
      89             : 
      90           0 : double Connection::getTimeConnection(void) { return this->timeConnection; }
      91           0 : std::shared_ptr<const BitRate> Connection::getBitrate(void) { return this->bitRate; }
      92           0 : long long Connection::getId(void) { return this->id; }

Generated by: LCOV version 1.13