Commit 18e9f453 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[STYLE]

[CHANGE] - disconnect combiner now works
parent d2185ba5
......@@ -307,7 +307,6 @@ void WMainWindow::setupPermanentToolBar()
{
addToolBar( toQtToolBarArea( getToolbarPos() ), m_permanentToolBar );
}
}
void WMainWindow::autoAdd( boost::shared_ptr< WModule > module, std::string proto )
......
......@@ -26,8 +26,9 @@
#include "WQtModuleOneToOneCombinerAction.h"
WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction( QWidget* parent, WIconManager* iconManager, boost::shared_ptr< WModuleOneToOneCombiner > combiner,
bool advancedText ):
WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction( QWidget* parent, WIconManager* iconManager,
boost::shared_ptr< WModuleOneToOneCombiner > combiner,
bool advancedText ):
QAction( parent ),
m_combiner( combiner )
{
......@@ -48,14 +49,14 @@ WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction( QWidget* paren
// append real module name if it is different from user specified name
if ( srcName != m_combiner->getSrcModule()->getName() )
{
srcName+=" (" + m_combiner->getSrcModule()->getName() + ")";
srcName += " (" + m_combiner->getSrcModule()->getName() + ")";
}
}
// append real module name if it is different from user specified name
if ( targetName != m_combiner->getTargetModule()->getName() )
{
targetName+=" (" + m_combiner->getTargetModule()->getName() + ")";
targetName += " (" + m_combiner->getTargetModule()->getName() + ")";
}
from = srcName + ":" + m_combiner->getSrcConnector() + " -> ";
......
......@@ -243,7 +243,7 @@ const WModule::OutputConnectorList& WModule::getOutputConnectors() const
return m_outputConnectors;
}
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name )
boost::shared_ptr< WModuleInputConnector > WModule::findInputConnector( std::string name )
{
// simply search
for( InputConnectorList::const_iterator listIter = m_inputConnectors.begin();
......@@ -256,10 +256,22 @@ boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::stri
}
}
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
return boost::shared_ptr< WModuleInputConnector >();
}
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name )
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name )
{
boost::shared_ptr< WModuleInputConnector > p = findInputConnector( name );
if ( !p )
{
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
}
return p;
}
boost::shared_ptr< WModuleOutputConnector > WModule::findOutputConnector( std::string name )
{
// simply search
for( OutputConnectorList::const_iterator listIter = m_outputConnectors.begin();
......@@ -272,7 +284,44 @@ boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::st
}
}
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
return boost::shared_ptr< WModuleOutputConnector >();
}
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name )
{
boost::shared_ptr< WModuleOutputConnector > p = findOutputConnector( name );
if ( !p )
{
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
}
return p;
}
boost::shared_ptr< WModuleConnector > WModule::findConnector( std::string name )
{
// simply search both
boost::shared_ptr< WModuleConnector > p = findInputConnector( name );
if ( p ) // found?
{
return p;
}
// search in output list
return findOutputConnector( name );
}
boost::shared_ptr< WModuleConnector > WModule::getConnector( std::string name )
{
boost::shared_ptr< WModuleConnector > p = findConnector( name );
if ( !p )
{
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
}
return p;
}
boost::signals2::connection WModule::subscribeSignal( MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier )
......
......@@ -110,6 +110,16 @@ public:
*/
boost::shared_ptr< WModuleInputConnector > getInputConnector( std::string name );
/**
* Finds the named connector for the module. This is similar to getInputConnector but it does not throw an exception if the connector could
* not be found.
*
* \param name the name. This can be a canonical name or the connector name.
*
* \return the connector or NULL if not found
*/
boost::shared_ptr< WModuleInputConnector > findInputConnector( std::string name );
/**
* Gives back output connectors.
*
......@@ -127,6 +137,36 @@ public:
*/
boost::shared_ptr< WModuleOutputConnector > getOutputConnector( std::string name );
/**
* Finds the named connector for the module. This is similar to getOutputConnector but it does not throw an exception if the connector could
* not be found.
*
* \param name the name. This can be a canonical name or the connector name.
*
* \return the connector or NULL if not found.
*/
boost::shared_ptr< WModuleOutputConnector > findOutputConnector( std::string name );
/**
* Finds the named connector for the module. This searches for inputs and outputs.
*
* \param name the name. This can be a canonical name or the connector name.
*
* \return the connector.
* \throw WModuleConnectorNotFound thrown whenever the module does not provide the specified connector.
*/
boost::shared_ptr< WModuleConnector > getConnector( std::string name );
/**
* Finds the named connector for the module. This searches for inputs and outputs. This is similar to getConnector but it does not throw an
* exception if the connector could not be found.
*
* \param name the name. This can be a canonical name or the connector name.
*
* \return the connector or NULL if not found.
*/
boost::shared_ptr< WModuleConnector > findConnector( std::string name );
/**
* Return a pointer to the properties object of the module.
*
......
......@@ -26,6 +26,8 @@
#define WMODULECOMBINERTYPES_H
#include <string>
#include <utility>
#include <vector>
#include <boost/shared_ptr.hpp>
......
......@@ -225,11 +225,20 @@ boost::shared_ptr< WModule > WModuleConnector::getModule() const
void WModuleConnector::disconnect( boost::shared_ptr<WModuleConnector> con, bool removeFromOwnList )
{
boost::shared_ptr< WModule > module = m_module.lock(); // it is "unlocked" at the end of this function as "module" looses its scope
boost::shared_ptr< WModuleContainer > container = module->getAssociatedContainer();
std::string containerName = container.get() ? container->getName() : "Unknown";
if ( !isConnectedTo( con ) )
{
WLogger::getLogger()->addLogMessage( "Could not disconnect " + con->getCanonicalName() + " from " + getCanonicalName() + " as they are"+
" not connected.", "ModuleContainer (" + containerName + ")", LL_INFO );
return;
}
WLogger::getLogger()->addLogMessage( "Disconnecting " + con->getCanonicalName() + " from " + getCanonicalName(),
"ModuleContainer (" + containerName + ")", LL_INFO );
// write lock
boost::unique_lock<boost::shared_mutex> lock;
try
......
......@@ -79,7 +79,8 @@ boost::shared_ptr< WModule > WModuleContainer::factory() const
void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
{
if ( !module )
{ // just ignore NULL Pointer
{
// just ignore NULL Pointer
return;
}
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "../WModuleFactory.h"
#include "WApplyCombiner.h"
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WDisconnectCombiner.h"
WDisconnectCombiner::WDisconnectCombiner( boost::shared_ptr< WModuleContainer > target,
......@@ -50,5 +52,17 @@ WDisconnectCombiner::~WDisconnectCombiner()
void WDisconnectCombiner::apply()
{
// get first connector
boost::shared_ptr< WModuleConnector > c1 = m_srcModule->findConnector( m_srcConnector );
boost::shared_ptr< WModuleConnector > c2 = m_targetModule->findConnector( m_targetConnector );
// check if they really existed
if ( !c1 || !c2 )
{
return;
}
// and do it
c1->disconnect( c2 );
}
......@@ -61,7 +61,6 @@ public:
/**
* Creates a combiner which disconnects the specified connection. If the specified connection does not exist (anymore), nothing will happen.
*
* \param target the target container
* \param srcModule the module whose connector should be disconnected
* \param srcConnector the srcModule connector to disconnect
* \param targetModule the module whose connector should be disconnected from srcConnector
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WModuleOneToOneCombiner.h"
WModuleOneToOneCombiner::WModuleOneToOneCombiner( boost::shared_ptr< WModuleContainer > target,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment