QtPass  1.2.3
Multi-platform GUI for pass, the standard unix password manager.
simpletransaction.cpp
Go to the documentation of this file.
1 #include "simpletransaction.h"
2 #include <utility>
3 
4 #ifdef QT_DEBUG
5 #include "debughelper.h"
6 #endif
7 
8 using std::pair;
9 using namespace Enums;
10 
12 #ifdef QT_DEBUG
13  dbg() << "START" << transactionDepth;
14 #endif
15  transactionDepth++;
16 }
17 
19 #ifdef QT_DEBUG
20  dbg() << "ADD" << transactionDepth << id;
21 #endif
22  if (transactionDepth > 0) {
23  lastInTransaction = id;
24  } else {
25  transactionQueue.push(pair<PROCESS, PROCESS>(id, id));
26  }
27 }
28 
30 #ifdef QT_DEBUG
31  dbg() << "END" << transactionDepth;
32 #endif
33  if (transactionDepth > 0) {
34  transactionDepth--;
35  if (transactionDepth == 0 && lastInTransaction != INVALID) {
36  transactionQueue.push(pair<PROCESS, PROCESS>(lastInTransaction, pid));
37  lastInTransaction = INVALID;
38  }
39  }
40 }
41 
43 #ifdef QT_DEBUG
44  dbg() << "OVER" << transactionDepth << id;
45 #endif
46  if (!transactionQueue.empty() && id == transactionQueue.front().first) {
47  PROCESS ret = transactionQueue.front().second;
48  transactionQueue.pop();
49  return ret;
50  }
51  return INVALID;
52 }
Enums::PROCESS transactionIsOver(Enums::PROCESS)
transactionIsOver checks wheather currently finished process is last in current transaction ...
void transactionAdd(Enums::PROCESS)
transactionAdd If called after call to transactionStart() and before transactionEnd(), this method marks given process as next step in transaction. Otherwise it marks given process as the only step in transaction(it&#39;s value is treated as transaction result).
PROCESS
Definition: enums.h:16
#define dbg()
Definition: debughelper.h:7
Enumerators for configuration and runtime items.
void transactionStart()
transactionStart this function is used to mark start of the sequence of processes that shall be treat...
void transactionEnd(Enums::PROCESS)
transactionEnd marks end of transaction