QtPass Developer documentation
QtPass test coverage
Current view: top level - src/simpletransaction.cpp (source / functions) Coverage Total Hit
Test: QtPass Lines: 100.0 % 22 22
Test Date: 2026-11-14 13:19:18 Functions: 100.0 % 4 4

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2017 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : /**
       4              :  * @file
       5              :  * @brief Implements SimpleTransaction as a queue of (last process, result)
       6              :  * pairs.
       7              :  */
       8              : #include "simpletransaction.h"
       9              : #include <utility>
      10              : 
      11              : #include "qtpasslogging.h"
      12              : 
      13              : using Enums::INVALID;
      14              : using Enums::PROCESS;
      15              : 
      16          106 : void SimpleTransaction::transactionStart() {
      17          106 :   qCDebug(lcQtPass) << "START" << transactionDepth;
      18          106 :   transactionDepth++;
      19          106 : }
      20              : 
      21          163 : void SimpleTransaction::transactionAdd(PROCESS id) {
      22          163 :   qCDebug(lcQtPass) << "ADD" << transactionDepth << id;
      23          163 :   if (transactionDepth > 0) {
      24           88 :     lastInTransaction = id;
      25              :   } else {
      26              :     transactionQueue.emplace(id, id);
      27              :   }
      28          163 : }
      29              : 
      30          107 : void SimpleTransaction::transactionEnd(PROCESS pid) {
      31          107 :   qCDebug(lcQtPass) << "END" << transactionDepth;
      32          107 :   if (transactionDepth > 0) {
      33          106 :     transactionDepth--;
      34          106 :     if (transactionDepth == 0 && lastInTransaction != INVALID) {
      35           72 :       transactionQueue.emplace(lastInTransaction, pid);
      36           72 :       lastInTransaction = INVALID;
      37              :     }
      38              :   }
      39          107 : }
      40              : 
      41          163 : auto SimpleTransaction::transactionIsOver(PROCESS id) -> PROCESS {
      42          163 :   qCDebug(lcQtPass) << "OVER" << transactionDepth << id;
      43          163 :   if (!transactionQueue.empty() && id == transactionQueue.front().first) {
      44          144 :     PROCESS ret = transactionQueue.front().second;
      45              :     transactionQueue.pop();
      46          144 :     return ret;
      47              :   }
      48              :   return INVALID;
      49              : }
        

Generated by: LCOV version 2.0-1