31template<
typename Input,
typename Output>
51 virtual Output
Run(
const Input &input) = 0;
98template<
typename Input,
typename Output>
130 if (this->
ready)
throw std::invalid_argument(
"Pipeline is already ready");
131 if (this->
stages.empty()) {
132 if (!std::is_same<Input, I>::value) {
133 throw std::invalid_argument(
"The initial input type is not correct");
141 this->
stages.push_back(stage);
183 Output
Run(
const Input &input)
override {
186 throw std::runtime_error(
"This is an illegal action: the pipeline is not ready yet");
198 std::vector<std::reference_wrapper<Action>>
stages;
Action is an interface that wraps a function that does something.
Definition pipeline.hpp:15
virtual void DoAction()=0
Performs some action.
Pipeline is composite Stage (i.e.
Definition pipeline.hpp:99
Output Run(const Input &input) override
Executes this Pipeline.
Definition pipeline.hpp:183
Input * firstResource
The pointer to the variable that will store the first input.
Definition pipeline.hpp:200
Pipeline & Complete(Stage< I, Output > &stage)
Adds a stage to the pipeline and marks it as the last stage, preventing further manipulation of the P...
Definition pipeline.hpp:160
bool ready
An indicator for if this Pipeline is ready.
Definition pipeline.hpp:206
void ** lastProduct
A temporary variable that always points to the last Stage's product field.
Definition pipeline.hpp:204
Pipeline & AddStage(Stage< I, O > &stage)
Adds a stage to this pipeline.
Definition pipeline.hpp:128
Pipeline(std::vector< std::reference_wrapper< Action > > &stages)
Constructs a Pipeline.
Definition pipeline.hpp:106
Pipeline()
Constructs an empty Pipeline.
Definition pipeline.hpp:112
std::vector< std::reference_wrapper< Action > > stages
The stages of this.
Definition pipeline.hpp:198
Output finalProduct
The final product (output)
Definition pipeline.hpp:202
A Stage is a data structure that wraps a function, and taking in parameter Input and returning Output...
Definition pipeline.hpp:32
Input & GetResource()
Returns the stored input of this.
Definition pipeline.hpp:65
Output * product
The pointer to the stored output for this.
Definition pipeline.hpp:79
Output *& GetProduct()
Returns the stored output of this.
Definition pipeline.hpp:73
void DoAction() override
Executes Run (with a stored input and storing the output)
Definition pipeline.hpp:56
virtual ~Stage()=default
Destroys this.
virtual Output Run(const Input &input)=0
Runs this stage.
Stage()=default
Constructs a new Stage.
Input resource
The stored input for this.
Definition pipeline.hpp:77
Definition calibrate.cpp:7