Discman
Loading...
Searching...
No Matches
Producer< T > Class Template Referenceabstract

The Producer interface. More...

#include <producer.h>

Public Member Functions

next (const Consumer< T > *const consumer)
 When a Producer has multiple Consumers, each Consumer must call this overloaded version of next().
 
void register_consumer (const Consumer< T > *const consumer)
 Use this method to maintain state associated with a particular Consumer. The state can be used to retrieve the right datum for the Consumer.
 
virtual T next ()=0
 When a producer has a single Consumer, that Consumer may simply call this version of next() to retrieve the next datum. When a Producer has multiple Consumers, this method must take into account the _current_consumer.
 

Protected Member Functions

Consumer< T > * current_consumer () const
 Getter for _current_consumer.
 

Private Attributes

Consumer< T > * _current_consumer = nullptr
 The Consumer that will receive the datum returned by next().
 

Detailed Description

template<typename T>
class Producer< T >

The Producer interface.

See also
Producer/Consumer.
Template Parameters
TThe data type produced.

Definition at line 16 of file producer.h.

Member Function Documentation

◆ current_consumer()

template<typename T>
Consumer< T > * Producer< T >::current_consumer ( ) const
protected

Getter for _current_consumer.

Definition at line 52 of file producer.h.

◆ next() [1/2]

template<typename T>
virtual T Producer< T >::next ( )
pure virtual

When a producer has a single Consumer, that Consumer may simply call this version of next() to retrieve the next datum. When a Producer has multiple Consumers, this method must take into account the _current_consumer.

Returns
The next datum.

Implemented in CDDrive.

◆ next() [2/2]

template<typename T>
T Producer< T >::next ( const Consumer< T > *const consumer)

When a Producer has multiple Consumers, each Consumer must call this overloaded version of next().

Parameters
[in]consumerConsumer for which to provide the next datum .
Returns
Yhe next datum.

Definition at line 46 of file producer.h.

◆ register_consumer()

template<typename T>
void Producer< T >::register_consumer ( const Consumer< T > *const consumer)
inline

Use this method to maintain state associated with a particular Consumer. The state can be used to retrieve the right datum for the Consumer.

Parameters
[in]consumerThe Consumer to register.

Definition at line 27 of file producer.h.

Member Data Documentation

◆ _current_consumer

template<typename T>
Consumer<T>* Producer< T >::_current_consumer = nullptr
private

The Consumer that will receive the datum returned by next().

Definition at line 38 of file producer.h.


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