1254 |
31 Oct 10 |
peter |
1 |
#ifndef _theplu_svndigest_node_counter_ |
1254 |
31 Oct 10 |
peter |
2 |
#define _theplu_svndigest_node_counter_ |
1254 |
31 Oct 10 |
peter |
3 |
|
1254 |
31 Oct 10 |
peter |
// $Id$ |
1254 |
31 Oct 10 |
peter |
5 |
|
1254 |
31 Oct 10 |
peter |
6 |
/* |
1254 |
31 Oct 10 |
peter |
Copyright (C) 2010 Peter Johansson |
1254 |
31 Oct 10 |
peter |
8 |
|
1254 |
31 Oct 10 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
1254 |
31 Oct 10 |
peter |
10 |
|
1254 |
31 Oct 10 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
1254 |
31 Oct 10 |
peter |
under the terms of the GNU General Public License as published by |
1254 |
31 Oct 10 |
peter |
the Free Software Foundation; either version 3 of the License, or |
1254 |
31 Oct 10 |
peter |
(at your option) any later version. |
1254 |
31 Oct 10 |
peter |
15 |
|
1254 |
31 Oct 10 |
peter |
svndigest is distributed in the hope that it will be useful, but |
1254 |
31 Oct 10 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1254 |
31 Oct 10 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1254 |
31 Oct 10 |
peter |
General Public License for more details. |
1254 |
31 Oct 10 |
peter |
20 |
|
1254 |
31 Oct 10 |
peter |
You should have received a copy of the GNU General Public License |
1254 |
31 Oct 10 |
peter |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
1254 |
31 Oct 10 |
peter |
23 |
*/ |
1254 |
31 Oct 10 |
peter |
24 |
|
1254 |
31 Oct 10 |
peter |
25 |
#include "NodeVisitor.h" |
1254 |
31 Oct 10 |
peter |
26 |
|
1254 |
31 Oct 10 |
peter |
27 |
namespace theplu{ |
1254 |
31 Oct 10 |
peter |
28 |
namespace svndigest{ |
1254 |
31 Oct 10 |
peter |
29 |
|
1254 |
31 Oct 10 |
peter |
30 |
class Directory; |
1254 |
31 Oct 10 |
peter |
31 |
class File; |
1254 |
31 Oct 10 |
peter |
32 |
|
1254 |
31 Oct 10 |
peter |
33 |
/** |
1254 |
31 Oct 10 |
peter |
Class to calculate number files and directories in a tree |
1254 |
31 Oct 10 |
peter |
35 |
*/ |
1254 |
31 Oct 10 |
peter |
36 |
class NodeCounter : public NodeVisitor |
1254 |
31 Oct 10 |
peter |
37 |
{ |
1254 |
31 Oct 10 |
peter |
38 |
public: |
1254 |
31 Oct 10 |
peter |
39 |
/** |
1254 |
31 Oct 10 |
peter |
Default constructor |
1254 |
31 Oct 10 |
peter |
41 |
*/ |
1254 |
31 Oct 10 |
peter |
42 |
NodeCounter(void); |
1254 |
31 Oct 10 |
peter |
43 |
|
1254 |
31 Oct 10 |
peter |
44 |
/** |
1254 |
31 Oct 10 |
peter |
\return number of directories |
1254 |
31 Oct 10 |
peter |
46 |
*/ |
1254 |
31 Oct 10 |
peter |
47 |
unsigned int directories(void) const; |
1254 |
31 Oct 10 |
peter |
48 |
|
1254 |
31 Oct 10 |
peter |
49 |
/** |
1254 |
31 Oct 10 |
peter |
This function is called from Directory::traverse |
1254 |
31 Oct 10 |
peter |
51 |
|
1254 |
31 Oct 10 |
peter |
Add 1 to number of directories |
1254 |
31 Oct 10 |
peter |
53 |
|
1254 |
31 Oct 10 |
peter |
\return true if we should traverse daughter nodes |
1254 |
31 Oct 10 |
peter |
55 |
*/ |
1254 |
31 Oct 10 |
peter |
56 |
bool enter(Directory& dir); |
1254 |
31 Oct 10 |
peter |
57 |
|
1254 |
31 Oct 10 |
peter |
58 |
/** |
1254 |
31 Oct 10 |
peter |
\return number of files |
1254 |
31 Oct 10 |
peter |
60 |
*/ |
1254 |
31 Oct 10 |
peter |
61 |
unsigned int files(void) const; |
1254 |
31 Oct 10 |
peter |
62 |
|
1254 |
31 Oct 10 |
peter |
63 |
/** |
1254 |
31 Oct 10 |
peter |
Does nothing |
1254 |
31 Oct 10 |
peter |
65 |
*/ |
1254 |
31 Oct 10 |
peter |
66 |
void leave(Directory& dir); |
1254 |
31 Oct 10 |
peter |
67 |
|
1254 |
31 Oct 10 |
peter |
68 |
/** |
1254 |
31 Oct 10 |
peter |
add 1 to number of files |
1254 |
31 Oct 10 |
peter |
70 |
*/ |
1254 |
31 Oct 10 |
peter |
71 |
void visit(File& file); |
1254 |
31 Oct 10 |
peter |
72 |
private: |
1254 |
31 Oct 10 |
peter |
73 |
unsigned int directories_; |
1254 |
31 Oct 10 |
peter |
74 |
unsigned int files_; |
1254 |
31 Oct 10 |
peter |
75 |
}; |
1254 |
31 Oct 10 |
peter |
76 |
|
1513 |
23 Sep 12 |
peter |
77 |
|
1254 |
31 Oct 10 |
peter |
78 |
}} // end of namespace svndigest and namespace theplu |
1254 |
31 Oct 10 |
peter |
79 |
|
1254 |
31 Oct 10 |
peter |
80 |
#endif |