flow  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
flow::pipe< T > Class Template Reference

Carries packets from one node to another node on a FIFO basis. More...

#include <pipe.h>

Inheritance diagram for flow::pipe< T >:
Inheritance graph
[legend]
Collaboration diagram for flow::pipe< T >:
Collaboration graph
[legend]

Public Member Functions

 pipe (const std::string &name_r, outpin< T > *output_p, inpin< T > *input_p, const size_t max_length=0, const size_t max_weight=0)
 Constructor for a new pipe.
 
 pipe (pipe &&pipe_rr)
 Move constructor.
 
virtual outpin< T > * input () const
 Pointer to the producing node's output pin.
 
virtual inpin< T > * output () const
 Pointer to the consuming node's input pin.
 
virtual size_t length () const
 The pipe's current length. The number of packets in the pipe.
 
virtual size_t max_length () const
 The maximum number of packets this pipe will carry.
 
virtual size_t weight () const
 The pipe's current weight. The sum of all bytes of all packets in the pipe.
 
virtual size_t max_weight () const
 The maximum number of bytes this pipe will carry.
 
virtual size_t cap_length (const size_t max_length)
 Sets the maximum length.
 
virtual size_t cap_weight (const size_t max_weight)
 Sets the maximum weight.
 
virtual size_t flush ()
 Discards all packets.
 
virtual bool push (std::unique_ptr< packet< T >> packet_p)
 Queues a packet in the pipe.
 
virtual std::unique_ptr
< packet< T > > 
pop ()
 Extracts a packet from the pipe.
 
- Public Member Functions inherited from flow::named
 named (const std::string &name_r)
 Constructor the takes a name.
 
 named (named &&name_rr)
 Move constructor.
 
 named (const named &name_r)
 Copy constructor.
 
virtual const std::string & name () const
 A const reference to this object's name.
 
virtual std::string rename (const std::string &name_r)
 Sets this object's name to a new name.
 

Detailed Description

template<typename T>
class flow::pipe< T >

Carries packets from one node to another node on a FIFO basis.

Packets will accumulate in pipes if the node at the consuming end does not consume them fast enough. If packet accumulation is expected but memory usage is a concern, length and weight can be specified. If a pipe has reached it's length and weight limit, pushed packets will instead be discarded. A graph that produces more data than it consumes is unbalanced and should be adjusted.

Constructor & Destructor Documentation

template<typename T>
flow::pipe< T >::pipe ( const std::string &  name_r,
outpin< T > *  output_p,
inpin< T > *  input_p,
const size_t  max_length = 0,
const size_t  max_weight = 0 
)
inline

Constructor for a new pipe.

Parameters
name_rName of this pipe. This will be typically generated from the names of the producing and consuming nodes.
output_pThe output pin of the producing node.
input_pThe input pin of the consuming node.
max_lengthThe maximum number of nodes this pipe will carry. Do not set or set to 0 for uncapped length.
max_weightThe maximum number of bytes this pipe will carry. Do not set or set to 0 for uncapped weight.

Member Function Documentation

template<typename T>
virtual size_t flow::pipe< T >::max_length ( ) const
inlinevirtual

The maximum number of packets this pipe will carry.

If 0, then uncapped.

template<typename T>
virtual size_t flow::pipe< T >::max_weight ( ) const
inlinevirtual

The maximum number of bytes this pipe will carry.

If 0, then uncapped.

template<typename T>
virtual bool flow::pipe< T >::push ( std::unique_ptr< packet< T >>  packet_p)
inlinevirtual

Queues a packet in the pipe.

Used by the producer node to move a packet it produced to the pipe. If the packet does not fit in the pipe, it will not be moved.

Parameters
packet_pA pointer to the packet. If this call is unsuccessful, packet_p will still point to the packet after the call.
Returns
true if the packet was successfully moved to the pipe, false otherwise.
template<typename T>
virtual std::unique_ptr<packet<T> > flow::pipe< T >::pop ( )
inlinevirtual

Extracts a packet from the pipe.

Used by the consuming node to move a packet from the pipe to consume.

Returns
A pointer to the next packet in the pipe, empty pointer if there is no packet.

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