InstantIO::BufferedInSlot< T > Class Template Reference

InSlot that buffers values. More...

#include <InstantIO/BufferedInSlot.h>

Inheritance diagram for InstantIO::BufferedInSlot< T >:
InstantIO::InSlot< T > InstantIO::BasicInSlot InstantIO::Slot

List of all members.

Public Member Functions

 BufferedInSlot (unsigned int numValues=1)
 Creates a new BufferedInSlot object.
 BufferedInSlot (const std::string &description, unsigned int numValues=1)
 Creates a new BufferedInSlot object.
virtual ~BufferedInSlot ()
 Destroys the BufferedInSlot object.
virtual bool empty () const
 Returns if data is available on the BufferedInSlot.
unsigned int getNumValues () const
 Returns the number of unread data values available on the BufferedInSlot.
virtual const Data< T > top ()
 Returns the current data value without removing it from the BufferedInSlot.
virtual const Data< T > pop ()
 Removes the current data value from the BufferedInSlot and returns it.
virtual void push (const Data< T > &data)
 Writes a new data value into the BufferedInSlot.

Detailed Description

template<class T>
class InstantIO::BufferedInSlot< T >

InSlot that buffers values.

Usually, InSlots do not buffer values, i.e. when a new data value is written into the InSlot before the old data value has been received by the application, the old data value gets lost. This is ok under many circumstances, but sometimes it is important to get all data values (e.g. when receiving button press and release event). For this reason, the BufferedInSlot class exists.

When you create a BufferedInSlot object, you have to specify the maximum number of data values that get buffered by the InSlot. When more values are written into the InSlot than the maximum number, the newer data values overwrite the oldest data values stored in the InSlot.

Author:
Patrick Dähne
See also:
InSlot InSlot

Constructor & Destructor Documentation

template<class T >
InstantIO::BufferedInSlot< T >::BufferedInSlot ( unsigned int  numValues = 1  )  [inline, explicit]

Creates a new BufferedInSlot object.

Parameters:
numValues The maximum number of values that are buffered by this InSlot.
template<class T >
InstantIO::BufferedInSlot< T >::BufferedInSlot ( const std::string &  description,
unsigned int  numValues = 1 
) [inline, explicit]

Creates a new BufferedInSlot object.

Parameters:
description The description of this BufferedInSlot. This information is not used by the InstantIO system directly, instead it is displayed for information purposes in user interfaces used to configure the InstantIO system.
numValues The maximum number of values that are buffered by this InSlot.

Member Function Documentation

template<class T >
virtual bool InstantIO::BufferedInSlot< T >::empty (  )  const [inline, virtual]

Returns if data is available on the BufferedInSlot.

All method that receive data values (top, pop) block when no data is available until data is received from an OutSlot. By using this method, you can prevent this blocking by checking if data is actually available.

Returns:
false when data is available, true otherwise.

Reimplemented from InstantIO::InSlot< T >.

template<class T >
unsigned int InstantIO::BufferedInSlot< T >::getNumValues (  )  const [inline]

Returns the number of unread data values available on the BufferedInSlot.

This method returns the number of times the application may call the pop method without blocking.

Returns:
The number of unread data values.
See also:
pop
template<class T >
virtual const Data<T> InstantIO::BufferedInSlot< T >::top (  )  [inline, virtual]

Returns the current data value without removing it from the BufferedInSlot.

To remove the data value from the BufferedInSlot, you can call the pop method.

Returns:
The current data value.
Exceptions:
InterruptedException when the interrupt method has been called
See also:
pop

Reimplemented from InstantIO::InSlot< T >.

template<class T >
virtual const Data<T> InstantIO::BufferedInSlot< T >::pop (  )  [inline, virtual]

Removes the current data value from the BufferedInSlot and returns it.

This method blocks when no data is available until data is received from an OutSlot. By using the empty or getNumValues methods you can check if data is available before calling this method.

To get the data value without removing it from the BufferedInSlot, use the top method.

Returns:
The current data value.
Exceptions:
InterruptedException when the interrupt method has been called
See also:
empty
getNumValues
top

Reimplemented from InstantIO::InSlot< T >.

template<class T >
virtual void InstantIO::BufferedInSlot< T >::push ( const Data< T > &  data  )  [inline, virtual]

Writes a new data value into the BufferedInSlot.

Usually, you do not write data values directly into a BufferedInSlot. InSlots receive data values from OutSlots they are connected to. This method is available for rare special circumstances where it might be helpful to write data values manually into the BufferedInSlot.

Parameters:
data A Data object that contains a new data value and the time when it has been created.

Reimplemented from InstantIO::InSlot< T >.


The documentation for this class was generated from the following file:
Generated on Thu Jul 31 17:17:32 2014 by  doxygen 1.6.3