Support Class Library
A set of tools providing classes and utility
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
scl::stream::details::StreamIteratorPayload< T > Class Template Reference

A class representing a stream iterator's payload. More...

#include "payload.h"

Collaboration diagram for scl::stream::details::StreamIteratorPayload< T >:
Collaboration graph
[legend]

Public Types

using value_type = T
 The type of value stored. More...
 
using alternative = scl::utils::Optional< value_type >
 The type that is available to the user. More...
 
using producer = std::function< alternative(void)>
 The type of function that produces the alternative. More...
 

Public Member Functions

 StreamIteratorPayload (producer prod)
 Construct a payload with its producer function. More...
 
const alternativevalue () const
 Retrieve the underlying sum type. More...
 
bool isInvalid () const
 Determine whether or not the underlying sum type store an invalid tag. More...
 
bool isValid () const
 Determine whether or not the underlying sum type stores a value. More...
 

Static Public Member Functions

static constexpr StreamIteratorPayload withValue (const T &value)
 Create a payload with a value set. More...
 
static constexpr StreamIteratorPayload withoutValue ()
 Create a payload with an invalid tag set. More...
 

Protected Member Functions

void ensureGenerated () const
 Ensure that the payload has been generated before use. More...
 

Protected Attributes

producer gen
 The producer function that gives an optional result. More...
 
alternative alt
 The optional result (as a cache) More...
 
bool generated = false
 Computation cache flag. More...
 

Detailed Description

template<class T>
class scl::stream::details::StreamIteratorPayload< T >

A class representing a stream iterator's payload.

Template Parameters
Tbeing the type of the value transported by the payload

Definition at line 16 of file payload.h.

Member Typedef Documentation

◆ alternative

The type that is available to the user.

Definition at line 37 of file payload.h.

◆ producer

template<class T >
using scl::stream::details::StreamIteratorPayload< T >::producer = std::function<alternative(void)>

The type of function that produces the alternative.

Definition at line 42 of file payload.h.

◆ value_type

template<class T >
using scl::stream::details::StreamIteratorPayload< T >::value_type = T

The type of value stored.

Definition at line 32 of file payload.h.

Constructor & Destructor Documentation

◆ StreamIteratorPayload()

template<class T >
scl::stream::details::StreamIteratorPayload< T >::StreamIteratorPayload ( producer  prod)
inlineexplicit

Construct a payload with its producer function.

Parameters
prodbeing the producer function to use

Definition at line 48 of file payload.h.

Member Function Documentation

◆ ensureGenerated()

template<class T >
void scl::stream::details::StreamIteratorPayload< T >::ensureGenerated ( ) const
inlineprotected

Ensure that the payload has been generated before use.

Definition at line 21 of file payload.h.

◆ isInvalid()

template<class T >
bool scl::stream::details::StreamIteratorPayload< T >::isInvalid ( ) const
inline

Determine whether or not the underlying sum type store an invalid tag.

Returns
TRUE if it does, FALSE otherwise

Definition at line 64 of file payload.h.

◆ isValid()

template<class T >
bool scl::stream::details::StreamIteratorPayload< T >::isValid ( ) const
inline

Determine whether or not the underlying sum type stores a value.

Returns
TRUE if it does, FALSE otherwise

Definition at line 73 of file payload.h.

◆ value()

template<class T >
const alternative& scl::stream::details::StreamIteratorPayload< T >::value ( ) const
inline

Retrieve the underlying sum type.

Returns
an Either containing a value on its left or an invalid tag on its right

Definition at line 55 of file payload.h.

◆ withoutValue()

template<class T >
static constexpr StreamIteratorPayload scl::stream::details::StreamIteratorPayload< T >::withoutValue ( )
inlinestatic

Create a payload with an invalid tag set.

Returns
the instantiated payload

Definition at line 92 of file payload.h.

◆ withValue()

template<class T >
static constexpr StreamIteratorPayload scl::stream::details::StreamIteratorPayload< T >::withValue ( const T &  value)
inlinestatic

Create a payload with a value set.

Parameters
valuebeing the value of the payload
Returns
the instantiated payload

Definition at line 82 of file payload.h.

Member Data Documentation

◆ alt

template<class T >
scl::stream::details::StreamIteratorPayload< T >::alt
mutableprotected

The optional result (as a cache)

Definition at line 109 of file payload.h.

◆ gen

template<class T >
scl::stream::details::StreamIteratorPayload< T >::gen
protected

The producer function that gives an optional result.

Definition at line 103 of file payload.h.

◆ generated

template<class T >
scl::stream::details::StreamIteratorPayload< T >::generated = false
mutableprotected

Computation cache flag.

Definition at line 115 of file payload.h.


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