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 (std::unique_ptr< Action > &&stage)
 Adds a stage to this pipeline, taking ownership of the provided stage.
 
void CompleteHelper (std::unique_ptr< Action > &&stage)
 Completes a pipeline with a final stage, taking ownership of it.
 
void DoActionHelper ()
 Runs the entire pipeline.
 

Protected Attributes

std::unique_ptr< Actionstages [N]
 Ownership storage for the stages.
 
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 ( std::unique_ptr< Action > &&  stage)
inlineprotected

Adds a stage to this pipeline, taking ownership of the provided stage.

Parameters
stageThe stage to add to this
Exceptions
std::invalid_argumentiff this has already been completed
Precondition
This method is called when the number of registered stages is less than N - 1
Postcondition
stage is stored inside this such that stage and this share the same lifetime. Ownership of stage is transferred to this

◆ CompleteHelper()

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

Completes a pipeline with a final stage, taking ownership of it.

Parameters
stageThe final stage to add
Exceptions
std::invalid_argumentiff this has already been completed
Precondition
This method is called when the number of registered stages is less than N
This is not ready yet
Postcondition
This is now ready. Ownership of stage is transferred to this. The lifetime of stage matches this

◆ 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: