- Timestamp:
- 04/05/09 09:21:44 (4 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
-
statistics.cpp (modified) (3 diffs)
-
statistics.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/statistics.cpp
r199 r201 34 34 Statistics::Statistics(configuration::Configuration *backend) 35 35 { 36 try { 37 load_data(); 38 } catch (exception &e) { 39 reset(); 40 } 41 } 42 43 void Statistics::load_data() 44 { 36 45 string tmp; 37 46 vector<string> tmp_vec; … … 46 55 tmp = backend->get("statistics_score_distribution"); 47 56 split(tmp_vec, tmp, is_any_of(",")); 48 if (tmp_vec.size() != score_distributions_slots) { 49 reset(); 50 return; 51 } 57 if (tmp_vec.size() != score_distributions_slots) 58 throw BadConfiguration(); 52 59 53 60 BOOST_FOREACH(string i, tmp_vec) { … … 57 64 istringstream i(tmp); 58 65 i >> _last_reset; 66 if (!_last_reset) 67 throw BadConfiguration(); 68 59 69 } 60 70 -
trunk/src/statistics.h
r199 r201 24 24 #include "configuration.h" 25 25 #include <vector> 26 #include <exception> 26 27 namespace statistics { 27 28 … … 55 56 void save(); 56 57 58 /** 59 * Loads data from the backend. 60 */ 61 void load_data(); 62 57 63 int _games_started; 58 64 int _games_finished; … … 61 67 std::vector<int> score_distribution; 62 68 configuration::Configuration *backend; 69 }; 70 71 class BadConfiguration : public std::exception { 72 virtual const char* what() const throw() 73 { 74 return "Bad Configuration"; 75 } 63 76 }; 64 77
Note: See TracChangeset
for help on using the changeset viewer.
