blob: e7867f6f4067638c41093008fe40caa7d36d189d [file] [log] [blame]
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -08001// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_GRAPH_TYPES_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_GRAPH_TYPES_H__
7
8#include <map>
9#include <set>
Andrew de los Reyesb10320d2010-03-31 16:44:44 -070010#include <string>
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080011#include <utility>
12#include <vector>
13#include "base/basictypes.h"
14#include "update_engine/update_metadata.pb.h"
15
16// A few classes that help in generating delta images use these types
17// for the graph work.
18
19namespace chromeos_update_engine {
20
21struct EdgeProperties {
22 std::vector<Extent> extents; // filesystem extents represented
23};
24
25struct Vertex {
Andrew de los Reyesb10320d2010-03-31 16:44:44 -070026 Vertex() : index(-1), lowlink(-1) {}
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080027 typedef std::map<std::vector<Vertex>::size_type, EdgeProperties> EdgeMap;
28 EdgeMap out_edges;
29
30 // We sometimes wish to consider a subgraph of a graph. A subgraph would have
31 // a subset of the vertices from the graph and a subset of the edges.
32 // When considering this vertex within a subgraph, subgraph_edges stores
33 // the out-edges.
34 typedef std::set<std::vector<Vertex>::size_type> SubgraphEdgeMap;
35 SubgraphEdgeMap subgraph_edges;
36
37 // For Tarjan's algorithm:
38 std::vector<Vertex>::size_type index;
39 std::vector<Vertex>::size_type lowlink;
40
41 // Other Vertex properties:
Andrew de los Reyesb10320d2010-03-31 16:44:44 -070042 DeltaArchiveManifest_InstallOperation op;
43 std::string file_name;
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080044
45 typedef std::vector<Vertex>::size_type Index;
46 static const Vertex::Index kInvalidIndex = -1;
47};
48
49typedef std::vector<Vertex> Graph;
50
51typedef std::pair<Vertex::Index, Vertex::Index> Edge;
52
Andrew de los Reyes09e56d62010-04-23 13:45:53 -070053const uint64_t kSparseHole = kuint64max;
Andrew de los Reyesb10320d2010-03-31 16:44:44 -070054
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080055} // namespace chromeos_update_engine
56
57#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_GRAPH_TYPES_H__