source: trunk/lib/SvndigestVisitor.cc @ 1290

Last change on this file since 1290 was 1290, checked in by Peter Johansson, 11 years ago

closes #457. Lifting out plotting functions in Stats into a new class
StatsPlotter?. In same manner lifting out print functions from
Node/Directory/File? into a new hierarchy
NodePrinter/DirectoryPrinter/FilePrinter?. To accomplish these splits
without to much recoding some friendships are introduced. These new
classes are only needed for svndigest (not svncopyright) and are
therefore placed in a library named libsvndigest together with Graph
class and first_page functions. Remaining functionality, shared
between svncopyright and svndigest, are located in libsvndigest_core
and linked into both binaries.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: SvndigestVisitor.cc 1290 2010-11-12 04:01:35Z peter $
2
3/*
4  Copyright (C) 2010 Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "SvndigestVisitor.h"
23
24#include "Directory.h"
25#include "DirectoryPrinter.h"
26#include "File.h"
27#include "FilePrinter.h"
28#include "NodeVisitor.h"
29
30namespace theplu {
31namespace svndigest {
32
33  SvndigestVisitor::SvndigestVisitor(bool verbose, bool ignore_cache,
34                                     bool report)
35    : verbose_(verbose), ignore_cache_(ignore_cache), report_(report)
36  {}
37
38
39  bool SvndigestVisitor::enter(Directory& dir) 
40  {
41    if (dir.ignore())
42      return false;
43    return true;
44  }
45 
46
47  void SvndigestVisitor::leave(Directory& dir) 
48  {
49    if (report_) {
50      dir.collect_stats();
51      dir.init_tiny_stats();
52      DirectoryPrinter dp(dir);
53      dp.print(verbose_);
54    }
55  }
56 
57
58  void SvndigestVisitor::visit(File& file)
59  {
60    if (!file.ignore())
61      file.parse(verbose_, ignore_cache_);
62    if (report_) {
63      file.init_tiny_stats();
64      if (!file.ignore()) {
65        FilePrinter fp(file);
66        fp.print(verbose_);
67      }
68    }
69  }
70
71}} // end of namespace svndigest and namespace theplu
72
Note: See TracBrowser for help on using the repository browser.