- Timestamp:
- Dec 25, 2007, 7:51:07 PM (16 years ago)
- Location:
- trunk/lib
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/BlameStats.cc
r529 r531 23 23 */ 24 24 25 #include " ClassicStats.h"25 #include "BlameStats.h" 26 26 27 27 #include "Functor.h" … … 50 50 51 51 52 ClassicStats::ClassicStats(const std::string& path)52 BlameStats::BlameStats(const std::string& path) 53 53 : Stats(path) 54 54 { … … 56 56 57 57 58 ClassicStats::ClassicStats(const ClassicStats& other)58 BlameStats::BlameStats(const BlameStats& other) 59 59 : Stats(other) 60 60 { … … 62 62 63 63 64 void ClassicStats::add(const std::string& user, const u_int& rev, 65 const Parser::line_type& lt) 66 { 67 assert(user.size()); 68 add_author(user); 69 70 std::vector<u_int>* total = &(total_[user]); 71 assert(total); 72 if (total->size() < rev+1){ 73 total->reserve(revision() + 1); 74 total->insert(total->end(), rev - total->size(), 0); 75 total->push_back(1); 76 } 77 else 78 ++(*total)[rev]; 79 80 std::vector<u_int>* code = &(code_[user]); 81 assert(code); 82 if (code->size() < rev+1){ 83 code->reserve(revision() + 1); 84 code->insert(code->end(), rev - code->size(), 0); 85 if (lt == Parser::code) 86 code->push_back(1); 87 else 88 code->push_back(0); 89 } 90 else if (lt == Parser::code) 91 ++(*code)[rev]; 92 93 std::vector<u_int>* comments = &(comments_[user]); 94 assert(comments); 95 if (comments->size() < rev+1){ 96 comments->reserve(revision() + 1); 97 comments->insert(comments->end(), rev - comments->size(), 0); 98 if (lt == Parser::comment) 99 comments->push_back(1); 100 else 101 comments->push_back(0); 102 } 103 else if (lt == Parser::comment) 104 ++(*comments)[rev]; 105 106 std::vector<u_int>* other = &(other_[user]); 107 assert(other); 108 if (other->size() < rev+1){ 109 other->reserve(revision() + 1); 110 other->insert(other->end(), rev - other->size(), 0); 111 if (lt == Parser::other) 112 other->push_back(1); 113 else 114 other->push_back(0); 115 } 116 else if (lt == Parser::other) 117 ++(*other)[rev]; 118 } 119 120 121 void ClassicStats::do_parse(const std::string& path) 64 void BlameStats::do_parse(const std::string& path) 122 65 { 123 66 Parser parser(path); -
trunk/lib/BlameStats.h
r529 r531 1 #ifndef _theplu_svndigest_ classic_stats_2 #define _theplu_svndigest_ classic_stats_1 #ifndef _theplu_svndigest_blame_stats_ 2 #define _theplu_svndigest_blame_stats_ 3 3 4 4 // $Id$ … … 35 35 /// Class taking care of statistics from svn. 36 36 /// 37 class ClassicStats : public Stats37 class BlameStats : public Stats 38 38 { 39 39 public: … … 41 41 /// @brief Default Constructor 42 42 /// 43 explicit ClassicStats(const std::string& path);43 explicit BlameStats(const std::string& path); 44 44 45 ClassicStats(const ClassicStats& other);45 BlameStats(const BlameStats& other); 46 46 47 47 private: … … 54 54 const Parser::line_type&); 55 55 56 /**57 Load object from a stream.58 59 \return true if successful60 */61 bool do_load_cache(std::istream&);62 63 56 void do_parse(const std::string&); 64 65 ///66 /// Create statistics graph.67 ///68 std::string do_plot(const std::string&, const std::string&) const;69 70 /**71 */72 void do_print(std::ostream&) const;73 74 std::vector<u_int> vector(std::string type, std::string user) const;75 /**76 Load map from stream77 */78 void load(std::istream&, Author2Vector&);79 80 void do_print(std::ostream& os, const Author2Vector& map) const;81 57 82 58 }; -
trunk/lib/ClassicStats.cc
r529 r531 62 62 63 63 64 void ClassicStats::add(const std::string& user, const u_int& rev,65 const Parser::line_type& lt)66 {67 assert(user.size());68 add_author(user);69 70 std::vector<u_int>* total = &(total_[user]);71 assert(total);72 if (total->size() < rev+1){73 total->reserve(revision() + 1);74 total->insert(total->end(), rev - total->size(), 0);75 total->push_back(1);76 }77 else78 ++(*total)[rev];79 80 std::vector<u_int>* code = &(code_[user]);81 assert(code);82 if (code->size() < rev+1){83 code->reserve(revision() + 1);84 code->insert(code->end(), rev - code->size(), 0);85 if (lt == Parser::code)86 code->push_back(1);87 else88 code->push_back(0);89 }90 else if (lt == Parser::code)91 ++(*code)[rev];92 93 std::vector<u_int>* comments = &(comments_[user]);94 assert(comments);95 if (comments->size() < rev+1){96 comments->reserve(revision() + 1);97 comments->insert(comments->end(), rev - comments->size(), 0);98 if (lt == Parser::comment)99 comments->push_back(1);100 else101 comments->push_back(0);102 }103 else if (lt == Parser::comment)104 ++(*comments)[rev];105 106 std::vector<u_int>* other = &(other_[user]);107 assert(other);108 if (other->size() < rev+1){109 other->reserve(revision() + 1);110 other->insert(other->end(), rev - other->size(), 0);111 if (lt == Parser::other)112 other->push_back(1);113 else114 other->push_back(0);115 }116 else if (lt == Parser::other)117 ++(*other)[rev];118 }119 120 121 64 void ClassicStats::do_parse(const std::string& path) 122 65 { -
trunk/lib/ClassicStats.h
r529 r531 46 46 47 47 private: 48 /// using compiler generated copy49 50 ///51 /// @brief adding a line to user from revision to the stats52 ///53 void add(const std::string& user, const u_int& revision,54 const Parser::line_type&);55 56 /**57 Load object from a stream.58 59 \return true if successful60 */61 bool do_load_cache(std::istream&);62 63 48 void do_parse(const std::string&); 64 65 ///66 /// Create statistics graph.67 ///68 std::string do_plot(const std::string&, const std::string&) const;69 70 /**71 */72 void do_print(std::ostream&) const;73 74 std::vector<u_int> vector(std::string type, std::string user) const;75 /**76 Load map from stream77 */78 void load(std::istream&, Author2Vector&);79 80 void do_print(std::ostream& os, const Author2Vector& map) const;81 49 82 50 }; -
trunk/lib/Makefile.am
r519 r531 26 26 noinst_LTLIBRARIES = libsvndigest.la 27 27 28 noinst_HEADERS = Alias.h ClassicStats.h ColumnStream.h \28 noinst_HEADERS = Alias.h BlameStats.h ClassicStats.h ColumnStream.h \ 29 29 Commitment.h Configuration.h css.h\ 30 30 Date.h Directory.h File.h first_page.h Functor.h Gnuplot.h GnuplotFE.h \ … … 33 33 SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h 34 34 35 libsvndigest_la_SOURCES = Alias.cc ClassicStats.cc ColumnStream.cc \ 35 libsvndigest_la_SOURCES = Alias.cc BlameStats.cc \ 36 ClassicStats.cc ColumnStream.cc \ 36 37 Commitment.cc Configuration.cc \ 37 38 css.cc Date.cc Directory.cc File.cc first_page.cc\ -
trunk/lib/Stats.cc
r530 r531 101 101 total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]); 102 102 } 103 104 105 void Stats::add(const std::string& user, const u_int& rev, 106 const Parser::line_type& lt, u_int n) 107 { 108 assert(user.size()); 109 add_author(user); 110 111 std::vector<u_int>& total = total_[user]; 112 if (total.size() < rev+1){ 113 total.reserve(revision() + 1); 114 total.insert(total.end(), rev - total.size(), 0); 115 total.push_back(n); 116 } 117 else 118 total[rev]+=n; 119 120 std::vector<u_int>& code = code_[user]; 121 if (code.size() < rev+1){ 122 code.reserve(revision() + 1); 123 code.insert(code.end(), rev - code.size(), 0); 124 if (lt == Parser::code) 125 code.push_back(n); 126 else 127 code.push_back(0); 128 } 129 else if (lt == Parser::code) 130 code[rev]+=n; 131 132 std::vector<u_int>& comments = comments_[user]; 133 if (comments.size() < rev+1){ 134 comments.reserve(revision() + 1); 135 comments.insert(comments.end(), rev - comments.size(), 0); 136 if (lt == Parser::comment) 137 code.push_back(n); 138 else 139 comments.push_back(0); 140 } 141 else if (lt == Parser::comment) 142 comments[rev]+=n; 143 144 std::vector<u_int>& other = other_[user]; 145 if (other.size() < rev+1){ 146 other.reserve(revision() + 1); 147 other.insert(other.end(), rev - other.size(), 0); 148 if (lt == Parser::other) 149 other.push_back(n); 150 else 151 other.push_back(0); 152 } 153 else if (lt == Parser::other) 154 other[rev]+=n; 155 } 103 156 104 157 -
trunk/lib/Stats.h
r530 r531 55 55 */ 56 56 virtual ~Stats(void); 57 58 /// 59 /// @brief adding \a n line(s) to \a user from \a revision to the stats 60 /// 61 void add(const std::string& user, const u_int& revision, 62 const Parser::line_type&, u_int n=1); 57 63 58 64 ///
Note: See TracChangeset
for help on using the changeset viewer.