source: trunk/lib/Stats.h @ 80

Last change on this file since 80 was 80, checked in by Jari Häkkinen, 17 years ago

Removed nasty bug: svnstat crashed when the last checkin contained zero statistics
count items only, eg. empty directories or binary files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//$Id: Stats.h 80 2006-03-10 16:52:04Z jari $
2
3#ifndef _theplu_svnstat_stats_
4#define _theplu_svnstat_stats_
5
6#include <iostream>
7#include <map>
8#include <ostream>
9#include <string>
10#include <vector>
11
12namespace theplu{
13namespace svnstat{
14
15  ///
16  /// Class taking care of statistics from svn.
17  ///
18  class Stats
19  {
20  public:
21    ///
22    /// @brief Default Constructor
23    ///
24    explicit Stats(const std::string& path);
25
26    ///
27    /// @return true if file is binary
28    ///
29    bool parse(const std::string&);
30
31    ///
32    /// Create statistics graph.
33    ///
34    std::string plot(const std::string&) const;
35
36    ///
37    /// @brief Clear all statistics
38    ///
39    inline void reset(void) { map_.clear(); }
40
41    ///
42    ///
43    ///
44    inline u_int rows(void) const { return accumulated().back(); }
45
46    ///
47    /// @return resulting Stats
48    ///
49    Stats& operator+=(const Stats&);
50
51  private:
52    ///
53    /// Copy constructor (not implemented)
54    ///
55    Stats(const Stats& other);
56
57    ///
58    /// @return accumulated vector of total
59    ///
60    std::vector<u_int> accumulated(void) const;
61
62    ///
63    /// @return accumulated vector of stats_[user]
64    ///
65    std::vector<u_int> accumulated(const std::string& user) const;
66
67    ///
68    /// @brief adding a line to user from revision to the stats
69    ///
70    void add(const std::string& user, const u_int& revision); 
71
72
73    u_int latest_revision_; // Should be the latest revision for whole project
74
75    // Peter, if the vector is sparse make it a map
76    typedef std::map<std::string, std::vector<u_int> > Map_;
77    typedef Map_::iterator MapIter_;
78    typedef Map_::const_iterator MapConstIter_;
79    Map_ map_;
80  };
81}} // end of namespace svnstat end of namespace theplu
82
83#endif
Note: See TracBrowser for help on using the repository browser.