Fix wrong xdg config string
[TortoiseGit.git] / src / TortoiseProc / lanes.h
blob3453e89d6e93eedb86b7ac5040458ff48a363845
1 /*
2 Author: Marco Costalba (C) 2005-2007
3 Author: TortoiseGit (C) 2013
5 Copyright: See COPYING file that comes with this distribution
7 */
8 #ifndef LANES_H
9 #define LANES_H
11 //#include <CGitHash>
12 //#include <QVector>
13 #include "githash.h"
15 #define QVector std::vector
17 typedef std::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 : activeLane(0)
67 , boundary(false)
68 , NODE(0)
69 , NODE_L(0)
70 , NODE_R(0)
72 bool isEmpty() { return typeVec.empty(); }
73 void init(const CGitHash& expectedSha);
74 void clear();
75 bool isFork(const CGitHash& sha, bool& isDiscontinuity);
76 void setBoundary(bool isBoundary);
77 void setFork(const CGitHash& sha);
78 void setMerge(const CGitHashList& parents);
79 void setInitial();
80 void setApplied();
81 void changeActiveLane(const CGitHash& sha);
82 void afterMerge();
83 void afterFork();
84 bool isBranch();
85 void afterBranch();
86 void afterApplied();
87 void nextParent(const CGitHash& sha);
88 void getLanes(QVector<int> &ln) { ln = typeVec; } // O(1) vector is implicitly shared
90 private:
91 int findNextSha(const CGitHash& next, int pos);
92 int findType(int type, int pos);
93 int add(int type, const CGitHash& next, int pos, bool& wasEmptyCross);
95 int activeLane;
96 QVector<int> typeVec;
97 QVector<CGitHash> nextShaVec;
98 bool boundary;
99 int NODE, NODE_L, NODE_R;
102 #endif