X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_callset.hpp;fp=common%2Ftrace_callset.hpp;h=4a4a52d397c6cef90804acfb0f16b5a7c931a6cc;hb=9db16b3989481f8d6dfc8932d760fcc16217ecbd;hp=b679d94867b3f095f78b574e07c4075deccafc7e;hpb=4f74cc67dd2b46d2abc0be5663c992410420091b;p=apitrace diff --git a/common/trace_callset.hpp b/common/trace_callset.hpp index b679d94..4a4a52d 100644 --- a/common/trace_callset.hpp +++ b/common/trace_callset.hpp @@ -48,6 +48,7 @@ #define _TRACE_CALLSET_HPP_ +#include #include #include "trace_model.hpp" @@ -106,12 +107,15 @@ namespace trace { // A collection of call ranges class CallSet { + private: + CallRange limits; + public: // TODO: use binary tree to speed up lookups typedef std::list< CallRange > RangeList; RangeList ranges; - CallSet() {} + CallSet(): limits(std::numeric_limits::min(), std::numeric_limits::max()) {} CallSet(CallFlags freq); @@ -128,6 +132,16 @@ namespace trace { if (range.start <= range.stop && range.freq != FREQUENCY_NONE) { + if (empty()) { + limits.start = range.start; + limits.stop = range.stop; + } else { + if (range.start < limits.start) + limits.start = range.start; + if (range.stop > limits.stop) + limits.stop = range.stop; + } + RangeList::iterator it = ranges.begin(); while (it != ranges.end() && it->start < range.start) { ++it; @@ -155,6 +169,14 @@ namespace trace { contains(const trace::Call &call) { return contains(call.no, call.flags); } + + CallNo getFirst() { + return limits.start; + } + + CallNo getLast() { + return limits.stop; + } };