source: trunk/lib/Stats.h @ 101

Last change on this file since 101 was 101, checked in by Peter Johansson, 15 years ago

closes #28 #18 and added some lippstick to the node daughters table output

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1// $Id: Stats.h 101 2006-06-22 09:00:06Z peter $
2
3/*
4  Copyright (C) 2005 Peter Johansson
5  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
6
7  This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat
8
9  svnstat is free software; you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13
14  svnstat is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25#ifndef _theplu_svnstat_stats_
26#define _theplu_svnstat_stats_
27
28#include <iostream>
29#include <map>
30#include <ostream>
31#include <string>
32#include <vector>
33
34namespace theplu{
35namespace svnstat{
36
37  ///
38  /// Class taking care of statistics from svn.
39  ///
40  class Stats
41  {
42  public:
43    ///
44    /// @brief Default Constructor
45    ///
46    explicit Stats(const std::string& path);
47
48    ///
49    /// @return true if file is binary
50    ///
51    bool parse(const std::string&);
52
53    ///
54    /// Create statistics graph.
55    ///
56    std::string plot(const std::string&, const std::string&) const;
57
58    ///
59    /// @brief Clear all statistics
60    ///
61    inline void reset(void) { map_.clear(); }
62
63    ///
64    ///
65    ///
66    inline u_int rows(void) const { return accumulated().back(); }
67
68    ///
69    /// @return resulting Stats
70    ///
71    Stats& operator+=(const Stats&);
72
73  private:
74    ///
75    /// Copy constructor (not implemented)
76    ///
77    Stats(const Stats& other);
78
79    ///
80    /// @return accumulated vector of total
81    ///
82    std::vector<u_int> accumulated(void) const;
83
84    ///
85    /// @return accumulated vector of stats_[user]
86    ///
87    std::vector<u_int> accumulated(const std::string& user) const;
88
89    ///
90    /// @brief adding a line to user from revision to the stats
91    ///
92    void add(const std::string& user, const u_int& revision); 
93
94
95    u_int latest_revision_; // Should be the latest revision for whole project
96
97    // Peter, if the vector is sparse make it a map
98    typedef std::map<std::string, std::vector<u_int> > Map_;
99    typedef Map_::iterator MapIter_;
100    typedef Map_::const_iterator MapConstIter_;
101    Map_ map_;
102  };
103}} // end of namespace svnstat end of namespace theplu
104
105#endif
Note: See TracBrowser for help on using the repository browser.