Changeset 527
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Stats.cc
r519 r527 51 51 52 52 Stats::Stats(const std::string& path) 53 : valid_(true)54 53 { 55 54 // Make sure latest revision is set properly … … 115 114 last_changed_rev_ = std::max(last_changed_rev_, rhs.last_changed_rev_); 116 115 add_authors(rhs.authors().begin(), rhs.authors().end()); 117 valid_ &= rhs.valid(); 118 // if cache not valid no need to update it 119 if (valid()) { 120 base_add(rhs.code_.begin(), rhs.code_.end(), code_); 121 base_add(rhs.comments_.begin(), rhs.comments_.end(), comments_); 122 base_add(rhs.other_.begin(), rhs.other_.end(), other_); 123 base_add(rhs.total_.begin(), rhs.total_.end(), total_); 124 } 116 base_add(rhs.code_.begin(), rhs.code_.end(), code_); 117 base_add(rhs.comments_.begin(), rhs.comments_.end(), comments_); 118 base_add(rhs.other_.begin(), rhs.other_.end(), other_); 119 base_add(rhs.total_.begin(), rhs.total_.end(), total_); 125 120 } 126 121 … … 147 142 std::string user) const 148 143 { 149 // Peter, we should avoid calling this function prior all150 // statistics are calculated. If, for some reason, this is not151 // possible call update_stats() first, however, that function is152 // not const so some redesign is needed (e.g. making cache mutable153 // or making them pointers)154 assert(valid() && "trying to access invalid cache of statistics");155 144 v_map::const_iterator iter(m.find(std::string(user))); 156 145 if (iter==m.end()) … … 189 178 u_int Stats::lines(const std::string& user) const 190 179 { 191 assert(valid());return get_vector(total_, "all").back();180 return get_vector(total_, "all").back(); 192 181 } 193 182 … … 195 184 void Stats::parse(const std::string& path) 196 185 { 197 valid_=false;198 186 // First we let inherited class do parsing 199 187 do_parse(path); … … 225 213 void Stats::plot_summary(const std::string& filename) const 226 214 { 227 assert(valid());228 215 plot_init(filename); 229 216 GnuplotFE* gp=GnuplotFE::instance(); … … 308 295 VectorPlus<u_int> vp; 309 296 total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]); 310 valid_=true;311 297 } 312 298 -
trunk/lib/Stats.h
r519 r527 152 152 /// 153 153 void plot_init(const std::string& output) const; 154 inline bool valid(void) const {return valid_;} 154 155 155 private: 156 156 virtual bool do_load_cache(std::istream&)=0; … … 169 169 v_map comments_; 170 170 v_map other_; 171 bool valid_; 171 172 172 svn_revnum_t revision_; // Should be the latest revision for whole project 173 173 svn_revnum_t last_changed_rev_; // Should be the latest revision for file
Note: See TracChangeset
for help on using the changeset viewer.