1 : // Copyright 2013 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares a Filterable object, which can be given a RelativeAddressFilter to
16 : // be respected while doing its work.
17 :
18 : #ifndef SYZYGY_BLOCK_GRAPH_FILTERABLE_H_
19 : #define SYZYGY_BLOCK_GRAPH_FILTERABLE_H_
20 :
21 : #include "syzygy/block_graph/filter_util.h"
22 :
23 : namespace block_graph {
24 :
25 : class Filterable {
26 : public:
27 E : Filterable() : filter_(NULL) { }
28 E : explicit Filterable(const RelativeAddressFilter* filter) : filter_(filter) { }
29 :
30 : // Sets the filter to be used by this object.
31 : // @param filter The filter to use. May be NULL.
32 E : void set_filter(const RelativeAddressFilter* filter) {
33 E : filter_ = filter;
34 E : }
35 :
36 : // Returns the filter currently used by this object.
37 E : const RelativeAddressFilter* filter() const { return filter_; }
38 :
39 : // Determines if the given object is filtered.
40 : // @param basic_block The basic block to be checked.
41 : // @returns true if the object filtered, false otherwise.
42 : // @note If no filter is specified this always returns false.
43 : bool IsFiltered(const block_graph::BlockGraph::Block* block) const;
44 : bool IsFiltered(const block_graph::BasicBlock* basic_block) const;
45 : bool IsFiltered(const block_graph::BasicCodeBlock* basic_block) const;
46 : bool IsFiltered(const block_graph::BasicDataBlock* basic_block) const;
47 : bool IsFiltered(const block_graph::Instruction& instruction) const;
48 :
49 : private:
50 : const RelativeAddressFilter* filter_;
51 :
52 : DISALLOW_COPY_AND_ASSIGN(Filterable);
53 : };
54 :
55 : } // namespace block_graph
56 :
57 : #endif // SYZYGY_BLOCK_GRAPH_FILTERABLE_H_
|