25 #ifndef WMODULECONNECTOR_H
26 #define WMODULECONNECTOR_H
30 #include <shared_mutex>
33 #include <boost/bind/bind.hpp>
34 #include <boost/signals2/connection.hpp>
35 #include <boost/signals2/signal.hpp>
36 #include <boost/thread.hpp>
39 #include "WModuleCombinerTypes.h"
40 #include "WModuleConnectorSignals.h"
60 typedef std::shared_ptr< WModuleConnector >
SPtr;
65 typedef std::shared_ptr< const WModuleConnector >
ConstSPtr;
74 WModuleConnector( std::shared_ptr< WModule > module, std::string name=
"", std::string description=
"" );
86 std::shared_ptr< WModule >
getModule()
const;
94 virtual void disconnect( std::shared_ptr<WModuleConnector> con,
bool removeFromOwnList =
true );
110 virtual void connect( std::shared_ptr<WModuleConnector> con,
bool force =
false );
141 virtual boost::signals2::connection
subscribeSignal( MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier );
162 const std::string
getName()
const;
177 void setName( std::string name );
186 virtual bool connectable( std::shared_ptr<WModuleConnector> con ) = 0;
259 virtual void connectSignals( std::shared_ptr<WModuleConnector> con );
277 virtual const t_GenericSignalHandlerType
getSignalHandler( MODULE_CONNECTOR_SIGNAL signal );
303 virtual void notifyConnectionClosed( std::shared_ptr<WModuleConnector> here, std::shared_ptr<WModuleConnector> there );
Tests the WModuleConnector class.
Base class for modelling connections between kernel modules.
const std::string getDescription() const
Gives information about this connection.
virtual bool isInputConnector() const =0
Returns true if this instance is an WModuleInputConnector.
virtual void disconnect(std::shared_ptr< WModuleConnector > con, bool removeFromOwnList=true)
Disconnects this connector if connected.
unsigned int isConnected()
Gets the count of connections currently established.
bool isConnectedTo(std::shared_ptr< WModuleConnector > con)
Checks whether this connector is connected to the given one.
std::string m_description
The connections description.
std::string m_moduleName
The name of the module owning this connector.
virtual const t_GenericSignalHandlerType getSignalHandler(MODULE_CONNECTOR_SIGNAL signal)
Gives the signal handler function responsible for a given signal.
std::shared_ptr< WModuleOutputConnector > toOutputConnector()
Tries to convert this instance to an output connector.
const std::string getCanonicalName() const
Gives canonical name of connection.
std::shared_ptr< const WModuleConnector > ConstSPtr
Const shared pointer to this class.
virtual void connectSignals(std::shared_ptr< WModuleConnector > con)
Connect additional signals.
std::shared_ptr< WCondition > getDataChangedCondition()
Gets the condition variable that gets fired whenever new data has been sent.
std::string m_name
The connections name.
t_GenericSignalType signal_ConnectionClosed
Signal emitted whenever connection has been closed.
virtual void disconnectAll()
Disconnects ALL connected connectors.
virtual void disconnectSignals(std::shared_ptr< WModuleConnector > con)
Disconnect all signals subscribed by this connector from "con".
t_GenericSignalType signal_ConnectionEstablished
Signal emitted whenever connection has been established.
std::shared_ptr< WModuleInputConnector > toInputConnector()
Tries to convert this instance to an input connector.
virtual bool connectable(std::shared_ptr< WModuleConnector > con)=0
Checks whether the specified connector is connectable to this one.
WCombinerTypes::WOneToOneCombiners getPossibleDisconnections()
Returns a list of possible disconnections for this connector.
virtual bool isOutputConnector() const =0
Returns true if this instance is an WModuleOutputConnector.
std::shared_ptr< WModuleConnector > SPtr
Shared pointer to this class.
virtual boost::signals2::connection subscribeSignal(MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier)
Connects a specified notify function with a signal this module instance is offering.
virtual void notifyConnectionEstablished(std::shared_ptr< WModuleConnector > here, std::shared_ptr< WModuleConnector > there)
Gets called whenever a connector gets connected to the specified input.
std::shared_ptr< WCondition > m_dataChangedCondition
Condition fired whenever data changes.
const std::string getName() const
Gives name of connection.
std::set< std::shared_ptr< WModuleConnector > > m_connected
List of connectors connected to this connector.
std::shared_mutex m_connectionListLock
Lock for avoiding concurrent write to m_Connected (multiple reader, single writer lock).
void setName(std::string name)
Sets the connector's name.
void setDescription(std::string desc)
Sets the connector's description.
std::shared_ptr< WModule > getModule() const
Returns the module which owns this connector.
virtual void connect(std::shared_ptr< WModuleConnector > con, bool force=false)
Connects this Module Connector with another one.
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.
virtual ~WModuleConnector()
Destructor.
WModuleConnector(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Constructor.
virtual bool lazyConnectable(std::shared_ptr< WModuleConnector > con)=0
Checks whether the specified connector is connectable to this one, but ignores compatibility the type...
std::weak_ptr< WModule > m_module
The Module this connector belongs to.
Class implementing output connection functionality between modules.
This class is able to parse project files and create the appropriate module graph inside a specified ...