FOUND
Loading...
Searching...
No Matches
found::SequentialPipeline< Input, Output, N > Class Template Reference

SequentialPipeline is composite Stage (i.e. More...

#include <pipelines.hpp>

Inheritance diagram for found::SequentialPipeline< Input, Output, N >:
Collaboration diagram for found::SequentialPipeline< Input, Output, N >:

Public Member Functions

 SequentialPipeline ()=default
 Constructs an empty SequentialPipeline.
 
template<typename I , typename O >
SequentialPipelineAddStage (FunctionStage< I, O > &stage)
 Adds a stage to this pipeline.
 
template<typename I >
SequentialPipelineComplete (FunctionStage< I, Output > &stage)
 Adds a stage to the pipeline and marks it as the last stage, preventing further manipulation of the SequentialPipeline.
 
Output Run (const Input &input) override
 Executes this SequentialPipeline.
 
- Public Member Functions inherited from found::Pipeline< Input, Output, N >
void DoAction () override
 Runs a Pipeline.
 
- Public Member Functions inherited from found::FunctionStage< Input, Output >
 FunctionStage ()=default
 Constructs a new Stage.
 
virtual ~FunctionStage ()=default
 Destroys this.
 
Input & GetResource ()
 Returns the stored input of this.
 
Output *& GetProduct ()
 Returns the stored output of this.
 
- Public Member Functions inherited from found::Stage< const raw_type< Input > &, raw_type< Output > >
virtual raw_type< Output > Run (const raw_type< Input > & input)=0
 Runs this stage.
 

Private Attributes

Input * firstResource = nullptr
 The pointer to the variable that will store the first input.
 
void ** lastProduct = nullptr
 A temporary variable that always points to the last Stage's product field.
 

Additional Inherited Members

- Protected Member Functions inherited from found::Pipeline< Input, Output, N >
void AddStageHelper (Action &stage)
 Adds a stage to this pipeline.
 
void CompleteHelper (Action &stage)
 Completes a pipeline with a stage.
 
void DoActionHelper ()
 Runs the entire pipeline.
 
- Protected Attributes inherited from found::Pipeline< Input, Output, N >
Actionstages [N]
 The stages of this.
 
size_t size = 0
 The number of stages.
 
bool ready = false
 Whether we're complete.
 
std::optional< Output > finalProduct
 The final product. This is only sometimes used.
 
- Protected Attributes inherited from found::FunctionStage< Input, Output >
Input resource
 The stored input for this.
 
Output * product = nullptr
 The pointer to the stored output for this.
 

Detailed Description

template<typename Input, typename Output, size_t N = DEFAULT_NUM_STAGES>
class found::SequentialPipeline< Input, Output, N >

SequentialPipeline is composite Stage (i.e.

A Stage that is made up of many stages). You can add 1 to many stages into a SequentialPipeline so long as the Input to the first stage is the same Input to the SequentialPipeline, and the Output to the last stage is the Output of the SequentialPipeline.

A SequentialPipeline runs by feeding the input to the first stage, taking its output and feeding it to the next stage, and so on until the last stage outputs the output.

Parameters
InputThe SequentialPipeline's Input
OutputThe SequentialPipeline's Output
NNumber of stages
Precondition
Output must be able to be default constructed (i.e. output has trait Output::Output())

Member Function Documentation

◆ AddStage()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
template<typename I , typename O >
SequentialPipeline & found::SequentialPipeline< Input, Output, N >::AddStage ( FunctionStage< I, O > &  stage)
inline

Adds a stage to this pipeline.

Parameters
stageThe stage to add to the pipeline
Returns
this, with the new stage added (for chaining)
Exceptions
invalid_argumentiff this is the first time this method is called, and I does not match Input OR if the SequentialPipeline is already complete (aka this::Complete was called successfully)
Precondition
Iff this method has already been called, O from the last parameter must match I of the next parameter
This method is called when the number of registered stages is less than N - 1

◆ Complete()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
template<typename I >
SequentialPipeline & found::SequentialPipeline< Input, Output, N >::Complete ( FunctionStage< I, Output > &  stage)
inline

Adds a stage to the pipeline and marks it as the last stage, preventing further manipulation of the SequentialPipeline.

Parameters
stageThe stage to add
Returns
this, with the last stage added (to run this::Run)
Exceptions
invalid_argumentiff this is the first time this method is called, and I does not match Input OR if the SequentialPipeline is already complete (aka this::Complete was called successfully)
Precondition
This method is called when the number of registered stages is less than N

◆ Run()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
Output found::SequentialPipeline< Input, Output, N >::Run ( const Input &  input)
inlineoverridevirtual

Executes this SequentialPipeline.

Parameters
inputThe input to this SequentialPipeline
Returns
The output of the SequentialPipeline
Note
A SequentialPipeline runs by feeding the input to the first stage, taking its output and feeding it to the next stage, and so on until the last stage outputs the output.
Precondition
The pipeline must have been completed successfully, i.e. before this::Run is called, this::Complete must have been called successfully

Implements found::Pipeline< Input, Output, N >.


The documentation for this class was generated from the following file: