OpenWalnut
1.5.0dev
|
Class implementing input connection functionality between modules. More...
#include <WModuleInputConnector.h>
Public Member Functions | |
WModuleInputConnector (std::shared_ptr< WModule > module, std::string name="", std::string description="") | |
Constructor. More... | |
virtual | ~WModuleInputConnector () |
Destructor. More... | |
virtual bool | connectable (std::shared_ptr< WModuleConnector > con) |
Checks whether the specified connector is an output connector. More... | |
virtual bool | lazyConnectable (std::shared_ptr< WModuleConnector > con) |
Checks whether the specified connector is connectable to this one, but ignores compatibility the type to be transferred. More... | |
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. More... | |
virtual bool | isInputConnector () const |
Returns true if this instance is an WModuleInputConnector. More... | |
virtual bool | isOutputConnector () const |
Returns true if this instance is an WModuleOutputConnector. More... | |
virtual bool | updated () |
Denotes whether the connected output was updated. More... | |
virtual bool | handledUpdate () |
Resets the updated-flag. More... | |
Public Member Functions inherited from WModuleConnector | |
WModuleConnector (std::shared_ptr< WModule > module, std::string name="", std::string description="") | |
Constructor. More... | |
virtual | ~WModuleConnector () |
Destructor. More... | |
std::shared_ptr< WModule > | getModule () const |
Returns the module which owns this connector. More... | |
virtual void | disconnect (std::shared_ptr< WModuleConnector > con, bool removeFromOwnList=true) |
Disconnects this connector if connected. More... | |
virtual void | disconnectAll () |
Disconnects ALL connected connectors. More... | |
virtual void | connect (std::shared_ptr< WModuleConnector > con, bool force=false) |
Connects this Module Connector with another one. More... | |
bool | isConnectedTo (std::shared_ptr< WModuleConnector > con) |
Checks whether this connector is connected to the given one. More... | |
unsigned int | isConnected () |
Gets the count of connections currently established. More... | |
const std::string | getDescription () const |
Gives information about this connection. More... | |
void | setDescription (std::string desc) |
Sets the connector's description. More... | |
const std::string | getName () const |
Gives name of connection. More... | |
const std::string | getCanonicalName () const |
Gives canonical name of connection. More... | |
void | setName (std::string name) |
Sets the connector's name. More... | |
WCombinerTypes::WOneToOneCombiners | getPossibleDisconnections () |
Returns a list of possible disconnections for this connector. More... | |
std::shared_ptr< WModuleInputConnector > | toInputConnector () |
Tries to convert this instance to an input connector. More... | |
std::shared_ptr< WModuleOutputConnector > | toOutputConnector () |
Tries to convert this instance to an output connector. More... | |
std::shared_ptr< WCondition > | getDataChangedCondition () |
Gets the condition variable that gets fired whenever new data has been sent. More... | |
Protected Member Functions | |
virtual void | connectSignals (std::shared_ptr< WModuleConnector > con) |
Connect additional signals. More... | |
virtual void | disconnectSignals (std::shared_ptr< WModuleConnector > con) |
Disconnect all signals subscribed by this connector from "con". More... | |
virtual void | notifyDataChange (std::shared_ptr< WModuleConnector > input, std::shared_ptr< WModuleConnector > output) |
Gets called when the data on this input connector changed. More... | |
virtual void | notifyConnectionEstablished (std::shared_ptr< WModuleConnector > here, std::shared_ptr< WModuleConnector > there) |
Gets called whenever a connector gets connected to the specified input. More... | |
virtual void | setUpdated () |
Sets the update flag (use updated() to query it)to true. More... | |
Protected Member Functions inherited from WModuleConnector | |
virtual const t_GenericSignalHandlerType | getSignalHandler (MODULE_CONNECTOR_SIGNAL signal) |
Gives the signal handler function responsible for a given signal. More... | |
virtual void | notifyConnectionClosed (std::shared_ptr< WModuleConnector > here, std::shared_ptr< WModuleConnector > there) |
Gets called whenever a connection between a remote and local connector gets closed. More... | |
Private Attributes | |
t_GenericSignalType | signal_DataChanged |
Signal for "DATA_CHANGED" Events. More... | |
boost::signals2::connection | m_DataChangedConnection |
Connection for Data Changed signal of the connected output connector. More... | |
std::shared_mutex | m_updatedLock |
This lock protects the m_updated flag. More... | |
bool | m_updated |
A flag denoting that an update was received. More... | |
Additional Inherited Members | |
Public Types inherited from WModuleConnector | |
typedef std::shared_ptr< WModuleConnector > | SPtr |
Shared pointer to this class. More... | |
typedef std::shared_ptr< const WModuleConnector > | ConstSPtr |
Const shared pointer to this class. More... | |
Protected Attributes inherited from WModuleConnector | |
std::set< std::shared_ptr< WModuleConnector > > | m_connected |
List of connectors connected to this connector. More... | |
std::shared_mutex | m_connectionListLock |
Lock for avoiding concurrent write to m_Connected (multiple reader, single writer lock). More... | |
std::weak_ptr< WModule > | m_module |
The Module this connector belongs to. More... | |
std::string | m_moduleName |
The name of the module owning this connector. More... | |
t_GenericSignalType | signal_ConnectionEstablished |
Signal emitted whenever connection has been established. More... | |
t_GenericSignalType | signal_ConnectionClosed |
Signal emitted whenever connection has been closed. More... | |
std::shared_ptr< WCondition > | m_dataChangedCondition |
Condition fired whenever data changes. More... | |
Class implementing input connection functionality between modules.
Definition at line 43 of file WModuleInputConnector.h.
WModuleInputConnector::WModuleInputConnector | ( | std::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(), WModuleConnector::m_dataChangedCondition, WCondition::notify(), setUpdated(), WModuleConnector::signal_ConnectionClosed, and signal_DataChanged.
|
virtual |
Destructor.
Definition at line 46 of file WModuleInputConnector.cpp.
References m_DataChangedConnection, and WModuleConnector::signal_ConnectionClosed.
|
virtual |
Checks whether the specified connector is an output connector.
con | the connector to check against. |
Implements WModuleConnector.
Reimplemented in WModuleInputData< T >, and WModuleInputData< WDataSetSingle >.
Definition at line 53 of file WModuleInputConnector.cpp.
Referenced by WModuleInputData< T >::connectable().
|
protectedvirtual |
Connect additional signals.
con | the connector that requests connection. |
Reimplemented from WModuleConnector.
Definition at line 73 of file WModuleInputConnector.cpp.
References WModuleConnector::connectSignals(), m_DataChangedConnection, and notifyDataChange().
|
protectedvirtual |
Disconnect all signals subscribed by this connector from "con".
con | the connector that gets disconnected. |
Reimplemented from WModuleConnector.
Definition at line 85 of file WModuleInputConnector.cpp.
References WModuleConnector::disconnectSignals(), and m_DataChangedConnection.
|
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().
|
virtual |
Returns true if this instance is an WModuleInputConnector.
Implements WModuleConnector.
Definition at line 127 of file WModuleInputConnector.cpp.
|
virtual |
Returns true if this instance is an WModuleOutputConnector.
Implements WModuleConnector.
Definition at line 132 of file WModuleInputConnector.cpp.
|
virtual |
Checks whether the specified connector is connectable to this one, but ignores compatibility the type to be transferred.
con | the connector to check against. |
Implements WModuleConnector.
Definition at line 63 of file WModuleInputConnector.cpp.
|
protectedvirtual |
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 WModuleConnector::notifyConnectionEstablished(), and notifyDataChange().
|
protectedvirtual |
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 >, and WModuleInputForwardData< WDataSetScalar >.
Definition at line 105 of file WModuleInputConnector.cpp.
References WModuleConnector::m_dataChangedCondition, setUpdated(), and signal_DataChanged.
Referenced by connectSignals(), notifyConnectionEstablished(), and WModuleInputForwardData< T >::notifyDataChange().
|
protectedvirtual |
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().
|
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 92 of file WModuleInputConnector.cpp.
References signal_DataChanged, and WModuleConnector::subscribeSignal().
|
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.
Referenced by WMTransferFunction1D::moduleMain().
|
private |
Connection for Data Changed signal of the connected output connector.
Definition at line 166 of file WModuleInputConnector.h.
Referenced by connectSignals(), disconnectSignals(), and ~WModuleInputConnector().
|
private |
A flag denoting that an update was received.
It does not denote a real change in the value!
Definition at line 176 of file WModuleInputConnector.h.
Referenced by handledUpdate(), setUpdated(), and updated().
|
private |
This lock protects the m_updated flag.
Definition at line 171 of file WModuleInputConnector.h.
Referenced by handledUpdate(), setUpdated(), and updated().
|
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 161 of file WModuleInputConnector.h.
Referenced by notifyDataChange(), subscribeSignal(), and WModuleInputConnector().