Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (C) 2009 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 16 | |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_ |
| 18 | #define UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_ |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 19 | |
| 20 | #include <vector> |
Alex Deymo | 161c4a1 | 2014-05-16 15:56:21 -0700 | [diff] [blame] | 21 | |
Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 22 | #include <base/macros.h> |
Alex Deymo | 161c4a1 | 2014-05-16 15:56:21 -0700 | [diff] [blame] | 23 | |
| 24 | #include "update_engine/payload_generator/graph_types.h" |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 25 | #include "update_engine/update_metadata.pb.h" |
| 26 | |
| 27 | // A few utility functions for graphs |
| 28 | |
| 29 | namespace chromeos_update_engine { |
| 30 | |
| 31 | namespace graph_utils { |
| 32 | |
| 33 | // Returns the number of blocks represented by all extents in the edge. |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 34 | uint64_t EdgeWeight(const Graph& graph, const Edge& edge); |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 35 | |
Andrew de los Reyes | 1bc16ab | 2010-10-06 15:07:21 -0700 | [diff] [blame] | 36 | // These add a read-before dependency from graph[src] -> graph[dst]. If the dep |
| 37 | // already exists, the block/s is/are added to the existing edge. |
| 38 | void AddReadBeforeDep(Vertex* src, |
| 39 | Vertex::Index dst, |
| 40 | uint64_t block); |
| 41 | void AddReadBeforeDepExtents(Vertex* src, |
| 42 | Vertex::Index dst, |
| 43 | const std::vector<Extent>& extents); |
| 44 | |
| 45 | void DropWriteBeforeDeps(Vertex::EdgeMap* edge_map); |
| 46 | |
| 47 | // For each node N in graph, drop all edges N->|index|. |
| 48 | void DropIncomingEdgesTo(Graph* graph, Vertex::Index index); |
| 49 | |
Andrew de los Reyes | 1bc16ab | 2010-10-06 15:07:21 -0700 | [diff] [blame] | 50 | void DumpGraph(const Graph& graph); |
| 51 | |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 52 | } // namespace graph_utils |
| 53 | |
| 54 | } // namespace chromeos_update_engine |
| 55 | |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 56 | #endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_ |