| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2006-2009 by Guy Rutenberg * |
| 3 | * [email protected] * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 2 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program; if not, write to the * |
| 17 | * Free Software Foundation, Inc., * |
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #ifndef OPENYAHTZEE_STATISTICS_INC |
| 22 | #define OPENYAHTZEE_STATISTICS_INCcxx . . $ `src/statistics.h:22:9`! |
| 23 | |
| 24 | #include "configuration.h"cxx . . $ `<file>/src/configuration.h`/ |
| 25 | #include <vector> |
| 26 | #include <exception> |
| 27 | namespace statisticscxx . . $ statistics/ { |
| 28 | |
| 29 | class Statisticscxx . . $ statistics/Statistics# { |
| 30 | public: |
| 31 | Statisticscxx . . $ statistics/Statistics#Statistics(682275155a2e2978).(configurationcxx . . $ configuration/::Configurationcxx . . $ configuration/Configuration# *backend); |
| 32 | /** |
| 33 | * Records that a new game has been started. |
| 34 | */ |
| 35 | void game_startedcxx . . $ statistics/Statistics#game_started(49f6e7a06ebc5aa8).(); |
| 36 | |
| 37 | /** |
| 38 | * Records that a game was ended. |
| 39 | * \param score The score the game ended with. |
| 40 | */ |
| 41 | void game_finishedcxx . . $ statistics/Statistics#game_finished(d4f767463ce0a6b3).(int score); |
| 42 | |
| 43 | /** |
| 44 | * Resets the statistics data. |
| 45 | */ |
| 46 | void resetcxx . . $ statistics/Statistics#reset(49f6e7a06ebc5aa8).(); |
| 47 | |
| 48 | int games_startedcxx . . $ statistics/Statistics#games_started(b126dc7c1de90089).() { return _games_startedcxx . . $ statistics/Statistics#_games_started.; } |
| 49 | int games_finishedcxx . . $ statistics/Statistics#games_finished(b126dc7c1de90089).() { return _games_finishedcxx . . $ statistics/Statistics#_games_finished.; } |
| 50 | time_t last_resetcxx . . $ statistics/Statistics#last_reset(da6335ded91d79c2).() { return _last_resetcxx . . $ statistics/Statistics#_last_reset.; } |
| 51 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> score_distributioncxx . . $ statistics/Statistics#score_distribution(95cc8889724c44b9).() { return _score_distributioncxx . . $ statistics/Statistics#_score_distribution.; } |
| 52 | |
| 53 | private: |
| 54 | /** |
| 55 | * Saves the current status of the statistics object. |
| 56 | */ |
| 57 | void savecxx . . $ statistics/Statistics#save(49f6e7a06ebc5aa8).(); |
| 58 | |
| 59 | /** |
| 60 | * Loads data from the backend. |
| 61 | */ |
| 62 | void load_datacxx . . $ statistics/Statistics#load_data(49f6e7a06ebc5aa8).(); |
| 63 | |
| 64 | int _games_startedcxx . . $ statistics/Statistics#_games_started.; |
| 65 | int _games_finishedcxx . . $ statistics/Statistics#_games_finished.; |
| 66 | time_t _last_resetcxx . . $ statistics/Statistics#_last_reset.; |
| 67 | |
| 68 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> _score_distributioncxx . . $ statistics/Statistics#_score_distribution.; |
| 69 | configurationcxx . . $ configuration/::Configurationcxx . . $ configuration/Configuration# *backendcxx . . $ statistics/Statistics#backend.; |
| 70 | }; |
| 71 | |
| 72 | class BadConfigurationcxx . . $ statistics/BadConfiguration# : public stdcxx . . $ std/::exception { |
| 73 | virtual const char* whatcxx . . $ statistics/BadConfiguration#what(a9f41ea0e82d88cf).() const throw() |
| 74 | { |
| 75 | return "Bad Configuration"; |
| 76 | } |
| 77 | }; |
| 78 | |
| 79 | const int score_distribution_granualitycxx . . $ statistics/score_distribution_granuality. = 50; |
| 80 | // anything above the following score will be in the same slot |
| 81 | const int score_distribution_maxcxx . . $ statistics/score_distribution_max. = 500; |
| 82 | const int score_distributions_slotscxx . . $ statistics/score_distributions_slots. = score_distribution_maxcxx . . $ statistics/score_distribution_max./score_distribution_granualitycxx . . $ statistics/score_distribution_granuality.+1; |
| 83 | |
| 84 | } //namespace |
| 85 | |
| 86 | #endif |
| 87 |