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
564bd605
Commit
564bd605
authored
Apr 21, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - prepared connectors to use weak pointers to manage the module
parent
6794f199
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
src/kernel/WModuleConnector.cpp
src/kernel/WModuleConnector.cpp
+8
-5
src/kernel/WModuleConnector.h
src/kernel/WModuleConnector.h
+5
-0
src/kernel/combiner/WModuleProjectFileCombiner.cpp
src/kernel/combiner/WModuleProjectFileCombiner.cpp
+3
-1
No files found.
src/kernel/WModuleConnector.cpp
View file @
564bd605
...
...
@@ -48,6 +48,7 @@ WModuleConnector::WModuleConnector( boost::shared_ptr< WModule > module, std::st
{
// initialize members
m_module
=
module
;
m_moduleName
=
module
->
getName
();
m_name
=
name
;
m_description
=
description
;
...
...
@@ -103,10 +104,11 @@ unsigned int WModuleConnector::isConnected()
void
WModuleConnector
::
connect
(
boost
::
shared_ptr
<
WModuleConnector
>
con
)
{
boost
::
shared_ptr
<
WModuleContainer
>
container
=
m_module
->
getAssociatedContainer
();
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"
;
WLogger
::
getLogger
()
->
addLogMessage
(
"Connecting "
+
con
->
getCanonicalName
()
+
" with "
+
getCanonicalName
()
,
"ModuleContainer ("
+
containerName
+
")"
,
LL_INFO
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Connecting "
+
con
->
getCanonicalName
()
+
" with "
+
getCanonicalName
()
,
"ModuleContainer ("
+
containerName
+
")"
,
LL_INFO
);
// are both partners compatible to each other?
if
(
!
(
con
->
connectable
(
shared_from_this
()
)
&&
connectable
(
con
)
)
)
...
...
@@ -203,7 +205,8 @@ boost::signals2::connection WModuleConnector::subscribeSignal( MODULE_CONNECTOR_
const
t_GenericSignalHandlerType
WModuleConnector
::
getSignalHandler
(
MODULE_CONNECTOR_SIGNAL
signal
)
{
// the module instance knows that
return
m_module
->
getSignalHandler
(
signal
);
boost
::
shared_ptr
<
WModule
>
module
=
m_module
;
//.lock(); // it is "unlocked" at the end of this function as "module" looses its scope
return
module
->
getSignalHandler
(
signal
);
}
void
WModuleConnector
::
disconnect
(
boost
::
shared_ptr
<
WModuleConnector
>
con
,
bool
removeFromOwnList
)
...
...
@@ -291,7 +294,7 @@ const std::string WModuleConnector::getName() const
const
std
::
string
WModuleConnector
::
getCanonicalName
()
const
{
std
::
ostringstream
s
;
s
<<
m_module
->
get
Name
()
<<
":"
<<
getName
();
s
<<
m_moduleName
<<
":"
<<
getName
();
return
s
.
str
();
}
...
...
src/kernel/WModuleConnector.h
View file @
564bd605
...
...
@@ -207,6 +207,11 @@ protected:
*/
boost
::
shared_ptr
<
WModule
>
m_module
;
/**
* The name of the module owning this connector.
*/
std
::
string
m_moduleName
;
/**
* Gets called whenever a connector gets connected to the specified input.
*
...
...
src/kernel/combiner/WModuleProjectFileCombiner.cpp
View file @
564bd605
...
...
@@ -399,8 +399,10 @@ void WModuleProjectFileCombiner::save( std::ostream& output ) // NOLINT
for
(
std
::
set
<
boost
::
shared_ptr
<
WModuleConnector
>
>::
const_iterator
iciter
=
(
*
citer
)
->
m_connected
.
begin
();
iciter
!=
(
*
citer
)
->
m_connected
.
end
();
++
iciter
)
{
// as the module is a weak_ptr -> lock and get access to it
boost
::
shared_ptr
<
WModule
>
theOtherModule
=
(
*
iciter
)
->
m_module
;
//.lock();
output
<<
"CONNECTION:("
<<
moduleToIDMap
[
(
*
iter
)
]
<<
","
<<
(
*
citer
)
->
getName
()
<<
")->("
<<
moduleToIDMap
[
(
*
iciter
)
->
m_m
odule
]
<<
","
<<
(
*
iciter
)
->
getName
()
<<
")"
<<
std
::
endl
;
moduleToIDMap
[
theOtherM
odule
]
<<
","
<<
(
*
iciter
)
->
getName
()
<<
")"
<<
std
::
endl
;
}
lock
.
unlock
();
}
...
...
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