1 : // Copyright 2012 Google Inc.
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 an ordering that orders blocks as explicitly specified in an
16 : // Reorderer::Order object. Blocks are uniquely specified by their addresses
17 : // in the most recent ImageLayout in which they took part.
18 :
19 : #ifndef SYZYGY_REORDER_ORDERERS_EXPLICIT_ORDERER_H_
20 : #define SYZYGY_REORDER_ORDERERS_EXPLICIT_ORDERER_H_
21 :
22 : #include "syzygy/block_graph/orderers/named_orderer.h"
23 : #include "syzygy/reorder/reorderer.h"
24 :
25 : namespace reorder {
26 : namespace orderers {
27 :
28 : class ExplicitOrderer
29 : : public block_graph::orderers::NamedOrdererImpl<ExplicitOrderer> {
30 : public:
31 : typedef block_graph::BlockGraph BlockGraph;
32 : typedef block_graph::OrderedBlockGraph OrderedBlockGraph;
33 :
34 : // Constructor.
35 : // @param order a pointer to the order to be applied. The order object must
36 : // outlive this orderer.
37 E : explicit ExplicitOrderer(const Reorderer::Order* order) : order_(order) {
38 E : DCHECK(order != NULL);
39 E : }
40 :
41 : // Applies this orderer to the provided block graph.
42 : //
43 : // @param ordered_block_graph the block graph to order.
44 : // @returns true on success, false otherwise.
45 : virtual bool OrderBlockGraph(OrderedBlockGraph* ordered_block_graph,
46 : BlockGraph::Block* header_block_unused) OVERRIDE;
47 :
48 : static const char kOrdererName[];
49 :
50 : private:
51 : const Reorderer::Order* order_;
52 :
53 : DISALLOW_COPY_AND_ASSIGN(ExplicitOrderer);
54 : };
55 :
56 : } // namespace orderers
57 : } // namespace reorder
58 :
59 : #endif // SYZYGY_REORDER_ORDERERS_EXPLICIT_ORDERER_H_
|