Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
1b3bfae0
Commit
1b3bfae0
authored
Jul 06, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - module container now propagate connection events to the GUI
parent
685f3e79
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
385 additions
and
3 deletions
+385
-3
src/gui/qt4/WQt4Gui.cpp
src/gui/qt4/WQt4Gui.cpp
+22
-0
src/gui/qt4/WQt4Gui.h
src/gui/qt4/WQt4Gui.h
+16
-0
src/gui/qt4/WQtCombinerActionList.cpp
src/gui/qt4/WQtCombinerActionList.cpp
+2
-2
src/gui/qt4/events/WEventTypes.h
src/gui/qt4/events/WEventTypes.h
+6
-0
src/gui/qt4/events/WModuleConnectEvent.cpp
src/gui/qt4/events/WModuleConnectEvent.cpp
+51
-0
src/gui/qt4/events/WModuleConnectEvent.h
src/gui/qt4/events/WModuleConnectEvent.h
+84
-0
src/gui/qt4/events/WModuleDisconnectEvent.cpp
src/gui/qt4/events/WModuleDisconnectEvent.cpp
+51
-0
src/gui/qt4/events/WModuleDisconnectEvent.h
src/gui/qt4/events/WModuleDisconnectEvent.h
+84
-0
src/kernel/WModuleContainer.cpp
src/kernel/WModuleContainer.cpp
+43
-1
src/kernel/WModuleContainer.h
src/kernel/WModuleContainer.h
+26
-0
No files found.
src/gui/qt4/WQt4Gui.cpp
View file @
1b3bfae0
...
...
@@ -46,6 +46,8 @@
#include "events/WModuleCrashEvent.h"
#include "events/WModuleReadyEvent.h"
#include "events/WModuleRemovedEvent.h"
#include "events/WModuleConnectEvent.h"
#include "events/WModuleDisconnectEvent.h"
#include "events/WOpenCustomDockWidgetEvent.h"
#include "events/WRoiAssocEvent.h"
#include "events/WRoiRemoveEvent.h"
...
...
@@ -171,6 +173,14 @@ int WQt4Gui::run()
t_ModuleGenericSignalHandlerType
removedSignal
=
boost
::
bind
(
&
WQt4Gui
::
slotRemoveDatasetOrModuleInBrowser
,
this
,
_1
);
m_kernel
->
getRootContainer
()
->
addDefaultNotifier
(
WM_REMOVED
,
removedSignal
);
// Connect Event
t_GenericSignalHandlerType
connectionEstablishedSignal
=
boost
::
bind
(
&
WQt4Gui
::
slotConnectionEstablished
,
this
,
_1
,
_2
);
m_kernel
->
getRootContainer
()
->
addDefaultNotifier
(
CONNECTION_ESTABLISHED
,
connectionEstablishedSignal
);
// Disconnect Event
t_GenericSignalHandlerType
connectionClosedSignal
=
boost
::
bind
(
&
WQt4Gui
::
slotConnectionClosed
,
this
,
_1
,
_2
);
m_kernel
->
getRootContainer
()
->
addDefaultNotifier
(
CONNECTION_CLOSED
,
connectionClosedSignal
);
boost
::
function
<
void
(
boost
::
shared_ptr
<
WRMROIRepresentation
>
)
>
assocRoiSignal
=
boost
::
bind
(
&
WQt4Gui
::
slotAddRoiToBrowser
,
this
,
_1
);
m_kernel
->
getRoiManager
()
->
addAddNotifier
(
assocRoiSignal
);
...
...
@@ -285,6 +295,18 @@ void WQt4Gui::slotRemoveDatasetOrModuleInBrowser( boost::shared_ptr< WModule > m
QCoreApplication
::
postEvent
(
m_mainWindow
->
getDatasetBrowser
(),
new
WModuleRemovedEvent
(
module
)
);
}
void
WQt4Gui
::
slotConnectionEstablished
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
)
{
// create a new event for this and insert it into event queue
QCoreApplication
::
postEvent
(
m_mainWindow
->
getDatasetBrowser
(),
new
WModuleConnectEvent
(
in
,
out
)
);
}
void
WQt4Gui
::
slotConnectionClosed
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
)
{
// create a new event for this and insert it into event queue
QCoreApplication
::
postEvent
(
m_mainWindow
->
getDatasetBrowser
(),
new
WModuleDisconnectEvent
(
in
,
out
)
);
}
boost
::
shared_ptr
<
WModule
>
WQt4Gui
::
getSelectedModule
()
{
return
m_mainWindow
->
getDatasetBrowser
()
->
getSelectedModule
();
...
...
src/gui/qt4/WQt4Gui.h
View file @
1b3bfae0
...
...
@@ -114,6 +114,22 @@ public:
*/
virtual
void
slotRemoveDatasetOrModuleInBrowser
(
boost
::
shared_ptr
<
WModule
>
module
);
/**
* Slot gets called whenever a connector pair got connected.
*
* \param in input connector
* \param out output connector
*/
virtual
void
slotConnectionEstablished
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
);
/**
* Slot gets called whenever a connector pair got disconnected.
*
* \param in input connector
* \param out output connector
*/
virtual
void
slotConnectionClosed
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
);
/**
* getter functions for the signales proved by the gui
*/
...
...
src/gui/qt4/WQtCombinerActionList.cpp
View file @
1b3bfae0
...
...
@@ -72,7 +72,7 @@ WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* ico
for
(
WCombinerTypes
::
WOneToOneCombiners
::
iterator
combiner
=
(
*
groups
).
second
.
begin
();
combiner
!=
(
*
groups
).
second
.
end
();
++
combiner
)
{
WQtModuleOneToOneCombinerAction
*
a
=
new
WQtModuleOneToOneCombinerAction
(
parent
,
icons
,
*
groups
->
second
.
begin
()
,
true
);
WQtModuleOneToOneCombinerAction
*
a
=
new
WQtModuleOneToOneCombinerAction
(
parent
,
icons
,
*
combiner
,
true
);
a
->
setIconVisibleInMenu
(
true
);
groupMenu
->
addAction
(
a
);
...
...
@@ -102,7 +102,7 @@ WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* ico
for
(
WCombinerTypes
::
WOneToOneCombiners
::
iterator
combiner
=
(
*
groups
).
second
.
begin
();
combiner
!=
(
*
groups
).
second
.
end
();
++
combiner
)
{
WQtModuleOneToOneCombinerAction
*
a
=
new
WQtModuleOneToOneCombinerAction
(
parent
,
icons
,
*
groups
->
second
.
begin
()
,
true
);
WQtModuleOneToOneCombinerAction
*
a
=
new
WQtModuleOneToOneCombinerAction
(
parent
,
icons
,
*
combiner
,
true
);
a
->
setIconVisibleInMenu
(
true
);
groupMenu
->
addAction
(
a
);
...
...
src/gui/qt4/events/WEventTypes.h
View file @
1b3bfae0
...
...
@@ -60,4 +60,10 @@
// when a module should be deleted finally.
#define WQT_MODULE_DELETE_EVENT QEvent::User + 9
// when a module connection got established.
#define WQT_MODULE_CONNECT_EVENT QEvent::User + 10
// when a module connection got closed.
#define WQT_MODULE_DISCONNECT_EVENT QEvent::User + 11
#endif // WEVENTTYPES_H
src/gui/qt4/events/WModuleConnectEvent.cpp
0 → 100644
View file @
1b3bfae0
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WEventTypes.h"
#include "WModuleConnectEvent.h"
WModuleConnectEvent
::
WModuleConnectEvent
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
)
:
QEvent
(
static_cast
<
QEvent
::
Type
>
(
WQT_MODULE_CONNECT_EVENT
)
),
m_in
(
in
),
m_out
(
out
)
{
// initialize members
}
WModuleConnectEvent
::~
WModuleConnectEvent
()
{
// cleanup
}
boost
::
shared_ptr
<
WModuleConnector
>
WModuleConnectEvent
::
getInput
()
const
{
return
m_in
;
}
boost
::
shared_ptr
<
WModuleConnector
>
WModuleConnectEvent
::
getOutput
()
const
{
return
m_out
;
}
src/gui/qt4/events/WModuleConnectEvent.h
0 → 100644
View file @
1b3bfae0
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMODULECONNECTEVENT_H
#define WMODULECONNECTEVENT_H
#include <boost/shared_ptr.hpp>
#include <QtCore/QEvent>
#include "../../../kernel/WModuleConnector.h"
/**
* Event signalling a module connection was established.
*/
class
WModuleConnectEvent
:
public
QEvent
{
public:
/**
* Creates a new event denoting the established connection between both connectors.
*
* \param in the input
* \param out the output
*/
WModuleConnectEvent
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
);
/**
* Destructor.
*/
virtual
~
WModuleConnectEvent
();
/**
* Gets the input connector involved in this connection event.
*
* \return the connector.
*/
boost
::
shared_ptr
<
WModuleConnector
>
getInput
()
const
;
/**
* Gets the output connector involved in this connection event.
*
* \return the connector.
*/
boost
::
shared_ptr
<
WModuleConnector
>
getOutput
()
const
;
protected:
/**
* The input.
*/
boost
::
shared_ptr
<
WModuleConnector
>
m_in
;
/**
* The output.
*/
boost
::
shared_ptr
<
WModuleConnector
>
m_out
;
private:
};
#endif // WMODULECONNECTEVENT_H
src/gui/qt4/events/WModuleDisconnectEvent.cpp
0 → 100644
View file @
1b3bfae0
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WEventTypes.h"
#include "WModuleDisconnectEvent.h"
WModuleDisconnectEvent
::
WModuleDisconnectEvent
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
)
:
QEvent
(
static_cast
<
QEvent
::
Type
>
(
WQT_MODULE_DISCONNECT_EVENT
)
),
m_in
(
in
),
m_out
(
out
)
{
// initialize members
}
WModuleDisconnectEvent
::~
WModuleDisconnectEvent
()
{
// cleanup
}
boost
::
shared_ptr
<
WModuleConnector
>
WModuleDisconnectEvent
::
getInput
()
const
{
return
m_in
;
}
boost
::
shared_ptr
<
WModuleConnector
>
WModuleDisconnectEvent
::
getOutput
()
const
{
return
m_out
;
}
src/gui/qt4/events/WModuleDisconnectEvent.h
0 → 100644
View file @
1b3bfae0
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMODULEDISCONNECTEVENT_H
#define WMODULEDISCONNECTEVENT_H
#include <boost/shared_ptr.hpp>
#include <QtCore/QEvent>
#include "../../../kernel/WModuleConnector.h"
/**
* Event signalling a module connection was closed.
*/
class
WModuleDisconnectEvent
:
public
QEvent
{
public:
/**
* Creates a new event denoting the established connection between both connectors.
*
* \param in the input
* \param out the output
*/
WModuleDisconnectEvent
(
boost
::
shared_ptr
<
WModuleConnector
>
in
,
boost
::
shared_ptr
<
WModuleConnector
>
out
);
/**
* Destructor.
*/
virtual
~
WModuleDisconnectEvent
();
/**
* Gets the input connector involved in this connection event.
*
* \return the connector.
*/
boost
::
shared_ptr
<
WModuleConnector
>
getInput
()
const
;
/**
* Gets the output connector involved in this connection event.
*
* \return the connector.
*/
boost
::
shared_ptr
<
WModuleConnector
>
getOutput
()
const
;
protected:
/**
* The input.
*/
boost
::
shared_ptr
<
WModuleConnector
>
m_in
;
/**
* The output.
*/
boost
::
shared_ptr
<
WModuleConnector
>
m_out
;
private:
};
#endif // WMODULEDISCONNECTEVENT_H
src/kernel/WModuleContainer.cpp
View file @
1b3bfae0
...
...
@@ -128,7 +128,7 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
boost
::
signals2
::
connection
signalCon
=
module
->
subscribeSignal
(
WM_ERROR
,
func
);
subscriptionsLock
->
get
().
insert
(
ModuleSubscription
(
module
,
signalCon
)
);
// connect default
ready/error
notifiers
// connect default notifiers
:
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_errorNotifiersLock
);
for
(
std
::
list
<
t_ModuleErrorSignalHandlerType
>::
iterator
iter
=
m_errorNotifiers
.
begin
();
iter
!=
m_errorNotifiers
.
end
();
++
iter
)
{
...
...
@@ -141,6 +141,25 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
// call associated notifier
(
*
iter
)(
module
);
}
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_connectorNotifiersLock
);
for
(
std
::
list
<
t_GenericSignalHandlerType
>::
iterator
iter
=
m_connectorEstablishedNotifiers
.
begin
();
iter
!=
m_connectorEstablishedNotifiers
.
end
();
++
iter
)
{
// subscribe on each input
for
(
InputConnectorList
::
const_iterator
ins
=
module
->
getInputConnectors
().
begin
();
ins
!=
module
->
getInputConnectors
().
end
();
++
ins
)
{
signalCon
=
(
*
ins
)
->
subscribeSignal
(
CONNECTION_ESTABLISHED
,
(
*
iter
)
);
subscriptionsLock
->
get
().
insert
(
ModuleSubscription
(
module
,
signalCon
)
);
}
}
for
(
std
::
list
<
t_GenericSignalHandlerType
>::
iterator
iter
=
m_connectorClosedNotifiers
.
begin
();
iter
!=
m_connectorClosedNotifiers
.
end
();
++
iter
)
{
// subscribe on each input
for
(
InputConnectorList
::
const_iterator
ins
=
module
->
getInputConnectors
().
begin
();
ins
!=
module
->
getInputConnectors
().
end
();
++
ins
)
{
signalCon
=
(
*
ins
)
->
subscribeSignal
(
CONNECTION_CLOSED
,
(
*
iter
)
);
subscriptionsLock
->
get
().
insert
(
ModuleSubscription
(
module
,
signalCon
)
);
}
}
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_readyNotifiersLock
);
for
(
std
::
list
<
t_ModuleGenericSignalHandlerType
>::
iterator
iter
=
m_readyNotifiers
.
begin
();
iter
!=
m_readyNotifiers
.
end
();
++
iter
)
{
...
...
@@ -334,6 +353,29 @@ void WModuleContainer::addDefaultNotifier( MODULE_SIGNAL signal, t_ModuleErrorSi
}
}
void
WModuleContainer
::
addDefaultNotifier
(
MODULE_CONNECTOR_SIGNAL
signal
,
t_GenericSignalHandlerType
notifier
)
{
boost
::
unique_lock
<
boost
::
shared_mutex
>
lock
;
switch
(
signal
)
{
case
CONNECTION_ESTABLISHED
:
lock
=
boost
::
unique_lock
<
boost
::
shared_mutex
>
(
m_connectorNotifiersLock
);
m_connectorEstablishedNotifiers
.
push_back
(
notifier
);
lock
.
unlock
();
break
;
case
CONNECTION_CLOSED
:
lock
=
boost
::
unique_lock
<
boost
::
shared_mutex
>
(
m_connectorNotifiersLock
);
m_connectorClosedNotifiers
.
push_back
(
notifier
);
lock
.
unlock
();
break
;
default:
std
::
ostringstream
s
;
s
<<
"Could not subscribe to unknown signal."
;
throw
WModuleSignalSubscriptionFailed
(
s
.
str
()
);
break
;
}
}
boost
::
shared_ptr
<
WModule
>
WModuleContainer
::
applyModule
(
boost
::
shared_ptr
<
WModule
>
applyOn
,
std
::
string
what
,
bool
tryOnly
)
{
boost
::
shared_ptr
<
WModule
>
prototype
=
boost
::
shared_ptr
<
WModule
>
();
...
...
src/kernel/WModuleContainer.h
View file @
1b3bfae0
...
...
@@ -39,6 +39,7 @@
#include "../common/WSharedObject.h"
#include "WModuleCombinerTypes.h"
#include "WModuleConnectorSignals.h"
#include "WModuleSignals.h"
class
WThreadedRunner
;
...
...
@@ -160,6 +161,16 @@ public:
*/
virtual
void
addDefaultNotifier
(
MODULE_SIGNAL
signal
,
t_ModuleGenericSignalHandlerType
notifier
);
/**
* Add a specified notifier to the list of default notifiers which get connected to each added module. This is especially used for all the
* connector related events like connect and disconnect.
* \note This signal is only called for input connectors!
*
* \param signal the signal the notifier should get connected to
* \param notifier the notifier function
*/
virtual
void
addDefaultNotifier
(
MODULE_CONNECTOR_SIGNAL
signal
,
t_GenericSignalHandlerType
notifier
);
/**
* Function combines two modules. This runs synchronously. It might take some time to finish since combination of modules is
* allowed only with modules marked as "ready" which might take some time.
...
...
@@ -328,6 +339,21 @@ protected:
*/
std
::
list
<
t_ModuleGenericSignalHandlerType
>
m_removedNotifiers
;
/**
* Lock for connector-notifiers set.
*/
boost
::
shared_mutex
m_connectorNotifiersLock
;
/**
* The notifiers connected to added modules by default and fired whenever the module connectors got connected.
*/
std
::
list
<
t_GenericSignalHandlerType
>
m_connectorEstablishedNotifiers
;
/**
* The notifiers connected to added modules by default and fired whenever the module connectors got disconnected.
*/
std
::
list
<
t_GenericSignalHandlerType
>
m_connectorClosedNotifiers
;
/**
* Set of all threads that currently depend upon this container.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment