From a7620015acc2401165b4587cbb6c9a118d944493 Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 14 Apr 2025 23:40:25 -0400 Subject: Add preprocess method to storage, removing nearly all duplication --- src/storage.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/storage.cc') diff --git a/src/storage.cc b/src/storage.cc index 17c902d..ee2e7e7 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -1,6 +1,7 @@ #include "storage.h" #include "definitions.h" #include +#include Storage::Storage(int delay) { @@ -20,6 +21,18 @@ Storage::view(int base, int lines) const return ret; } +int +Storage::preprocess(void *id) +{ + if (id == nullptr) + throw std::invalid_argument("Accessor cannot be nullptr."); + + if (this->current_request == nullptr) + this->current_request = id; + + return this->current_request == id; +} + int Storage::is_data_ready() { -- cgit v1.2.3