From de50cd15f12216760bb746ec8936fc1501113425 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 22 Aug 2021 13:09:25 +0100 Subject: Add EventCounter class --- lib/eventCounter.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/eventCounter.cpp (limited to 'lib/eventCounter.cpp') diff --git a/lib/eventCounter.cpp b/lib/eventCounter.cpp new file mode 100644 index 0000000..92383c5 --- /dev/null +++ b/lib/eventCounter.cpp @@ -0,0 +1,30 @@ +#include "eventCounter.h" +#include + +namespace MyGrate { + void + EventCounter::tick(mariadb_rpl_event e) + { + counters[e]++; + } + const EventCounter::Counters & + EventCounter::getAll() const + { + return counters; + } + unsigned long + EventCounter::get(mariadb_rpl_event e) const + { + return counters[e]; + } + bool + EventCounter::operator>=(const EventCounter & target) const + { + for (size_t e {}; e < ENUM_END_EVENT; e++) { + if (counters[e] < target.counters[e]) { + return false; + } + } + return true; + } +} -- cgit v1.2.3