OSDN Git Service

Show Ignore Sub Menu
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / VisibleGraphNode.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-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 "FullGraphNode.h"\r
22 \r
23 // forward declarations\r
24 \r
25 class CVisibleGraph;\r
26 \r
27 /**\r
28  * \ingroup TortoiseProc\r
29  * Helper class, representing a revision with all the required information\r
30  * which we need to draw a revision graph.\r
31  */\r
32 class CVisibleGraphNode\r
33 {\r
34 public:\r
35 \r
36     /**\r
37     * Represents a branch that has been recognized as "tag" \r
38     * and folded into the copy source node.\r
39     */\r
40 \r
41     class CFoldedTag\r
42     {\r
43     private:\r
44 \r
45         const CFullGraphNode* tagNode;\r
46         CFoldedTag* next;\r
47         size_t depth;\r
48 \r
49     public:\r
50 \r
51         /// construction\r
52 \r
53             CFoldedTag ( const CFullGraphNode* tagNode\r
54                    , size_t depth\r
55                    , CFoldedTag* next = NULL);\r
56 \r
57         /// data access\r
58 \r
59         const CFullGraphNode* GetTag() const;\r
60         const CFoldedTag* GetNext() const;\r
61         size_t GetDepth() const;\r
62 \r
63         bool IsAlias() const;\r
64         bool IsDeleted() const;\r
65         bool IsModified() const;\r
66 \r
67         /// used to modify the depth\r
68 \r
69         friend CVisibleGraphNode;\r
70     };\r
71 \r
72     /// copy target list type\r
73 \r
74     typedef simple_list<CVisibleGraphNode> CCopyTarget;\r
75 \r
76     /// factory type\r
77 \r
78     class CFactory\r
79     {\r
80     private:\r
81 \r
82         boost::pool<> nodePool;\r
83         boost::pool<> tagPool;\r
84         CCopyTarget::factory copyTargetFactory;\r
85 \r
86         size_t nodeCount;\r
87 \r
88     public:\r
89 \r
90         /// factory creation\r
91 \r
92         CFactory();\r
93 \r
94         /// factory interface\r
95 \r
96         CVisibleGraphNode* Create ( const CFullGraphNode* base\r
97                                   , CVisibleGraphNode* prev\r
98                                   , bool preserveNode);\r
99         void Destroy (CVisibleGraphNode* node);\r
100 \r
101         CFoldedTag* Create ( const CFullGraphNode* tagNode\r
102                            , size_t depth\r
103                            , CFoldedTag* next);\r
104         void Destroy (CFoldedTag* tag);\r
105 \r
106         /// instance tracking\r
107 \r
108         size_t GetNodeCount() const;\r
109     };\r
110 \r
111     friend class CFactory;\r
112 \r
113 private:\r
114 \r
115         /// members\r
116 \r
117     const CFullGraphNode* base;\r
118 \r
119         CCopyTarget*        firstCopyTarget;\r
120     CFoldedTag*         firstTag;\r
121 \r
122         CVisibleGraphNode*  prev;\r
123         CVisibleGraphNode*  next;\r
124 \r
125         CVisibleGraphNode*  copySource;\r
126 \r
127     CNodeClassification classification;\r
128 \r
129         index_t                     index;\r
130 \r
131     /// construction / destruction via pool\r
132 \r
133 protected:\r
134 \r
135         /// protect construction / destruction to force usage of pool\r
136 \r
137         CVisibleGraphNode ( const CFullGraphNode* base\r
138                       , CVisibleGraphNode* prev\r
139                       , CCopyTarget::factory& copyTargetFactory\r
140                       , bool preserveNode);\r
141     ~CVisibleGraphNode();\r
142 \r
143     /// destruction utilities\r
144 \r
145     void DestroySubNodes ( CFactory& factory\r
146                          , CCopyTarget::factory& copyTargetFactory);\r
147     void DestroyTags (CFactory& factory);\r
148 \r
149 public:\r
150 \r
151     /// data access\r
152 \r
153         const CDictionaryBasedTempPath& GetPath() const;\r
154         CDictionaryBasedPath GetRealPath() const;\r
155         const CFoldedTag* GetFirstTag() const;\r
156 \r
157         const CVisibleGraphNode* GetCopySource() const;\r
158     const CCopyTarget* GetFirstCopyTarget() const;\r
159 \r
160         const CVisibleGraphNode* GetPrevious() const;\r
161         CVisibleGraphNode* GetPrevious();\r
162         const CVisibleGraphNode* GetNext() const;\r
163         CVisibleGraphNode* GetNext();\r
164 \r
165         revision_t GetRevision() const;\r
166         CNodeClassification GetClassification() const;\r
167 \r
168         index_t GetIndex() const;\r
169 \r
170     /// set index members within the whole sub-tree\r
171 \r
172     index_t InitIndex (index_t startIndex);\r
173 \r
174     /// remove node and move links to pre-decessor\r
175 \r
176     void DropNode (CVisibleGraph* graph);\r
177 \r
178     /// remove node and add it as folded tag to the parent\r
179 \r
180     void FoldTag (CVisibleGraph* graph);\r
181 };\r
182 \r
183 /// CVisibleGraphNode::CFoldedTag construction\r
184 \r
185 inline CVisibleGraphNode::CFoldedTag::CFoldedTag \r
186     ( const CFullGraphNode* tagNode\r
187     , size_t depth\r
188     , CFoldedTag* next)\r
189         : tagNode (tagNode), depth (depth), next (next)\r
190 {\r
191 }\r
192 \r
193 /// CVisibleGraphNode::CFoldedTag data access\r
194 \r
195 inline const CFullGraphNode* CVisibleGraphNode::CFoldedTag::GetTag() const\r
196 {\r
197     return tagNode;\r
198 }\r
199 \r
200 inline const CVisibleGraphNode::CFoldedTag* \r
201 CVisibleGraphNode::CFoldedTag::GetNext() const\r
202 {\r
203     return next;\r
204 }\r
205 \r
206 inline size_t CVisibleGraphNode::CFoldedTag::GetDepth() const\r
207 {\r
208     return depth;\r
209 }\r
210 \r
211 inline bool CVisibleGraphNode::CFoldedTag::IsDeleted() const\r
212 {\r
213     return tagNode->GetClassification()\r
214         .Is (CNodeClassification::PATH_ONLY_DELETED);\r
215 }\r
216 \r
217 inline bool CVisibleGraphNode::CFoldedTag::IsModified() const\r
218 {\r
219     return tagNode->GetClassification()\r
220         .Is (CNodeClassification::PATH_ONLY_MODIFIED);\r
221 }\r
222 \r
223 /// CVisibleGraphNode::CFactory data access\r
224 \r
225 inline size_t CVisibleGraphNode::CFactory::GetNodeCount() const\r
226 {\r
227     return nodeCount;\r
228 }\r
229 \r
230 /// CVisibleGraphNode data access\r
231 \r
232 inline const CDictionaryBasedTempPath& CVisibleGraphNode::GetPath() const\r
233 {\r
234     return base->GetPath();\r
235 }\r
236 \r
237 inline CDictionaryBasedPath CVisibleGraphNode::GetRealPath() const\r
238 {\r
239     return base->GetRealPath();\r
240 }\r
241 \r
242 inline const CVisibleGraphNode::CFoldedTag* CVisibleGraphNode::GetFirstTag() const\r
243 {\r
244     return firstTag;\r
245 }\r
246 \r
247 inline const CVisibleGraphNode* CVisibleGraphNode::GetCopySource() const\r
248 {\r
249     return copySource;\r
250 }\r
251 \r
252 inline const CVisibleGraphNode::CCopyTarget* \r
253 CVisibleGraphNode::GetFirstCopyTarget() const\r
254 {\r
255     return firstCopyTarget;\r
256 }\r
257 \r
258 inline const CVisibleGraphNode* CVisibleGraphNode::GetPrevious() const\r
259 {\r
260     return prev;\r
261 }\r
262 \r
263 inline CVisibleGraphNode* CVisibleGraphNode::GetPrevious()\r
264 {\r
265     return prev;\r
266 }\r
267 \r
268 inline const CVisibleGraphNode* CVisibleGraphNode::GetNext() const\r
269 {\r
270     return next;\r
271 }\r
272 \r
273 inline CVisibleGraphNode* CVisibleGraphNode::GetNext() \r
274 {\r
275     return next;\r
276 }\r
277 \r
278 inline revision_t CVisibleGraphNode::GetRevision() const\r
279 {\r
280     return base->GetRevision();\r
281 }\r
282 \r
283 inline CNodeClassification CVisibleGraphNode::GetClassification() const\r
284 {\r
285     return classification;\r
286 }\r
287 \r
288 inline index_t CVisibleGraphNode::GetIndex() const\r
289 {\r
290     return index;\r
291 }\r