OSDN Git Service

Change Dir Structure to be same as TortoiseSVN'
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / SearchPathTree.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 #include "DictionaryBasedTempPath.h"\r
22 \r
23 using namespace LogCache;\r
24 \r
25 class CFullGraphNode;\r
26 \r
27 /**\r
28  * \ingroup TortoiseProc\r
29  * Helper class for the revision graph to search the whole path tree\r
30  */\r
31 class CSearchPathTree\r
32 {\r
33 private:\r
34 \r
35         CDictionaryBasedTempPath path;\r
36 \r
37         /// when this entry becomes valid / active\r
38 \r
39         revision_t startRevision;\r
40 \r
41         /// previous node for this path (or its copy source)\r
42 \r
43         CFullGraphNode* lastEntry;\r
44 \r
45         /// tree pointers\r
46 \r
47         CSearchPathTree* parent;\r
48         CSearchPathTree* firstChild;\r
49         CSearchPathTree* lastChild;\r
50         CSearchPathTree* previous;\r
51         CSearchPathTree* next;\r
52 \r
53         /// utilities: handle node insertion / removal\r
54 \r
55         void DeLink();\r
56         void Link (CSearchPathTree* newParent);\r
57 \r
58 public:\r
59 \r
60         /// construction / destruction\r
61 \r
62         CSearchPathTree (const CPathDictionary* dictionary);\r
63         CSearchPathTree ( const CDictionaryBasedTempPath& path\r
64                                         , revision_t startrev\r
65                                         , CSearchPathTree* parent);\r
66 \r
67         ~CSearchPathTree();\r
68 \r
69         /// add a node for the given path and rev. to the tree\r
70 \r
71         CSearchPathTree* Insert ( const CDictionaryBasedTempPath& path\r
72                                                         , revision_t startrev);\r
73         void Remove();\r
74 \r
75         /// there is a new revision entry for this path\r
76 \r
77         void ChainEntries (CFullGraphNode* entry);\r
78 \r
79         /// property access\r
80 \r
81         const CDictionaryBasedTempPath& GetPath() const\r
82         {\r
83                 return path;\r
84         }\r
85 \r
86         revision_t GetStartRevision() const\r
87         {\r
88                 return startRevision;\r
89         }\r
90 \r
91         void SetStartRevision (revision_t revision)\r
92         {\r
93                 startRevision = revision;\r
94         }\r
95 \r
96         CFullGraphNode* GetLastEntry() const\r
97         {\r
98                 return lastEntry;\r
99         }\r
100 \r
101         CSearchPathTree* GetParent() const\r
102         {\r
103                 return parent;\r
104         }\r
105 \r
106         CSearchPathTree* GetFirstChild() const\r
107         {\r
108                 return firstChild;\r
109         }\r
110 \r
111         CSearchPathTree* GetLastChild() const\r
112         {\r
113                 return lastChild;\r
114         }\r
115 \r
116         CSearchPathTree* GetNext() const\r
117         {\r
118                 return next;\r
119         }\r
120 \r
121         CSearchPathTree* GetPrevious() const\r
122         {\r
123                 return previous;\r
124         }\r
125 \r
126         bool IsActive() const\r
127         {\r
128                 return startRevision != NO_REVISION;\r
129         }\r
130 \r
131         bool IsEmpty() const\r
132         {\r
133                 return !IsActive() && (firstChild == NULL);\r
134         }\r
135 \r
136     /// return true for active paths that don't have a revEntry for this revision\r
137 \r
138     bool YetToCover (revision_t revision) const;\r
139 \r
140     /// return next node in pre-order\r
141 \r
142     CSearchPathTree* GetPreOrderNext (CSearchPathTree* lastNode = NULL);\r
143 \r
144     /// return next node in pre-order but skip this sub-tree\r
145 \r
146     CSearchPathTree* GetSkipSubTreeNext (CSearchPathTree* lastNode = NULL);\r
147 \r
148         /// find sub-tree of pathID  \r
149         /// (return closet match if there is no such node)\r
150 \r
151         CSearchPathTree* FindCommonParent (index_t pathID);\r
152 };\r