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

A Pipeline<Input, Output, N> is an abstract Pipeline that takes an Input, outputs an Output, with N stages. More...

#include <pipelines.hpp>

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

Public Member Functions

void DoAction () override
 Runs a Pipeline.
 
virtual Output Run (const Input &input)=0
 Runs this 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.
 

Protected Member Functions

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

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::Pipeline< Input, Output, N >

A Pipeline<Input, Output, N> is an abstract Pipeline that takes an Input, outputs an Output, with N stages.

Parameters
InputThe input type
OutputThe output type
NThe number of stages it uses
Precondition
Output must be able to be default constructed

Member Function Documentation

◆ AddStageHelper()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
void found::Pipeline< Input, Output, N >::AddStageHelper ( Action stage)
inlineprotected

Adds a stage to this pipeline.

Parameters
stageThe stage to add to the pipeline
Exceptions
std::invalid_argumentiff this is already completed
Precondition
This method is called when the number of registered stages is less than N - 1

◆ CompleteHelper()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
void found::Pipeline< Input, Output, N >::CompleteHelper ( Action stage)
inlineprotected

Completes a pipeline with a stage.

Parameters
stageThe stage to add
Exceptions
std::invalid_argumentiff this is already completed
Precondition
This method is called when the number of registered stages is less than N
The pipeline is not ready yet (this->ready == false)
Postcondition
The pipeline is ready (this->ready == true)

◆ DoAction()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
void found::Pipeline< Input, Output, N >::DoAction ( )
inlineoverridevirtual

Runs a Pipeline.

Note
Because Pipelines already construct their return type into the correct destination, there is no need to set the product to the result of the Run, so we optimize here. This override actually isn't necessary for code correctness, but is great for optimization.

Reimplemented from found::FunctionStage< Input, Output >.

◆ DoActionHelper()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
void found::Pipeline< Input, Output, N >::DoActionHelper ( )
inlineprotected

Runs the entire pipeline.

Precondition
The pipeline is ready (this->ready == true)

◆ Run()

template<typename Input , typename Output , size_t N = DEFAULT_NUM_STAGES>
virtual Output found::Pipeline< Input, Output, N >::Run ( const Input &  input)
pure virtual

Runs this Pipeline.

Parameters
inputThe input to the Pipeline
Returns
The output of the Pipeline
Postcondition
This method must also construct Output into the correct destination so that Pipeline::GetProduct() may be used
Note
In this function only, Pipeline::GetProduct() indicates whether storage is present or not for the output.

Implemented in found::SequentialPipeline< Input, Output, N >.


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