Use CAutoGeneralHandle
[TortoiseGit.git] / src / TortoiseProc / lanes.h
blob29ffadc152aebff3553aa8649c1700a965622faf
1 /*
2 Author: Marco Costalba (C) 2005-2007
4 Copyright: See COPYING file that comes with this distribution
6 */
7 #ifndef LANES_H
8 #define LANES_H
10 //#include <CGitHash>
11 //#include <QVector>
12 #include "githash.h"
14 #define QVector vector
15 using namespace std;
17 typedef vector<CGitHash> CGitHashList ;
19 class Lanes {
20 public:
21 // graph elements
22 enum LaneType {
23 EMPTY,
24 ACTIVE,
25 NOT_ACTIVE,
26 MERGE_FORK,
27 MERGE_FORK_R,
28 MERGE_FORK_L,
29 JOIN,
30 JOIN_R,
31 JOIN_L,
32 HEAD,
33 HEAD_R,
34 HEAD_L,
35 TAIL,
36 TAIL_R,
37 TAIL_L,
38 CROSS,
39 CROSS_EMPTY,
40 INITIAL,
41 BRANCH,
42 UNAPPLIED,
43 APPLIED,
44 BOUNDARY,
45 BOUNDARY_C, // corresponds to MERGE_FORK
46 BOUNDARY_R, // corresponds to MERGE_FORK_R
47 BOUNDARY_L, // corresponds to MERGE_FORK_L
49 LANE_TYPES_NUM,
50 COLORS_NUM=8
53 // graph helpers
54 static inline bool isHead(int x) { return (x == HEAD || x == HEAD_R || x == HEAD_L); }
55 static inline bool isTail(int x) { return (x == TAIL || x == TAIL_R || x == TAIL_L); }
56 static inline bool isJoin(int x) { return (x == JOIN || x == JOIN_R || x == JOIN_L); }
57 static inline bool isFreeLane(int x) { return (x == NOT_ACTIVE || x == CROSS || isJoin(x)); }
58 static inline bool isBoundary(int x) { return (x == BOUNDARY || x == BOUNDARY_C ||
59 x == BOUNDARY_R || x == BOUNDARY_L); }
60 static inline bool isMerge(int x) { return (x == MERGE_FORK || x == MERGE_FORK_R ||
61 x == MERGE_FORK_L || isBoundary(x)); }
62 static inline bool isActive(int x) { return (x == ACTIVE || x == INITIAL || x == BRANCH ||
63 isMerge(x)); }
65 Lanes() {} // init() will setup us later, when data is available
66 bool isEmpty() { return typeVec.empty(); }
67 void init(const CGitHash& expectedSha);
68 void clear();
69 bool isFork(const CGitHash& sha, bool& isDiscontinuity);
70 void setBoundary(bool isBoundary);
71 void setFork(const CGitHash& sha);
72 void setMerge(const CGitHashList& parents);
73 void setInitial();
74 void setApplied();
75 void changeActiveLane(const CGitHash& sha);
76 void afterMerge();
77 void afterFork();
78 bool isBranch();
79 void afterBranch();
80 void afterApplied();
81 void nextParent(const CGitHash& sha);
82 void getLanes(QVector<int> &ln) { ln = typeVec; } // O(1) vector is implicitly shared
84 private:
85 int findNextSha(const CGitHash& next, int pos);
86 int findType(int type, int pos);
87 int add(int type, const CGitHash& next, int pos);
89 int activeLane;
90 QVector<int> typeVec;
91 QVector<CGitHash> nextShaVec;
92 bool boundary;
93 int NODE, NODE_L, NODE_R;
96 #endif