Abstract ancestor of all InSlots. More...
#include <InstantIO/BasicInSot.h>
Classes | |
class | Listener |
Allows to receive information about the status of an InSlot. More... | |
Public Member Functions | |
virtual | ~BasicInSlot () |
Destroys the BasicInSlot object. | |
virtual Direction | getDirection () const |
Returns the direction of the Slot (In or Out). | |
void | addListener (Listener &listener) |
Adds a Listener to the InSlot. | |
void | removeListener (Listener &listener) |
Removes a Listener from the InSlot. | |
virtual bool | empty () const =0 |
Returns if data is available on the InSlot. | |
void | interrupt () |
Interrupts one thread blocked at the pop or top methods. | |
virtual void | connect (BasicOutSlot *outSlot)=0 |
Connects an OutSlot to this InSlot. | |
virtual void | disconnect (BasicOutSlot *outSlot)=0 |
Disconnects an OutSlot from this InSlot. | |
Protected Member Functions | |
BasicInSlot (const std::string &description=std::string()) | |
Creates a new BasicInSlot object. | |
virtual void | startInSlot () |
Gets called when an InSlot gets connected to the first OutSlot. | |
virtual void | stopInSlot () |
Gets called when an InSlot gets disconnected from the last OutSlot. | |
virtual void | newData () |
Gets called when there is new data available on the InSlot. | |
void | up () const |
Increments the semaphore used to block threads in the top and pop methods. | |
void | down () const |
Decrements the semaphore used to block threads in the top and pop methods. | |
Protected Attributes | |
bool | interrupted_ |
Flag that is set to true when the interrupt method is called. |
Abstract ancestor of all InSlots.
Applications do not use this class directly, instead they use one of its descendants (InSlot and BufferedInSlot).
InstantIO::BasicInSlot::BasicInSlot | ( | const std::string & | description = std::string() |
) | [explicit, protected] |
Creates a new BasicInSlot object.
description | The description of this InSlot. 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. |
virtual Direction InstantIO::BasicInSlot::getDirection | ( | ) | const [virtual] |
Returns the direction of the Slot (In or Out).
Implements InstantIO::Slot.
void InstantIO::BasicInSlot::addListener | ( | Listener & | listener | ) |
Adds a Listener to the InSlot.
After calling this methods, the listener receives status information from the InSlot.
Listeners can be used to receive notifications when the status of an InSlot changes, i.e. when the first OutSlot connects to the InSlot, the last OutSlot disconnects from the InSlot, or new data is available on the InSlot. Instead of implementing the Listener interface, you can also create a descendant of the InSlot class and override the startInSlot, stopInSlot and newData methods.
listener | The listener. |
void InstantIO::BasicInSlot::removeListener | ( | Listener & | listener | ) |
Removes a Listener from the InSlot.
After calling this method, the listener does not receive status notifications any more.
listener | The Listener. |
virtual bool InstantIO::BasicInSlot::empty | ( | ) | const [pure virtual] |
Returns if data is available on the InSlot.
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.
Implemented in InstantIO::BufferedInSlot< T >, and InstantIO::InSlot< T >.
virtual void InstantIO::BasicInSlot::connect | ( | BasicOutSlot * | outSlot | ) | [pure virtual] |
Connects an OutSlot to this InSlot.
Usually, OutSlots and InSlots are not connected manually. They are connected automatically by adding them to Namespaces. This method just exists for rare special circumstances where it might be helpful to connect slots manually.
It is only possible to connect OutSlots and InSlots that have the same C++ data type.
It is possible to add the same OutSlot more than once to an InSlot. Nevertheless, just one connection is created. For each call of the connect
method, there has to be a corresponding call to the disconnect
method. The slots do not get disconnected until the last call of the disconnect method.
outSlot | The OutSlot. |
Implemented in InstantIO::InSlot< T >.
virtual void InstantIO::BasicInSlot::disconnect | ( | BasicOutSlot * | outSlot | ) | [pure virtual] |
Disconnects an OutSlot from this InSlot.
Usually, OutSlots and InSlots are not disconnected manually. The are disconnected automatically by removing them from Namespaces. This method just exists for rare special circumstances where it might be helpful to disconnect slots manually.
It is possible to add the same OutSlot more than once to an InSlot. Nevertheless, just one connection is created. For each call of the connect
method, there has to be a corresponding call to the disconnect
method. The slots do not get disconnected until the last call of the disconnect method.
outSlot | The OutSlot. |
Implemented in InstantIO::InSlot< T >.
virtual void InstantIO::BasicInSlot::startInSlot | ( | ) | [protected, virtual] |
virtual void InstantIO::BasicInSlot::stopInSlot | ( | ) | [protected, virtual] |
virtual void InstantIO::BasicInSlot::newData | ( | ) | [protected, virtual] |