InstantIO::BasicInSlot Class Reference

Abstract ancestor of all InSlots. More...

#include <InstantIO/BasicInSot.h>

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

List of all members.

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.

Detailed Description

Abstract ancestor of all InSlots.

Applications do not use this class directly, instead they use one of its descendants (InSlot and BufferedInSlot).

See also:
InSlot
BufferedInSlot
Author:
Patrick Dähne

Constructor & Destructor Documentation

InstantIO::BasicInSlot::BasicInSlot ( const std::string &  description = std::string()  )  [explicit, protected]

Creates a new BasicInSlot object.

Parameters:
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.

Member Function Documentation

virtual Direction InstantIO::BasicInSlot::getDirection (  )  const [virtual]

Returns the direction of the Slot (In or Out).

Returns:
The direction (always Slot::In for InSlots)

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.

Parameters:
listener The listener.
See also:
Listener Listener
removeListener removeListener
startInSlot startInSlot
stopInSlot stopInSlot
newData newData
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.

Parameters:
listener The Listener.
See also:
addListener addListener
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.

Returns:
false when data is available, true otherwise.

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.

Parameters:
outSlot The OutSlot.
See also:
disconnect

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.

Parameters:
outSlot The OutSlot.
See also:
connect

Implemented in InstantIO::InSlot< T >.

virtual void InstantIO::BasicInSlot::startInSlot (  )  [protected, virtual]

Gets called when an InSlot gets connected to the first OutSlot.

You can override this method to get a notification when you should start reading values from an InSlot. The default implementation of this method calls the startInSlot method of all listeners.

virtual void InstantIO::BasicInSlot::stopInSlot (  )  [protected, virtual]

Gets called when an InSlot gets disconnected from the last OutSlot.

You can override this method to get a notification when you can stop reading values from an InSlot. The default implementation of this method calls the stopInSlot method of all listeners.

virtual void InstantIO::BasicInSlot::newData (  )  [protected, virtual]

Gets called when there is new data available on the InSlot.

You can override this method to get a notification when you can read a data value from an InSlot using the top or pop methods. The default implementation of this method calls the newData method of all listeners.


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