OpenWalnut 1.2.5
|
Class implementing input connection functionality between modules. More...
#include <WModuleInputConnector.h>
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< WCondition > | getDataChangedCondition () |
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< WCondition > | m_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. |
Class implementing input connection functionality between modules.
Definition at line 43 of file WModuleInputConnector.h.
WModuleInputConnector::WModuleInputConnector | ( | boost::shared_ptr< WModule > | module, |
std::string | name = "" , |
||
std::string | description = "" |
||
) |
Constructor.
module | the module which is owner of this connector. |
name | The name of this connector. |
description | Short description of this connector. |
Definition at line 33 of file WModuleInputConnector.cpp.
References WModuleConnector::getSignalHandler(), m_dataChangedCondition, WCondition::notify(), setUpdated(), WModuleConnector::signal_ConnectionClosed, and signal_DataChanged.
WModuleInputConnector::~WModuleInputConnector | ( | ) | [virtual] |
Destructor.
Definition at line 51 of file WModuleInputConnector.cpp.
References m_DataChangedConnection, and WModuleConnector::signal_ConnectionClosed.
bool WModuleInputConnector::connectable | ( | boost::shared_ptr< WModuleConnector > | con | ) | [virtual] |
Checks whether the specified connector is an output connector.
con | the connector to check against. |
Implements WModuleConnector.
Reimplemented in WModuleInputData< T >.
Definition at line 58 of file WModuleInputConnector.cpp.
Referenced by WModuleInputData< T >::connectable().
void WModuleInputConnector::connectSignals | ( | boost::shared_ptr< WModuleConnector > | con | ) | [protected, virtual] |
Connect additional signals.
con | the connector that requests connection. |
Reimplemented from WModuleConnector.
Definition at line 68 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".
con | the connector that gets disconnected. |
Reimplemented from WModuleConnector.
Definition at line 80 of file WModuleInputConnector.cpp.
References m_DataChangedConnection.
boost::shared_ptr< WCondition > WModuleInputConnector::getDataChangedCondition | ( | ) |
Gets the condition variable that gets fired whenever new data has been sent.
Definition at line 111 of file WModuleInputConnector.cpp.
References m_dataChangedCondition.
bool WModuleInputConnector::handledUpdate | ( | ) | [virtual] |
Resets the updated-flag.
Call this from your module to reset the value of updated().
Definition at line 149 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.
Implements WModuleConnector.
Definition at line 127 of file WModuleInputConnector.cpp.
bool WModuleInputConnector::isOutputConnector | ( | ) | const [virtual] |
Returns true if this instance is an WModuleOutputConnector.
Implements WModuleConnector.
Definition at line 132 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.
here | the connector of THIS module that got connected to "there" |
there | the connector that has been connected with the connector "here" of this module. |
Reimplemented from WModuleConnector.
Definition at line 116 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.
input | the input connector receiving the change. |
output | the output connector sending the change notification. |
Reimplemented in WModuleInputForwardData< T >.
Definition at line 100 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 143 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.
WModuleSignalSubscriptionFailed | thrown if the signal can't be connected. |
signal | the signal to connect to. |
notifier | the notifier function to bind. |
Reimplemented from WModuleConnector.
Definition at line 87 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!
Definition at line 137 of file WModuleInputConnector.cpp.
References m_updated, and m_updatedLock.
boost::shared_ptr< WCondition > WModuleInputConnector::m_dataChangedCondition [private] |
Condition fired whenever data changes.
Definition at line 167 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 172 of file WModuleInputConnector.h.
Referenced by connectSignals(), disconnectSignals(), and ~WModuleInputConnector().
bool WModuleInputConnector::m_updated [private] |
A flag denoting that an update was received.
It does not denote a real change in the value!
Definition at line 182 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 177 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 162 of file WModuleInputConnector.h.
Referenced by notifyDataChange(), subscribeSignal(), and WModuleInputConnector().