Debian Codegraph @

src/statistics.cpp

raw symbols SCIP
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 #include <string>
22 #include <sstream>
23 #include <cstdlib>
24 #include <boost/algorithm/string/split.hpp>
25 #include <boost/algorithm/string/classification.hpp>
26 #include "statistics.h"cxx . . $ `<file>/src/statistics.h`/
27 #include "utility.h"cxx . . $ `<file>/src/utility.h`/
28
29 using namespace std;
30 using namespace statistics;
31 using namespace boost;
32
33 Statisticscxx . . $ statistics/Statistics#::Statisticscxx . . $ statistics/Statistics#Statistics(682275155a2e2978).(configurationcxx . . $ configuration/::Configurationcxx . . $ configuration/Configuration# *backend)
34 {
35 this->backendcxx . . $ statistics/Statistics#backend. = backend;
36 try {
37 load_datacxx . . $ statistics/Statistics#load_data(49f6e7a06ebc5aa8).();
38 } catch (stdcxx . . $ std/::exception &e) {
39 resetcxx . . $ statistics/Statistics#reset(49f6e7a06ebc5aa8).();
40 }
41 }
42
43 void Statisticscxx . . $ statistics/Statistics#::load_datacxx . . $ statistics/Statistics#load_data(49f6e7a06ebc5aa8).()
44 {
45 stringcxx . . $ std/string# tmpcxx . . $ std/__cxx11/basic_string#basic_string(49f6e7a06ebc5aa8).;
46 vectorcxx . . $ std/vector#<stringcxx . . $ std/string#> tmp_veccxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
47
48 tmp =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). backendcxx . . $ statistics/Statistics#backend.->getcxx . . $ configuration/Configuration#get(24764cae04130674).("statistics_games_started"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).);
49 _games_startedcxx . . $ statistics/Statistics#_games_started. = atoi(tmp.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).());
50
51 tmp =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). backendcxx . . $ statistics/Statistics#backend.->getcxx . . $ configuration/Configuration#get(24764cae04130674).("statistics_games_finished"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).);
52 _games_finishedcxx . . $ statistics/Statistics#_games_finished. = atoi(tmp.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).());
53
54 tmp =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). backendcxx . . $ statistics/Statistics#backend.->getcxx . . $ configuration/Configuration#get(24764cae04130674).("statistics_score_distribution"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).);
55 splitcxx . . $ boost/split(e7a7d932a175c7b3).(tmp_vec, tmp, is_any_ofcxx . . $ boost/algorithm/detail/is_any_ofF#is_any_ofF(4af6997af56a891e).(","));
56 if (tmp_vec.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() != score_distributions_slotscxx . . $ statistics/score_distributions_slots.)
57 throw BadConfigurationcxx . . $ statistics/BadConfiguration#();
58
59 for (stringcxx . . $ std/string# &i : tmp_vec) {
60 _score_distributioncxx . . $ statistics/Statistics#_score_distribution..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(atoi(i.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()));
61 }
62
63 istringstreamcxx . . $ std/istringstream# icxx . . $ std/__cxx11/basic_istringstream#basic_istringstream(d3c8ea0e6521074c).( backendcxx . . $ statistics/Statistics#backend.->getcxx . . $ configuration/Configuration#get(24764cae04130674).("statistics_last_reset"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).));
64 i >>cxx . . $ std/basic_istream#`operator>>`(927c60e123e2de33). _last_resetcxx . . $ statistics/Statistics#_last_reset.;
65 if (!_last_resetcxx . . $ statistics/Statistics#_last_reset.)
66 throw BadConfigurationcxx . . $ statistics/BadConfiguration#();
67
68 }
69
70 void Statisticscxx . . $ statistics/Statistics#::game_startedcxx . . $ statistics/Statistics#game_started(49f6e7a06ebc5aa8).()
71 {
72 _games_startedcxx . . $ statistics/Statistics#_games_started.++;
73 savecxx . . $ statistics/Statistics#save(49f6e7a06ebc5aa8).();
74 }
75
76 void Statisticscxx . . $ statistics/Statistics#::game_finishedcxx . . $ statistics/Statistics#game_finished(d4f767463ce0a6b3).(int score)
77 {
78 int score_slot;
79 _games_finishedcxx . . $ statistics/Statistics#_games_finished.++;
80
81 score_slot = score/score_distribution_granualitycxx . . $ statistics/score_distribution_granuality.;
82 score_slot = score_slot<score_distributions_slotscxx . . $ statistics/score_distributions_slots. ? score_slot : score_slot;
83 _score_distributioncxx . . $ statistics/Statistics#_score_distribution.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).score_slot]++;
84 savecxx . . $ statistics/Statistics#save(49f6e7a06ebc5aa8).();
85 }
86
87 void Statisticscxx . . $ statistics/Statistics#::savecxx . . $ statistics/Statistics#save(49f6e7a06ebc5aa8).() {
88 stringcxx . . $ std/string# tmpcxx . . $ std/__cxx11/basic_string#basic_string(49f6e7a06ebc5aa8).;
89 backendcxx . . $ statistics/Statistics#backend.->setcxx . . $ configuration/Configuration#set(f712b3a0dad3b1f).("statistics_games_started"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)., stringifycxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).(_games_startedcxx . . $ statistics/Statistics#_games_started.));
90 backendcxx . . $ statistics/Statistics#backend.->setcxx . . $ configuration/Configuration#set(f712b3a0dad3b1f).("statistics_games_finished"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)., stringifycxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).(_games_finishedcxx . . $ statistics/Statistics#_games_finished.));
91 backendcxx . . $ statistics/Statistics#backend.->setcxx . . $ configuration/Configuration#set(f712b3a0dad3b1f).("statistics_last_reset"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)., stringifycxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).(_last_resetcxx . . $ statistics/Statistics#_last_reset.));
92
93 tmp =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "";
94 for (int &i : _score_distributioncxx . . $ statistics/Statistics#_score_distribution.) {
95 tmp +=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75). stringifycxx . . $ stringify(913c38b53db8afbc).(i) +cxx . . $ std/operator+(900ec9581c410ad9). ",";
96 }
97 //delete trailing comma
98 tmp =cxx . . $ std/__cxx11/basic_string#`operator=`(706c69e8c742c906). tmp.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(0, tmp.sizecxx . . $ std/__cxx11/basic_string#size(48278e53df7b52a5).()-1);
99 backendcxx . . $ statistics/Statistics#backend.->setcxx . . $ configuration/Configuration#set(f712b3a0dad3b1f).("statistics_score_distribution"cxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)., tmpcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).);
100
101 backendcxx . . $ statistics/Statistics#backend.->savecxx . . $ configuration/Configuration#save(49f6e7a06ebc5aa8).();
102 }
103
104 void Statisticscxx . . $ statistics/Statistics#::resetcxx . . $ statistics/Statistics#reset(49f6e7a06ebc5aa8).() {
105 _games_startedcxx . . $ statistics/Statistics#_games_started. = 0;
106 _games_finishedcxx . . $ statistics/Statistics#_games_finished. = 0;
107 _last_resetcxx . . $ statistics/Statistics#_last_reset. = time(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
108
109 _score_distributioncxx . . $ statistics/Statistics#_score_distribution. =cxx . . $ std/vector#`operator=`(27b3db0518c64371). vectorcxx . . $ std/vector#vector(229e4d6bd205de31).<int>(score_distributions_slotscxx . . $ statistics/score_distributions_slots., 0);
110
111 savecxx . . $ statistics/Statistics#save(49f6e7a06ebc5aa8).();
112 }