OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
WModuleInputConnector Class Reference

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

#include <WModuleInputConnector.h>

+ Inheritance diagram for WModuleInputConnector:
+ Collaboration diagram for WModuleInputConnector:

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< WModulegetModule () 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< WModuleInputConnectortoInputConnector ()
 Tries to convert this instance to an input connector. More...
 
std::shared_ptr< WModuleOutputConnectortoOutputConnector ()
 Tries to convert this instance to an output connector. More...
 
std::shared_ptr< WConditiongetDataChangedCondition ()
 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< WModuleConnectorSPtr
 Shared pointer to this class. More...
 
typedef std::shared_ptr< const WModuleConnectorConstSPtr
 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< WModulem_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< WConditionm_dataChangedCondition
 Condition fired whenever data changes. More...
 

Detailed Description

Class implementing input connection functionality between modules.

Definition at line 43 of file WModuleInputConnector.h.

Constructor & Destructor Documentation

◆ WModuleInputConnector()

WModuleInputConnector::WModuleInputConnector ( std::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 33 of file WModuleInputConnector.cpp.

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

+ Here is the call graph for this function:

◆ ~WModuleInputConnector()

WModuleInputConnector::~WModuleInputConnector ( )
virtual

Destructor.

Definition at line 46 of file WModuleInputConnector.cpp.

References m_DataChangedConnection, and WModuleConnector::signal_ConnectionClosed.

Member Function Documentation

◆ connectable()

bool WModuleInputConnector::connectable ( std::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 >, and WModuleInputData< WDataSetSingle >.

Definition at line 53 of file WModuleInputConnector.cpp.

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

+ Here is the caller graph for this function:

◆ connectSignals()

void WModuleInputConnector::connectSignals ( std::shared_ptr< WModuleConnector con)
protectedvirtual

Connect additional signals.

Parameters
conthe connector that requests connection.

Reimplemented from WModuleConnector.

Definition at line 73 of file WModuleInputConnector.cpp.

References WModuleConnector::connectSignals(), m_DataChangedConnection, and notifyDataChange().

+ Here is the call graph for this function:

◆ disconnectSignals()

void WModuleInputConnector::disconnectSignals ( std::shared_ptr< WModuleConnector con)
protectedvirtual

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

Parameters
conthe connector that gets disconnected.

Reimplemented from WModuleConnector.

Definition at line 85 of file WModuleInputConnector.cpp.

References WModuleConnector::disconnectSignals(), and m_DataChangedConnection.

+ Here is the call graph for this function:

◆ handledUpdate()

bool WModuleInputConnector::handledUpdate ( )
virtual

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 149 of file WModuleInputConnector.cpp.

References m_updated, and m_updatedLock.

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

+ Here is the caller graph for this function:

◆ isInputConnector()

bool WModuleInputConnector::isInputConnector ( ) const
virtual

Returns true if this instance is an WModuleInputConnector.

Returns
true if castable to WModuleInputConnector.

Implements WModuleConnector.

Definition at line 127 of file WModuleInputConnector.cpp.

◆ isOutputConnector()

bool WModuleInputConnector::isOutputConnector ( ) const
virtual

Returns true if this instance is an WModuleOutputConnector.

Returns
true if castable to WModuleOutputConnector.

Implements WModuleConnector.

Definition at line 132 of file WModuleInputConnector.cpp.

◆ lazyConnectable()

bool WModuleInputConnector::lazyConnectable ( std::shared_ptr< WModuleConnector con)
virtual

Checks whether the specified connector is connectable to this one, but ignores compatibility the type to be transferred.

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

Implements WModuleConnector.

Definition at line 63 of file WModuleInputConnector.cpp.

◆ notifyConnectionEstablished()

void WModuleInputConnector::notifyConnectionEstablished ( std::shared_ptr< WModuleConnector here,
std::shared_ptr< WModuleConnector there 
)
protectedvirtual

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 116 of file WModuleInputConnector.cpp.

References WModuleConnector::notifyConnectionEstablished(), and notifyDataChange().

+ Here is the call graph for this function:

◆ notifyDataChange()

void WModuleInputConnector::notifyDataChange ( std::shared_ptr< WModuleConnector input,
std::shared_ptr< WModuleConnector output 
)
protectedvirtual

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 >, 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUpdated()

void WModuleInputConnector::setUpdated ( )
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().

+ Here is the caller graph for this function:

◆ subscribeSignal()

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 92 of file WModuleInputConnector.cpp.

References signal_DataChanged, and WModuleConnector::subscribeSignal().

+ Here is the call graph for this function:

◆ updated()

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 137 of file WModuleInputConnector.cpp.

References m_updated, and m_updatedLock.

Referenced by WMTransferFunction1D::moduleMain().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_DataChangedConnection

boost::signals2::connection WModuleInputConnector::m_DataChangedConnection
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().

◆ m_updated

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 176 of file WModuleInputConnector.h.

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

◆ m_updatedLock

std::shared_mutex WModuleInputConnector::m_updatedLock
private

This lock protects the m_updated flag.

Definition at line 171 of file WModuleInputConnector.h.

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

◆ signal_DataChanged

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 161 of file WModuleInputConnector.h.

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


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