source: trunk/lib/Stats.h @ 112

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

fixes #27 and added some beauty

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1// $Id: Stats.h 112 2006-06-29 09:30:54Z 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    ///
50    ///
51    inline u_int last_changed_rev(void) const { return last_changed_rev_; }
52
53    ///
54    /// @return true if file is binary
55    ///
56    bool parse(const std::string&);
57
58    ///
59    /// Create statistics graph.
60    ///
61    std::string plot(const std::string&, const std::string&) const;
62
63    ///
64    /// @brief Clear all statistics
65    ///
66    inline void reset(void) { map_.clear(); }
67
68    ///
69    ///
70    ///
71    inline u_int revision(void) const { return revision_; }
72
73    ///
74    ///
75    ///
76    inline u_int rows(void) const { return accumulated().back(); }
77
78    ///
79    /// @return resulting Stats
80    ///
81    Stats& operator+=(const Stats&);
82
83  private:
84    ///
85    /// Copy constructor (not implemented)
86    ///
87    Stats(const Stats& other);
88
89    ///
90    /// @return accumulated vector of total
91    ///
92    std::vector<u_int> accumulated(void) const;
93
94    ///
95    /// @return accumulated vector of stats_[user]
96    ///
97    std::vector<u_int> accumulated(const std::string& user) const;
98
99    ///
100    /// @brief adding a line to user from revision to the stats
101    ///
102    void add(const std::string& user, const u_int& revision); 
103
104
105    u_int revision_; // Should be the latest revision for whole project
106    u_int last_changed_rev_; // Should be the latest revision for file
107
108    // Peter, if the vector is sparse make it a map
109    typedef std::map<std::string, std::vector<u_int> > Map_;
110    typedef Map_::iterator MapIter_;
111    typedef Map_::const_iterator MapConstIter_;
112    Map_ map_;
113  };
114}} // end of namespace svnstat end of namespace theplu
115
116#endif
Note: See TracBrowser for help on using the repository browser.