Alex Deymo | 759c275 | 2014-03-17 21:09:36 -0700 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_ |
| 6 | #define UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_ |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 7 | |
| 8 | #include <vector> |
Alex Deymo | 161c4a1 | 2014-05-16 15:56:21 -0700 | [diff] [blame] | 9 | |
Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 10 | #include <base/macros.h> |
Alex Deymo | 161c4a1 | 2014-05-16 15:56:21 -0700 | [diff] [blame] | 11 | |
| 12 | #include "update_engine/payload_generator/graph_types.h" |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 13 | #include "update_engine/update_metadata.pb.h" |
| 14 | |
| 15 | // A few utility functions for graphs |
| 16 | |
| 17 | namespace chromeos_update_engine { |
| 18 | |
| 19 | namespace graph_utils { |
| 20 | |
| 21 | // 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] | 22 | uint64_t EdgeWeight(const Graph& graph, const Edge& edge); |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 23 | |
Andrew de los Reyes | 1bc16ab | 2010-10-06 15:07:21 -0700 | [diff] [blame] | 24 | // These add a read-before dependency from graph[src] -> graph[dst]. If the dep |
| 25 | // already exists, the block/s is/are added to the existing edge. |
| 26 | void AddReadBeforeDep(Vertex* src, |
| 27 | Vertex::Index dst, |
| 28 | uint64_t block); |
| 29 | void AddReadBeforeDepExtents(Vertex* src, |
| 30 | Vertex::Index dst, |
| 31 | const std::vector<Extent>& extents); |
| 32 | |
| 33 | void DropWriteBeforeDeps(Vertex::EdgeMap* edge_map); |
| 34 | |
| 35 | // For each node N in graph, drop all edges N->|index|. |
| 36 | void DropIncomingEdgesTo(Graph* graph, Vertex::Index index); |
| 37 | |
Andrew de los Reyes | 1bc16ab | 2010-10-06 15:07:21 -0700 | [diff] [blame] | 38 | void DumpGraph(const Graph& graph); |
| 39 | |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 40 | } // namespace graph_utils |
| 41 | |
| 42 | } // namespace chromeos_update_engine |
| 43 | |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 44 | #endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_ |