src/DataManager/transforms/TransformPipeline.hpp
src/DataManager/transforms/TransformPipeline.hpp
Classes
| Name | |
|---|---|
| struct | PipelineStep Represents a single step in a transformation pipeline. |
| struct | StepResult Represents execution result of a pipeline step. |
| struct | PipelineResult Represents the complete pipeline execution result. |
| class | TransformPipeline Factory and execution engine for transformation pipelines. |
Types
| Name | |
|---|---|
| using std::function< void(int step_index, std::string const &step_name, int step_progress, int overall_progress)> | PipelineProgressCallback Progress callback for pipeline execution. |
Types Documentation
using PipelineProgressCallback
using PipelineProgressCallback = std::function<void(int step_index, std::string const& step_name, int step_progress, int overall_progress)>;Progress callback for pipeline execution.
Parameters:
- step_index Current step being executed (0-based)
- step_name Name of the current step
- step_progress Progress of current step (0-100)
- overall_progress Overall pipeline progress (0-100)
Source code
#ifndef TRANSFORM_PIPELINE_HPP
#define TRANSFORM_PIPELINE_HPP
#include "TimeFrame/StrongTimeTypes.hpp"
#include "data_transforms.hpp"
#include <nlohmann/json.hpp>
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <unordered_map>
class DataManager;
class TransformRegistry;
using PipelineProgressCallback = std::function<void(int step_index, std::string const& step_name, int step_progress, int overall_progress)>;
struct PipelineStep {
std::string step_id; // Unique identifier for this step
std::string transform_name; // Name of the transform operation
std::string input_key; // Input data key from DataManager
std::string output_key; // Output data key (empty = temporary)
nlohmann::json parameters; // Parameters as JSON object
int phase = 0; // Execution phase (0 = first)
bool enabled = true; // Whether this step is enabled
// Optional metadata
std::string description; // Human-readable description
std::vector<std::string> tags; // Tags for organization
};
struct StepResult {
bool success = false;
std::string error_message;
std::string output_key; // Key where result was stored (if any)
DataTypeVariant result_data; // The actual result data
double execution_time_ms = 0.0; // Execution time in milliseconds
};
struct PipelineResult {
bool success = false;
std::string error_message;
std::vector<StepResult> step_results;
double total_execution_time_ms = 0.0;
int steps_completed = 0;
int total_steps = 0;
};
class TransformPipeline {
public:
TransformPipeline(DataManager* data_manager, TransformRegistry* registry);
bool loadFromJson(nlohmann::json const& json_config);
bool loadFromJsonFile(std::string const& json_file_path);
PipelineResult execute(PipelineProgressCallback progress_callback = nullptr);
StepResult executeStep(PipelineStep const& step, ProgressCallback progress_callback = nullptr);
std::vector<std::string> validate() const;
std::vector<PipelineStep> const& getSteps() const { return steps_; }
nlohmann::json const& getMetadata() const { return metadata_; }
void clear();
nlohmann::json exportToJson() const;
bool saveToJsonFile(std::string const& json_file_path) const;
private:
DataManager* data_manager_;
TransformRegistry* registry_;
std::vector<PipelineStep> steps_;
nlohmann::json metadata_;
// Execution state
std::map<std::string, DataTypeVariant> temporary_data_;
std::pair<bool, PipelineStep> parseStep(nlohmann::json const& step_json, int step_index);
std::unique_ptr<TransformParametersBase> createParametersFromJson(
std::string const& transform_name,
nlohmann::json const& param_json);
bool setParameterValue(TransformParametersBase* param_obj,
std::string const& param_name,
nlohmann::json const& json_value,
std::string const& transform_name);
std::pair<bool, DataTypeVariant> getInputData(std::string const& input_key);
void storeOutputData(std::string const& output_key,
DataTypeVariant const& data,
std::string const& step_id,
TimeKey const& time_key);
std::map<int, std::vector<int>> groupStepsByPhase() const;
std::vector<StepResult> executePhase(
std::vector<int> const& phase_steps,
int phase_number,
PipelineProgressCallback progress_callback);
void substituteVariables(nlohmann::json& json, std::unordered_map<std::string, std::string> const& variables) const;
std::unordered_map<std::string, std::string> extractVariables() const;
};
#endif // TRANSFORM_PIPELINE_HPPUpdated on 2026-11-13 at 20:25:43 +0000