From 32e97cac52ac6de69a9804d845b74199371e5d2a Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Tue, 22 Aug 2023 15:09:18 -0700 Subject: [PATCH] planner: add span_t == op --- resource/planner/c++/planner.cpp | 48 ++++++++++++++++++++++---------- resource/planner/c++/planner.hpp | 3 ++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/resource/planner/c++/planner.cpp b/resource/planner/c++/planner.cpp index 326cea32d..a15c93949 100644 --- a/resource/planner/c++/planner.cpp +++ b/resource/planner/c++/planner.cpp @@ -21,6 +21,37 @@ extern "C" { #include "planner.hpp" +/**************************************************************************** + * * + * Public Span_t Methods * + * * + ****************************************************************************/ + +bool span_t::operator== (const span_t &o) const +{ + if (start != o.start) + return false; + if (last != o.last) + return false; + if (span_id != o.span_id) + return false; + if (planned != o.planned) + return false; + if (in_system != o.in_system) + return false; + if ((*(start_p) != *(o.start_p))) + return false; + if ((*(last_p) != *(o.last_p))) + return false; + + return true; +} + +bool span_t::operator!= (const span_t &o) const +{ + return !operator == (o); +} + /**************************************************************************** * * * Public Planner Methods * @@ -441,21 +472,8 @@ bool planner::span_lookups_equal (const planner &o) const return false; if (this_it.first != other->first) return false; - if (this_it.second->start != other->second->start) - return false; - if (this_it.second->last != other->second->last) - return false; - if (this_it.second->span_id != other->second->span_id) - return false; - if (this_it.second->planned != other->second->planned) - return false; - if (this_it.second->in_system != other->second->in_system) - return false; - if (this_it.second->in_system != other->second->in_system) - return false; - if (*(this_it.second->start_p) != *(other->second->start_p)) - return false; - if (*(this_it.second->last_p) != *(other->second->last_p)) + // Compare span_t + if (*(this_it.second) != *(other->second)) return false; } } diff --git a/resource/planner/c++/planner.hpp b/resource/planner/c++/planner.hpp index fd0084c6e..abdd2a3a8 100644 --- a/resource/planner/c++/planner.hpp +++ b/resource/planner/c++/planner.hpp @@ -23,6 +23,9 @@ struct request_t { /*! Node in a span interval tree to enable fast retrieval of intercepting spans. */ struct span_t { + bool operator== (const span_t &o) const; + bool operator!= (const span_t &o) const; + int64_t start; /* start time of the span */ int64_t last; /* end time of the span */ int64_t span_id; /* unique span id */