1 /**************************************************************************
3 * Copyright 2012 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
27 * Representation of call sets.
32 * | range ( ',' ? range ) *
34 * range = interval ( '/' frequency )
38 * | start_number '-' end_number
42 * | "rendertarget" | "fbo"
47 #ifndef _TRACE_CALLSET_HPP_
48 #define _TRACE_CALLSET_HPP_
53 #include "trace_model.hpp"
59 // Should match Call::no
60 typedef unsigned CallNo;
63 // Aliases for call flags
66 FREQUENCY_FRAME = CALL_FLAG_END_FRAME,
67 FREQUENCY_RENDERTARGET = CALL_FLAG_END_FRAME | CALL_FLAG_SWAP_RENDERTARGET,
68 FREQUENCY_RENDER = CALL_FLAG_RENDER,
69 FREQUENCY_ALL = 0xffffffff
72 // A linear range of calls
81 CallRange(CallNo callNo) :
88 CallRange(CallNo _start, CallNo _stop, CallNo _step = 1, CallFlags _freq = FREQUENCY_ALL) :
96 contains(CallNo callNo, CallFlags callFlags) const {
97 return callNo >= start &&
99 ((callNo - start) % step) == 0 &&
100 ((callFlags & freq) ||
101 freq == FREQUENCY_ALL);
106 // A collection of call ranges
110 // TODO: use binary tree to speed up lookups
111 typedef std::list< CallRange > RangeList;
116 CallSet(CallFlags freq);
118 CallSet(const char *str);
123 return ranges.empty();
127 addRange(const CallRange & range) {
128 if (range.start <= range.stop &&
129 range.freq != FREQUENCY_NONE) {
131 RangeList::iterator it = ranges.begin();
132 while (it != ranges.end() && it->start < range.start) {
136 ranges.insert(it, range);
141 contains(CallNo callNo, CallFlags callFlags = FREQUENCY_ALL) const {
145 RangeList::const_iterator it;
146 for (it = ranges.begin(); it != ranges.end() && it->start <= callNo; ++it) {
147 if (it->contains(callNo, callFlags)) {
155 contains(const trace::Call &call) {
156 return contains(call.no, call.flags);
161 CallSet parse(const char *string);
164 } /* namespace trace */
167 #endif /* _TRACE_CALLSET_HPP_ */