blob: b32e666e8a577875a8ab822cb10274390251c39b [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
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 Reyes0ce161b2010-02-22 15:27:01 -080016
Alex Vakulenko072359c2014-07-18 11:41:07 -070017#ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_
18#define UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080019
20#include <vector>
Alex Deymo161c4a12014-05-16 15:56:21 -070021
Ben Chan05735a12014-09-03 07:48:22 -070022#include <base/macros.h>
Alex Deymo161c4a12014-05-16 15:56:21 -070023
24#include "update_engine/payload_generator/graph_types.h"
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080025#include "update_engine/update_metadata.pb.h"
26
27// A few utility functions for graphs
28
29namespace chromeos_update_engine {
30
31namespace graph_utils {
32
33// Returns the number of blocks represented by all extents in the edge.
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070034uint64_t EdgeWeight(const Graph& graph, const Edge& edge);
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080035
Andrew de los Reyes1bc16ab2010-10-06 15:07:21 -070036// 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.
38void AddReadBeforeDep(Vertex* src,
39 Vertex::Index dst,
40 uint64_t block);
41void AddReadBeforeDepExtents(Vertex* src,
42 Vertex::Index dst,
43 const std::vector<Extent>& extents);
44
45void DropWriteBeforeDeps(Vertex::EdgeMap* edge_map);
46
47// For each node N in graph, drop all edges N->|index|.
48void DropIncomingEdgesTo(Graph* graph, Vertex::Index index);
49
Andrew de los Reyes1bc16ab2010-10-06 15:07:21 -070050void DumpGraph(const Graph& graph);
51
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080052} // namespace graph_utils
53
54} // namespace chromeos_update_engine
55
Alex Vakulenko072359c2014-07-18 11:41:07 -070056#endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_