Add get_data methodes

This commit is contained in:
marcelb 2024-01-06 16:08:06 +01:00
parent 2431e4b9bc
commit 8210800683
5 changed files with 28 additions and 1 deletions

View File

@ -4,6 +4,10 @@
"ostream": "cpp",
"string": "cpp",
"vector": "cpp",
"map": "cpp"
"map": "cpp",
"*.tcc": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"system_error": "cpp"
}
}

View File

@ -54,6 +54,17 @@ class Metrics {
*/
vector<string> keys();
/**
* Metoda vraća map<string, uint> svih mjerenja
*/
map<string, uint> get_data();
/**
* Metoda vraća map<string, uint> svih mjerenja i resetira brojače
*/
map<string, uint> get_data_and_clear();
};

View File

@ -22,3 +22,14 @@ vector<string> marcelb::Metrics::keys() {
return _keys;
}
map<string, uint> marcelb::Metrics::get_data() {
return counters;
}
map<string, uint> marcelb::Metrics::get_data_and_clear() {
auto data = counters;
clear();
return counters;
}

BIN
test/test

Binary file not shown.

View File

@ -17,5 +17,6 @@ int main() {
cout << " access " << metrika["access"] << endl;
return 0;
}