source: trunk/lib/ClassicStats.cc @ 1194

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

refs #475. First version using Sparse Vector class. This change is obviously quite invasive and thus the size of this commit is larger than what is preferred. I've tried to limit as much as possible and left optimization and style issues behind with a note 'FIXME'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1// $Id: ClassicStats.cc 1194 2010-10-03 23:39:12Z peter $
2
3/*
4  Copyright (C) 2005 Peter Johansson
5  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
6  Copyright (C) 2009, 2010 Peter Johansson
7
8  This file is part of svndigest, http://dev.thep.lu.se/svndigest
9
10  svndigest is free software; you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 3 of the License, or
13  (at your option) any later version.
14
15  svndigest is distributed in the hope that it will be useful, but
16  WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#include "ClassicStats.h"
25
26#include "Functor.h"
27#include "SVNblame.h"
28#include "SVNinfo.h"
29#include "utility.h"
30
31#include <algorithm>
32#include <cassert>
33#include <cstdlib>
34#include <fstream>
35#include <iostream>
36#include <iterator>
37#include <map>
38#include <numeric>
39#include <string>
40#include <sstream>
41#include <unistd.h>
42#include <utility>
43#include <vector>
44
45
46namespace theplu{
47namespace svndigest{
48
49
50  ClassicStats::ClassicStats(const std::string& path)
51    : Stats(path)
52  {
53  }
54
55
56  ClassicStats::ClassicStats(const ClassicStats& other)
57  : Stats(other)
58  {
59  }
60
61
62  void ClassicStats::do_parse(const std::string& path, svn_revnum_t rev)
63  {
64    reset();
65    LineTypeParser parser(path);
66    SVNblame svn_blame(path);
67    std::vector<std::map<std::string, SparseVector> > data(4);
68    while (svn_blame.valid()) {
69      LineTypeParser::line_type lt = parser.parse(svn_blame.line());
70      assert(lt<data.size());
71      SparseVector& vec = data[lt][svn_blame.author()];
72      vec.set(svn_blame.revision(), vec[svn_blame.revision()] + 1);
73      svn_blame.next_line();
74    }
75    // add parsed data to member
76    add(data);
77  }
78
79
80  unsigned int 
81  ClassicStats::max_element(const SumVector& v) const 
82  {
83    assert(v.size());
84    return v.back();
85  }
86
87}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.