blob: 6595e57fcfec5aa0abeb947a5ff700f5b485edfc [file] [log] [blame]
Alex Deymo759c2752014-03-17 21:09:36 -07001// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -08002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Vakulenko072359c2014-07-18 11:41:07 -07005#ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_
6#define UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -08007
8#include <vector>
Alex Deymo161c4a12014-05-16 15:56:21 -07009
Ben Chan05735a12014-09-03 07:48:22 -070010#include <base/macros.h>
Alex Deymo161c4a12014-05-16 15:56:21 -070011
12#include "update_engine/payload_generator/graph_types.h"
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080013#include "update_engine/update_metadata.pb.h"
14
15// A few utility functions for graphs
16
17namespace chromeos_update_engine {
18
19namespace graph_utils {
20
21// Returns the number of blocks represented by all extents in the edge.
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070022uint64_t EdgeWeight(const Graph& graph, const Edge& edge);
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080023
Andrew de los Reyes1bc16ab2010-10-06 15:07:21 -070024// 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.
26void AddReadBeforeDep(Vertex* src,
27 Vertex::Index dst,
28 uint64_t block);
29void AddReadBeforeDepExtents(Vertex* src,
30 Vertex::Index dst,
31 const std::vector<Extent>& extents);
32
33void DropWriteBeforeDeps(Vertex::EdgeMap* edge_map);
34
35// For each node N in graph, drop all edges N->|index|.
36void DropIncomingEdgesTo(Graph* graph, Vertex::Index index);
37
Andrew de los Reyes1bc16ab2010-10-06 15:07:21 -070038void DumpGraph(const Graph& graph);
39
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080040} // namespace graph_utils
41
42} // namespace chromeos_update_engine
43
Alex Vakulenko072359c2014-07-18 11:41:07 -070044#endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_