#pragma once #include "PipelineGraph.h" #include "PipelineStageSpec.h" #include #include namespace whetstone { class PipelineExecutionPlan { public: void addStage(const PipelineStageSpec& spec) { registry_.registerStage(spec); graph_.addStage(spec.stageId); } void addEdge(const std::string& fromId, const std::string& toId) { graph_.addEdge(fromId, toId); } // Stages in topological order. std::vector executionOrder() const { std::vector result; for (const auto& id : graph_.topologicalOrder()) result.push_back(registry_.getStage(id)); return result; } // Language per stage in execution order. std::vector languageSequence() const { std::vector langs; for (const auto& spec : executionOrder()) langs.push_back(spec.language); return langs; } bool isValid() const { return !graph_.hasCycle() && graph_.stageCount() > 0; } // Pairs "langA->langB" wherever adjacent stages in execution order differ in language. std::vector boundaryPairs() const { auto order = executionOrder(); std::vector pairs; for (std::size_t i = 1; i < order.size(); ++i) { if (order[i-1].language != order[i].language) pairs.push_back(order[i-1].language + "->" + order[i].language); } return pairs; } private: PipelineStageRegistry registry_; PipelineGraph graph_; }; } // namespace whetstone