graph_utils.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  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. //
  16. #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_
  17. #define UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_
  18. #include <vector>
  19. #include <base/macros.h>
  20. #include "update_engine/payload_generator/graph_types.h"
  21. #include "update_engine/update_metadata.pb.h"
  22. // A few utility functions for graphs
  23. namespace chromeos_update_engine {
  24. namespace graph_utils {
  25. // Returns the number of blocks represented by all extents in the edge.
  26. uint64_t EdgeWeight(const Graph& graph, const Edge& edge);
  27. // These add a read-before dependency from graph[src] -> graph[dst]. If the dep
  28. // already exists, the block/s is/are added to the existing edge.
  29. void AddReadBeforeDep(Vertex* src, Vertex::Index dst, uint64_t block);
  30. void AddReadBeforeDepExtents(Vertex* src,
  31. Vertex::Index dst,
  32. const std::vector<Extent>& extents);
  33. void DropWriteBeforeDeps(Vertex::EdgeMap* edge_map);
  34. // For each node N in graph, drop all edges N->|index|.
  35. void DropIncomingEdgesTo(Graph* graph, Vertex::Index index);
  36. void DumpGraph(const Graph& graph);
  37. } // namespace graph_utils
  38. } // namespace chromeos_update_engine
  39. #endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_GRAPH_UTILS_H_