165 |
24 Aug 06 |
jari |
1 |
#ifndef _theplu_svndigest_node_ |
165 |
24 Aug 06 |
jari |
2 |
#define _theplu_svndigest_node_ |
165 |
24 Aug 06 |
jari |
3 |
|
7 |
30 Dec 05 |
jari |
// $Id$ |
4 |
29 Dec 05 |
peter |
5 |
|
84 |
13 Mar 06 |
jari |
6 |
/* |
978 |
12 Dec 09 |
peter |
Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson |
757 |
27 Jan 09 |
peter |
Copyright (C) 2009 Peter Johansson |
1264 |
02 Nov 10 |
peter |
Copyright (C) 2010 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2011, 2012 Peter Johansson |
84 |
13 Mar 06 |
jari |
11 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
84 |
13 Mar 06 |
jari |
13 |
|
149 |
12 Aug 06 |
jari |
svndigest is free software; you can redistribute it and/or modify it |
84 |
13 Mar 06 |
jari |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
84 |
13 Mar 06 |
jari |
(at your option) any later version. |
84 |
13 Mar 06 |
jari |
18 |
|
149 |
12 Aug 06 |
jari |
svndigest is distributed in the hope that it will be useful, but |
84 |
13 Mar 06 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
149 |
12 Aug 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
84 |
13 Mar 06 |
jari |
General Public License for more details. |
84 |
13 Mar 06 |
jari |
23 |
|
84 |
13 Mar 06 |
jari |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
84 |
13 Mar 06 |
jari |
26 |
*/ |
84 |
13 Mar 06 |
jari |
27 |
|
1234 |
23 Oct 10 |
peter |
28 |
#include "LineTypeParser.h" |
532 |
26 Dec 07 |
peter |
29 |
#include "StatsCollection.h" |
129 |
02 Aug 06 |
jari |
30 |
#include "SVNinfo.h" |
285 |
06 May 07 |
peter |
31 |
#include "SVNlog.h" |
1356 |
17 May 11 |
peter |
32 |
#include "SVNproperty.h" |
1234 |
23 Oct 10 |
peter |
33 |
#include "TinyStats.h" |
14 |
30 Dec 05 |
peter |
34 |
|
226 |
11 Mar 07 |
peter |
35 |
#include <map> |
29 |
09 Jan 06 |
peter |
36 |
#include <ostream> |
91 |
23 Mar 06 |
jari |
37 |
#include <stdexcept> |
4 |
29 Dec 05 |
peter |
38 |
#include <string> |
4 |
29 Dec 05 |
peter |
39 |
|
4 |
29 Dec 05 |
peter |
40 |
namespace theplu{ |
149 |
12 Aug 06 |
jari |
41 |
namespace svndigest{ |
4 |
29 Dec 05 |
peter |
42 |
|
303 |
11 May 07 |
peter |
43 |
class Alias; |
1234 |
23 Oct 10 |
peter |
44 |
class NodeVisitor; |
303 |
11 May 07 |
peter |
45 |
|
91 |
23 Mar 06 |
jari |
46 |
/// |
91 |
23 Mar 06 |
jari |
/// If something goes wrong in the use of the Node or its derived |
91 |
23 Mar 06 |
jari |
/// classes, a NodeException is thrown. |
91 |
23 Mar 06 |
jari |
49 |
/// |
91 |
23 Mar 06 |
jari |
50 |
struct NodeException : public std::runtime_error |
91 |
23 Mar 06 |
jari |
51 |
{ inline NodeException(const std::string& msg) : runtime_error(msg) {} }; |
91 |
23 Mar 06 |
jari |
52 |
|
4 |
29 Dec 05 |
peter |
53 |
/// |
4 |
29 Dec 05 |
peter |
/// Abstract Base Class for files. |
4 |
29 Dec 05 |
peter |
55 |
/// |
4 |
29 Dec 05 |
peter |
56 |
class Node |
4 |
29 Dec 05 |
peter |
57 |
{ |
4 |
29 Dec 05 |
peter |
58 |
public: |
91 |
23 Mar 06 |
jari |
59 |
|
1450 |
22 Dec 11 |
peter |
60 |
/// |
1450 |
22 Dec 11 |
peter |
/// @brief Constructor |
1450 |
22 Dec 11 |
peter |
62 |
/// |
1450 |
22 Dec 11 |
peter |
63 |
Node(const unsigned int, const std::string&, const std::string&, |
1264 |
02 Nov 10 |
peter |
64 |
const std::string& = ""); |
91 |
23 Mar 06 |
jari |
65 |
|
9 |
30 Dec 05 |
jari |
66 |
/// |
9 |
30 Dec 05 |
jari |
/// @brief Destructor |
9 |
30 Dec 05 |
jari |
68 |
/// |
453 |
17 Aug 07 |
peter |
69 |
virtual ~Node(void); |
4 |
29 Dec 05 |
peter |
70 |
|
74 |
07 Mar 06 |
jari |
71 |
/// |
129 |
02 Aug 06 |
jari |
/// @brief Get the author of the latest commit. |
112 |
29 Jun 06 |
peter |
73 |
/// |
452 |
17 Aug 07 |
peter |
74 |
std::string author(void) const; |
112 |
29 Jun 06 |
peter |
75 |
|
452 |
17 Aug 07 |
peter |
76 |
|
185 |
06 Sep 06 |
jari |
77 |
/** |
185 |
06 Sep 06 |
jari |
@brief Check whether node is binary. |
185 |
06 Sep 06 |
jari |
79 |
|
185 |
06 Sep 06 |
jari |
@return True if node is binary. |
185 |
06 Sep 06 |
jari |
81 |
*/ |
1356 |
17 May 11 |
peter |
82 |
bool binary(void) const; |
185 |
06 Sep 06 |
jari |
83 |
|
112 |
29 Jun 06 |
peter |
84 |
/// |
101 |
22 Jun 06 |
peter |
/// @return true if directory |
101 |
22 Jun 06 |
peter |
86 |
/// |
101 |
22 Jun 06 |
peter |
87 |
virtual bool dir(void) const; |
101 |
22 Jun 06 |
peter |
88 |
|
101 |
22 Jun 06 |
peter |
89 |
/// |
175 |
02 Sep 06 |
peter |
/// @return href to this node |
74 |
07 Mar 06 |
jari |
91 |
/// |
175 |
02 Sep 06 |
peter |
92 |
virtual std::string href(void) const=0; |
74 |
07 Mar 06 |
jari |
93 |
|
1290 |
12 Nov 10 |
peter |
94 |
/** |
1290 |
12 Nov 10 |
peter |
95 |
*/ |
1450 |
22 Dec 11 |
peter |
96 |
void html_tablerow(std::ostream& os, |
1290 |
12 Nov 10 |
peter |
97 |
const std::string& stats_type, |
1290 |
12 Nov 10 |
peter |
98 |
const std::string& css_class, |
213 |
15 Sep 06 |
peter |
99 |
const std::string& user) const; |
74 |
07 Mar 06 |
jari |
100 |
|
185 |
06 Sep 06 |
jari |
101 |
/** |
1234 |
23 Oct 10 |
peter |
Create the TinyStats based on the stored CollectionStats |
1234 |
23 Oct 10 |
peter |
103 |
*/ |
1234 |
23 Oct 10 |
peter |
104 |
void init_tiny_stats(void); |
1234 |
23 Oct 10 |
peter |
105 |
|
100 |
19 Jun 06 |
peter |
106 |
/// |
129 |
02 Aug 06 |
jari |
/// @brief Get the revision number of the latest commit. |
112 |
29 Jun 06 |
peter |
108 |
/// |
834 |
07 Nov 09 |
peter |
109 |
virtual svn_revnum_t last_changed_rev(void) const=0; |
112 |
29 Jun 06 |
peter |
110 |
|
380 |
21 Jun 07 |
jari |
111 |
/** |
447 |
16 Aug 07 |
peter |
@return log of this node in a recursive manner. |
447 |
16 Aug 07 |
peter |
113 |
*/ |
453 |
17 Aug 07 |
peter |
114 |
const SVNlog& log(void) const; |
447 |
16 Aug 07 |
peter |
115 |
|
182 |
03 Sep 06 |
peter |
116 |
/// |
1450 |
22 Dec 11 |
peter |
/// @return |
100 |
19 Jun 06 |
peter |
118 |
/// |
201 |
09 Sep 06 |
peter |
119 |
inline const std::string& local_path(void) const { return local_path_; } |
60 |
16 Jan 06 |
peter |
120 |
|
129 |
02 Aug 06 |
jari |
121 |
/// |
201 |
09 Sep 06 |
peter |
/// Function returning everything after the last '/' |
201 |
09 Sep 06 |
peter |
123 |
/// |
201 |
09 Sep 06 |
peter |
/// @return name of node (not full path) |
201 |
09 Sep 06 |
peter |
125 |
/// |
482 |
13 Oct 07 |
peter |
126 |
std::string name(void) const; |
201 |
09 Sep 06 |
peter |
127 |
|
343 |
19 May 07 |
peter |
128 |
/** |
1290 |
12 Nov 10 |
peter |
@return The explicit string identifying the underlying derived |
1290 |
12 Nov 10 |
peter |
class. |
1290 |
12 Nov 10 |
peter |
131 |
*/ |
1290 |
12 Nov 10 |
peter |
132 |
virtual std::string node_type(void) const=0; |
356 |
25 May 07 |
peter |
133 |
|
201 |
09 Sep 06 |
peter |
134 |
/// |
176 |
02 Sep 06 |
peter |
/// @todo doc |
1450 |
22 Dec 11 |
peter |
136 |
/// |
91 |
23 Mar 06 |
jari |
137 |
inline const std::string& path(void) const { return path_; } |
91 |
23 Mar 06 |
jari |
138 |
|
653 |
08 Jun 08 |
peter |
139 |
/** |
1450 |
22 Dec 11 |
peter |
\return svnprop for this Node |
1450 |
22 Dec 11 |
peter |
141 |
*/ |
1450 |
22 Dec 11 |
peter |
142 |
const SVNproperty& property(void) const; |
1450 |
22 Dec 11 |
peter |
143 |
|
1450 |
22 Dec 11 |
peter |
144 |
/** |
1538 |
07 Oct 12 |
peter |
check revision of this node and sub-nodes and return the |
1538 |
07 Oct 12 |
peter |
smallest revision, i.e., all nodes are at least at revision |
1538 |
07 Oct 12 |
peter |
returned. |
1538 |
07 Oct 12 |
peter |
148 |
*/ |
1538 |
07 Oct 12 |
peter |
149 |
virtual svn_revnum_t revision_min(void) const=0; |
1538 |
07 Oct 12 |
peter |
150 |
|
1538 |
07 Oct 12 |
peter |
151 |
/** |
1234 |
23 Oct 10 |
peter |
\return true if svncopyright::ignore property was set |
1234 |
23 Oct 10 |
peter |
153 |
*/ |
1234 |
23 Oct 10 |
peter |
154 |
bool svncopyright_ignore(void) const; |
1234 |
23 Oct 10 |
peter |
155 |
|
1234 |
23 Oct 10 |
peter |
156 |
/** |
1449 |
22 Dec 11 |
peter |
@brief Check if Node should be ignored by svndigest. |
185 |
06 Sep 06 |
jari |
158 |
|
1449 |
22 Dec 11 |
peter |
Binary files and links will be ignored as well as nodes with |
1449 |
22 Dec 11 |
peter |
property svndigest:ignore set to "" as that implies that all |
1449 |
22 Dec 11 |
peter |
revs should be ignored. |
185 |
06 Sep 06 |
jari |
162 |
|
1449 |
22 Dec 11 |
peter |
@return True if item property svndigest:ignore was set with |
1449 |
22 Dec 11 |
peter |
empty string or node is binary or link. |
1449 |
22 Dec 11 |
peter |
165 |
|
1450 |
22 Dec 11 |
peter |
\see SVNproperty::svndigest_ignore() |
185 |
06 Sep 06 |
jari |
167 |
*/ |
1356 |
17 May 11 |
peter |
168 |
bool svndigest_ignore(void) const; |
185 |
06 Sep 06 |
jari |
169 |
|
330 |
18 May 07 |
peter |
170 |
/** |
1234 |
23 Oct 10 |
peter |
171 |
*/ |
1234 |
23 Oct 10 |
peter |
172 |
const StatsCollection& stats(void) const; |
1234 |
23 Oct 10 |
peter |
173 |
|
1290 |
12 Nov 10 |
peter |
174 |
/** |
1290 |
12 Nov 10 |
peter |
175 |
*/ |
1234 |
23 Oct 10 |
peter |
176 |
StatsCollection& stats(void); |
1234 |
23 Oct 10 |
peter |
177 |
|
1234 |
23 Oct 10 |
peter |
178 |
/** |
1234 |
23 Oct 10 |
peter |
Access point for a NodeVisitor to start traversing Node and its |
1234 |
23 Oct 10 |
peter |
daughter nodes. |
1234 |
23 Oct 10 |
peter |
181 |
*/ |
1234 |
23 Oct 10 |
peter |
182 |
virtual void traverse(NodeVisitor& visitor)=0; |
1234 |
23 Oct 10 |
peter |
183 |
|
1234 |
23 Oct 10 |
peter |
184 |
/** |
1290 |
12 Nov 10 |
peter |
185 |
*/ |
1280 |
06 Nov 10 |
peter |
186 |
inline const SVNinfo& svn_info(void) const { return svninfo_; } |
1280 |
06 Nov 10 |
peter |
187 |
|
1290 |
12 Nov 10 |
peter |
188 |
/** |
1290 |
12 Nov 10 |
peter |
189 |
*/ |
1290 |
12 Nov 10 |
peter |
190 |
const TinyStats& tiny_stats(void) const { return tiny_stats_; } |
1290 |
12 Nov 10 |
peter |
191 |
|
129 |
02 Aug 06 |
jari |
192 |
protected: |
589 |
12 Apr 08 |
jari |
193 |
unsigned int level_; |
343 |
19 May 07 |
peter |
194 |
std::string output_dir_; |
203 |
10 Sep 06 |
peter |
195 |
std::string path_; // absolute path |
207 |
11 Sep 06 |
peter |
196 |
static std::string project_; |
532 |
26 Dec 07 |
peter |
197 |
StatsCollection stats_; |
1234 |
23 Oct 10 |
peter |
198 |
TinyStats tiny_stats_; |
4 |
29 Dec 05 |
peter |
199 |
|
9 |
30 Dec 05 |
jari |
200 |
private: |
9 |
30 Dec 05 |
jari |
201 |
/// |
9 |
30 Dec 05 |
jari |
/// @brief Copy Constructor, not implemented |
9 |
30 Dec 05 |
jari |
203 |
/// |
9 |
30 Dec 05 |
jari |
204 |
Node(const Node&); |
29 |
09 Jan 06 |
peter |
205 |
|
1290 |
12 Nov 10 |
peter |
206 |
/** |
1290 |
12 Nov 10 |
peter |
207 |
*/ |
1450 |
22 Dec 11 |
peter |
208 |
void html_tabletd(std::ostream&, |
1450 |
22 Dec 11 |
peter |
209 |
const std::string& stats_type, |
1450 |
22 Dec 11 |
peter |
210 |
const std::string& user, |
1234 |
23 Oct 10 |
peter |
211 |
LineTypeParser::line_type lt) const; |
1234 |
23 Oct 10 |
peter |
212 |
|
757 |
27 Jan 09 |
peter |
213 |
virtual void log_core(SVNlog&) const=0; |
757 |
27 Jan 09 |
peter |
214 |
|
361 |
10 Jun 07 |
peter |
215 |
bool link_; |
1013 |
05 Jan 10 |
jari |
216 |
std::string local_path_; // path from root |
453 |
17 Aug 07 |
peter |
217 |
mutable SVNlog* log_; |
1356 |
17 May 11 |
peter |
218 |
SVNproperty property_; |
129 |
02 Aug 06 |
jari |
219 |
SVNinfo svninfo_; |
1290 |
12 Nov 10 |
peter |
220 |
|
1290 |
12 Nov 10 |
peter |
221 |
friend class FilePrinter; |
1290 |
12 Nov 10 |
peter |
222 |
friend class DirectoryPrinter; |
1290 |
12 Nov 10 |
peter |
223 |
friend class NodePrinter; |
9 |
30 Dec 05 |
jari |
224 |
}; |
4 |
29 Dec 05 |
peter |
225 |
|
330 |
18 May 07 |
peter |
226 |
/** |
330 |
18 May 07 |
peter |
\brief Functor class to compare pointers of Nodes |
330 |
18 May 07 |
peter |
228 |
*/ |
101 |
22 Jun 06 |
peter |
229 |
struct NodePtrLess |
101 |
22 Jun 06 |
peter |
230 |
{ |
330 |
18 May 07 |
peter |
231 |
/** |
330 |
18 May 07 |
peter |
@return true if first and second are of same type (Directory or |
330 |
18 May 07 |
peter |
File) and name of first is (alphabetically) less than name of |
330 |
18 May 07 |
peter |
second; or if first is a Directory and second is a File. |
330 |
18 May 07 |
peter |
235 |
*/ |
101 |
22 Jun 06 |
peter |
236 |
inline bool operator()(const Node* first, const Node* second) const |
1450 |
22 Dec 11 |
peter |
237 |
{ |
101 |
22 Jun 06 |
peter |
238 |
if (first->dir()==second->dir()) |
201 |
09 Sep 06 |
peter |
239 |
return first->name()<second->name(); |
101 |
22 Jun 06 |
peter |
240 |
return first->dir(); |
101 |
22 Jun 06 |
peter |
241 |
} |
101 |
22 Jun 06 |
peter |
242 |
}; |
101 |
22 Jun 06 |
peter |
243 |
|
149 |
12 Aug 06 |
jari |
244 |
}} // end of namespace svndigest and namespace theplu |
4 |
29 Dec 05 |
peter |
245 |
|
7 |
30 Dec 05 |
jari |
246 |
#endif |