OpenWalnut  1.4.0
Public Member Functions | Protected Member Functions | Private Attributes
WModuleInputConnector Class Reference

Class implementing input connection functionality between modules. More...

#include <WModuleInputConnector.h>

+ Inheritance diagram for WModuleInputConnector:

List of all members.

Public Member Functions

 WModuleInputConnector (boost::shared_ptr< WModule > module, std::string name="", std::string description="")
 Constructor.
virtual ~WModuleInputConnector ()
 Destructor.
virtual bool connectable (boost::shared_ptr< WModuleConnector > con)
 Checks whether the specified connector is an output connector.
boost::shared_ptr< WConditiongetDataChangedCondition ()
 Gets the condition variable that gets fired whenever new data has been sent.
boost::signals2::connection subscribeSignal (MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier)
 Connects (subscribes) a specified notify function with a signal this module instance is offering.
virtual bool isInputConnector () const
 Returns true if this instance is an WModuleInputConnector.
virtual bool isOutputConnector () const
 Returns true if this instance is an WModuleOutputConnector.
virtual bool updated ()
 Denotes whether the connected output was updated.
virtual bool handledUpdate ()
 Resets the updated-flag.

Protected Member Functions

virtual void connectSignals (boost::shared_ptr< WModuleConnector > con)
 Connect additional signals.
virtual void disconnectSignals (boost::shared_ptr< WModuleConnector > con)
 Disconnect all signals subscribed by this connector from "con".
virtual void notifyDataChange (boost::shared_ptr< WModuleConnector > input, boost::shared_ptr< WModuleConnector > output)
 Gets called when the data on this input connector changed.
virtual void notifyConnectionEstablished (boost::shared_ptr< WModuleConnector > here, boost::shared_ptr< WModuleConnector > there)
 Gets called whenever a connector gets connected to the specified input.
virtual void setUpdated ()
 Sets the update flag (use updated() to query it)to true.

Private Attributes

t_GenericSignalType signal_DataChanged
 Signal for "DATA_CHANGED" Events.
boost::shared_ptr< WConditionm_dataChangedCondition
 Condition fired whenever data changes.
boost::signals2::connection m_DataChangedConnection
 Connection for Data Changed signal of the connected output connector.
boost::shared_mutex m_updatedLock
 This lock protects the m_updated flag.
bool m_updated
 A flag denoting that an update was received.

Detailed Description

Class implementing input connection functionality between modules.

Definition at line 42 of file WModuleInputConnector.h.


Constructor & Destructor Documentation

WModuleInputConnector::WModuleInputConnector ( boost::shared_ptr< WModule module,
std::string  name = "",
std::string  description = "" 
)

Constructor.

Parameters:
modulethe module which is owner of this connector.
nameThe name of this connector.
descriptionShort description of this connector.

Definition at line 34 of file WModuleInputConnector.cpp.

References WModuleConnector::getSignalHandler(), m_dataChangedCondition, WCondition::notify(), setUpdated(), WModuleConnector::signal_ConnectionClosed, and signal_DataChanged.

Destructor.

Definition at line 52 of file WModuleInputConnector.cpp.

References m_DataChangedConnection, and WModuleConnector::signal_ConnectionClosed.


Member Function Documentation

bool WModuleInputConnector::connectable ( boost::shared_ptr< WModuleConnector con) [virtual]

Checks whether the specified connector is an output connector.

Parameters:
conthe connector to check against.
Returns:
true if compatible.

Implements WModuleConnector.

Reimplemented in WModuleInputData< T >.

Definition at line 59 of file WModuleInputConnector.cpp.

Referenced by WModuleInputData< T >::connectable().

void WModuleInputConnector::connectSignals ( boost::shared_ptr< WModuleConnector con) [protected, virtual]

Connect additional signals.

Parameters:
conthe connector that requests connection.

Reimplemented from WModuleConnector.

Definition at line 69 of file WModuleInputConnector.cpp.

References m_DataChangedConnection, and notifyDataChange().

void WModuleInputConnector::disconnectSignals ( boost::shared_ptr< WModuleConnector con) [protected, virtual]

Disconnect all signals subscribed by this connector from "con".

Parameters:
conthe connector that gets disconnected.

Reimplemented from WModuleConnector.

Definition at line 81 of file WModuleInputConnector.cpp.

References m_DataChangedConnection.

Gets the condition variable that gets fired whenever new data has been sent.

Returns:
the condition

Definition at line 112 of file WModuleInputConnector.cpp.

References m_dataChangedCondition.

Resets the updated-flag.

Call this from your module to reset the value of updated().

Returns:
the update flag before reset. Useful to get the flag and reset it in one call.

Definition at line 150 of file WModuleInputConnector.cpp.

References m_updated, and m_updatedLock.

Referenced by WModuleInputData< T >::getData().

bool WModuleInputConnector::isInputConnector ( ) const [virtual]

Returns true if this instance is an WModuleInputConnector.

Returns:
true if castable to WModuleInputConnector.

Implements WModuleConnector.

Definition at line 128 of file WModuleInputConnector.cpp.

bool WModuleInputConnector::isOutputConnector ( ) const [virtual]

Returns true if this instance is an WModuleOutputConnector.

Returns:
true if castable to WModuleOutputConnector.

Implements WModuleConnector.

Definition at line 133 of file WModuleInputConnector.cpp.

void WModuleInputConnector::notifyConnectionEstablished ( boost::shared_ptr< WModuleConnector here,
boost::shared_ptr< WModuleConnector there 
) [protected, virtual]

Gets called whenever a connector gets connected to the specified input.

Parameters:
herethe connector of THIS module that got connected to "there"
therethe connector that has been connected with the connector "here" of this module.

Reimplemented from WModuleConnector.

Definition at line 117 of file WModuleInputConnector.cpp.

References notifyDataChange().

void WModuleInputConnector::notifyDataChange ( boost::shared_ptr< WModuleConnector input,
boost::shared_ptr< WModuleConnector output 
) [protected, virtual]

Gets called when the data on this input connector changed.

Parameters:
inputthe input connector receiving the change.
outputthe output connector sending the change notification.

Reimplemented in WModuleInputForwardData< T >.

Definition at line 101 of file WModuleInputConnector.cpp.

References m_dataChangedCondition, setUpdated(), and signal_DataChanged.

Referenced by connectSignals(), and notifyConnectionEstablished().

void WModuleInputConnector::setUpdated ( ) [protected, virtual]

Sets the update flag (use updated() to query it)to true.

This is normally called by the notifyDataChange callback.

Definition at line 144 of file WModuleInputConnector.cpp.

References m_updated, and m_updatedLock.

Referenced by notifyDataChange(), and WModuleInputConnector().

boost::signals2::connection WModuleInputConnector::subscribeSignal ( MODULE_CONNECTOR_SIGNAL  signal,
t_GenericSignalHandlerType  notifier 
) [virtual]

Connects (subscribes) a specified notify function with a signal this module instance is offering.

Exceptions:
WModuleSignalSubscriptionFailedthrown if the signal can't be connected.
Parameters:
signalthe signal to connect to.
notifierthe notifier function to bind.
Returns:
the connection. Disconnect it manually if not needed anymore!

Reimplemented from WModuleConnector.

Definition at line 88 of file WModuleInputConnector.cpp.

References signal_DataChanged.

bool WModuleInputConnector::updated ( ) [virtual]

Denotes whether the connected output was updated.

This does NOT denote an actual change in the current data!

Returns:
true if there has been an update.

Definition at line 138 of file WModuleInputConnector.cpp.

References m_updated, and m_updatedLock.


Member Data Documentation

Condition fired whenever data changes.

Definition at line 163 of file WModuleInputConnector.h.

Referenced by getDataChangedCondition(), notifyDataChange(), and WModuleInputConnector().

boost::signals2::connection WModuleInputConnector::m_DataChangedConnection [private]

Connection for Data Changed signal of the connected output connector.

Definition at line 168 of file WModuleInputConnector.h.

Referenced by connectSignals(), disconnectSignals(), and ~WModuleInputConnector().

A flag denoting that an update was received.

It does not denote a real change in the value!

Definition at line 178 of file WModuleInputConnector.h.

Referenced by handledUpdate(), setUpdated(), and updated().

boost::shared_mutex WModuleInputConnector::m_updatedLock [private]

This lock protects the m_updated flag.

Definition at line 173 of file WModuleInputConnector.h.

Referenced by handledUpdate(), setUpdated(), and updated().

t_GenericSignalType WModuleInputConnector::signal_DataChanged [private]

Signal for "DATA_CHANGED" Events.

We use a separate signal here (instead of using the signal send by the connected output) since the output can not determine the receiver when signalling. So we use an own signal handler and signal to "forward" the message and complete the information with a this-pointer.

Definition at line 158 of file WModuleInputConnector.h.

Referenced by notifyDataChange(), subscribeSignal(), and WModuleInputConnector().


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