InSlot that buffers values. More...
#include <InstantIO/BufferedInSlot.h>
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. |
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.
InstantIO::BufferedInSlot< T >::BufferedInSlot | ( | unsigned int | numValues = 1 |
) | [inline, explicit] |
Creates a new BufferedInSlot object.
numValues | The maximum number of values that are buffered by this InSlot. |
InstantIO::BufferedInSlot< T >::BufferedInSlot | ( | const std::string & | description, | |
unsigned int | numValues = 1 | |||
) | [inline, explicit] |
Creates a new BufferedInSlot object.
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. |
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.
Reimplemented from InstantIO::InSlot< T >.
unsigned int InstantIO::BufferedInSlot< T >::getNumValues | ( | ) | const [inline] |
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.
InterruptedException | when the interrupt method has been called |
Reimplemented from InstantIO::InSlot< 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.
InterruptedException | when the interrupt method has been called |
Reimplemented from InstantIO::InSlot< 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.
data | A Data object that contains a new data value and the time when it has been created. |
Reimplemented from InstantIO::InSlot< T >.