QtPass  1.3.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 
15 #ifdef QT_DEBUG
16  dbg() << "START" << transactionDepth;
17 #endif
18  transactionDepth++;
19 }
20 
26 #ifdef QT_DEBUG
27  dbg() << "ADD" << transactionDepth << id;
28 #endif
29  if (transactionDepth > 0) {
30  lastInTransaction = id;
31  } else {
32  transactionQueue.push(pair<PROCESS, PROCESS>(id, id));
33  }
34 }
35 
41 #ifdef QT_DEBUG
42  dbg() << "END" << transactionDepth;
43 #endif
44  if (transactionDepth > 0) {
45  transactionDepth--;
46  if (transactionDepth == 0 && lastInTransaction != INVALID) {
47  transactionQueue.push(pair<PROCESS, PROCESS>(lastInTransaction, pid));
48  lastInTransaction = INVALID;
49  }
50  }
51 }
52 
59 #ifdef QT_DEBUG
60  dbg() << "OVER" << transactionDepth << id;
61 #endif
62  if (!transactionQueue.empty() && id == transactionQueue.front().first) {
63  PROCESS ret = transactionQueue.front().second;
64  transactionQueue.pop();
65  return ret;
66  }
67  return INVALID;
68 }
simpleTransaction::transactionIsOver
Enums::PROCESS transactionIsOver(Enums::PROCESS)
transactionIsOver checks wheather currently finished process is last in current transaction
Definition: simpletransaction.cpp:58
simpletransaction.h
debughelper.h
Enums::PROCESS
PROCESS
Definition: enums.h:16
Enums::INVALID
@ INVALID
Definition: enums.h:33
simpleTransaction::transactionStart
void transactionStart()
transactionStart this function is used to mark start of the sequence of processes that shall be treat...
Definition: simpletransaction.cpp:14
Enums
Enumerators for configuration and runtime items.
simpleTransaction::transactionEnd
void transactionEnd(Enums::PROCESS)
transactionEnd marks end of transaction
Definition: simpletransaction.cpp:40
dbg
#define dbg()
Definition: debughelper.h:7
simpleTransaction::transactionAdd
void transactionAdd(Enums::PROCESS)
transactionAdd If called after call to transactionStart() and before transactionEnd(),...
Definition: simpletransaction.cpp:25