Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 1 | // 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 Reyes | b10320d | 2010-03-31 16:44:44 -0700 | [diff] [blame] | 10 | #include <string> |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 11 | #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 | |
| 19 | namespace chromeos_update_engine { |
| 20 | |
| 21 | struct EdgeProperties { |
| 22 | std::vector<Extent> extents; // filesystem extents represented |
| 23 | }; |
| 24 | |
| 25 | struct Vertex { |
Andrew de los Reyes | b10320d | 2010-03-31 16:44:44 -0700 | [diff] [blame] | 26 | Vertex() : index(-1), lowlink(-1) {} |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 27 | 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 Reyes | b10320d | 2010-03-31 16:44:44 -0700 | [diff] [blame] | 42 | DeltaArchiveManifest_InstallOperation op; |
| 43 | std::string file_name; |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 44 | |
| 45 | typedef std::vector<Vertex>::size_type Index; |
| 46 | static const Vertex::Index kInvalidIndex = -1; |
| 47 | }; |
| 48 | |
| 49 | typedef std::vector<Vertex> Graph; |
| 50 | |
| 51 | typedef std::pair<Vertex::Index, Vertex::Index> Edge; |
| 52 | |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 53 | const uint64_t kSparseHole = kuint64max; |
Andrew de los Reyes | b10320d | 2010-03-31 16:44:44 -0700 | [diff] [blame] | 54 | |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 55 | } // namespace chromeos_update_engine |
| 56 | |
| 57 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_GRAPH_TYPES_H__ |