OpenWalnut
1.4.0
|
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 42 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 34 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 52 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 59 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 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".
con | the connector that gets disconnected. |
Reimplemented from WModuleConnector.
Definition at line 81 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 112 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 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.
Implements WModuleConnector.
Definition at line 128 of file WModuleInputConnector.cpp.
bool WModuleInputConnector::isOutputConnector | ( | ) | const [virtual] |
Returns true if this instance is an 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.
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 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.
input | the input connector receiving the change. |
output | the 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.
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 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!
Definition at line 138 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 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().
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 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().