1 | //$Id: Stats.h 38 2006-01-13 12:29:09Z jari $ |
---|
2 | |
---|
3 | #ifndef _theplu_svnstat_stats_ |
---|
4 | #define _theplu_svnstat_stats_ |
---|
5 | |
---|
6 | #include <map> |
---|
7 | #include <string> |
---|
8 | #include <vector> |
---|
9 | |
---|
10 | namespace theplu{ |
---|
11 | namespace svnstat{ |
---|
12 | |
---|
13 | class Gnuplot; |
---|
14 | |
---|
15 | /// |
---|
16 | /// Class taking care of statistics from svn. |
---|
17 | /// |
---|
18 | class Stats |
---|
19 | { |
---|
20 | public: |
---|
21 | /// |
---|
22 | /// @brief Default Constructor |
---|
23 | /// |
---|
24 | inline Stats(void) {} |
---|
25 | |
---|
26 | /// |
---|
27 | /// @brief adding a line to user from revision to the stats |
---|
28 | /// |
---|
29 | void add(const std::string& user, const u_int& revision); |
---|
30 | |
---|
31 | /// |
---|
32 | /// @bief print statistics |
---|
33 | /// |
---|
34 | void print(std::ostream&) const; |
---|
35 | |
---|
36 | /// |
---|
37 | /// @brief Clear all statistics |
---|
38 | /// |
---|
39 | inline void reset(void) { map_.clear(); } |
---|
40 | |
---|
41 | /// |
---|
42 | /// @return resulting Stats |
---|
43 | /// |
---|
44 | Stats& operator+=(const Stats&); |
---|
45 | |
---|
46 | /// |
---|
47 | /// Jari, this is public. Naughty! |
---|
48 | /// |
---|
49 | /// @todo Make this non-public. The issues that gnuplot is started |
---|
50 | /// in cwd, but the main program makes a 'chdir' to another, and |
---|
51 | /// we cannot get gnuplot to change directory if it is |
---|
52 | /// private. Some redesign is needed. |
---|
53 | /// |
---|
54 | static Gnuplot gnuplot_pipe_; |
---|
55 | |
---|
56 | private: |
---|
57 | /// |
---|
58 | /// Copy constructor (not implemented) |
---|
59 | /// |
---|
60 | Stats(const Stats& other); |
---|
61 | |
---|
62 | /// |
---|
63 | /// @return accumulated vector of total |
---|
64 | /// |
---|
65 | std::vector<double> accumulated(void) const; |
---|
66 | |
---|
67 | /// |
---|
68 | /// @return accumulated vector of stats_[user] |
---|
69 | /// |
---|
70 | std::vector<double> accumulated(const std::string& user) const; |
---|
71 | |
---|
72 | std::string plot(void) const; |
---|
73 | |
---|
74 | // Peter, if the vector is sparse make it a map |
---|
75 | typedef std::map<std::string, std::vector<u_int> > Map_; |
---|
76 | typedef Map_::iterator MapIter_; |
---|
77 | typedef Map_::const_iterator MapConstIter_; |
---|
78 | Map_ map_; |
---|
79 | }; |
---|
80 | }} |
---|
81 | |
---|
82 | #endif // end of namespace svnstat end of namespace theplu |
---|