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