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
1488673b
Commit
1488673b
authored
Nov 13, 2009
by
Sebastian Eichelbaum
Browse files
[ADD] - 1-1 connector compatibility test
parent
08cc85d3
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
87 additions
and
20 deletions
+87
-20
src/graphicsEngine/WGEViewer.cpp
src/graphicsEngine/WGEViewer.cpp
+1
-1
src/kernel/WKernel.cpp
src/kernel/WKernel.cpp
+2
-2
src/kernel/WModule.cpp
src/kernel/WModule.cpp
+6
-0
src/kernel/WModule.h
src/kernel/WModule.h
+7
-0
src/kernel/WModuleConnector.h
src/kernel/WModuleConnector.h
+2
-2
src/kernel/WModuleFactory.cpp
src/kernel/WModuleFactory.cpp
+53
-4
src/kernel/WModuleFactory.h
src/kernel/WModuleFactory.h
+8
-3
src/kernel/WModuleInputConnector.h
src/kernel/WModuleInputConnector.h
+2
-2
src/kernel/WModuleInputData.hpp
src/kernel/WModuleInputData.hpp
+2
-2
src/kernel/WModuleOutputConnector.h
src/kernel/WModuleOutputConnector.h
+2
-2
src/kernel/WModuleOutputData.hpp
src/kernel/WModuleOutputData.hpp
+2
-2
No files found.
src/graphicsEngine/WGEViewer.cpp
View file @
1488673b
...
...
@@ -95,7 +95,7 @@ WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, i
WGEViewer
::~
WGEViewer
()
{
// cleanup
wait
(
true
);
close
(
);
}
osg
::
ref_ptr
<
osgViewer
::
CompositeViewer
>
WGEViewer
::
getViewer
()
...
...
src/kernel/WKernel.cpp
View file @
1488673b
...
...
@@ -141,8 +141,8 @@ int WKernel::run()
m_gui
->
getLoadButtonSignal
()
->
connect
(
boost
::
bind
(
&
WKernel
::
doLoadDataSets
,
this
,
_1
)
);
// default modules
m_moduleContainer
->
add
(
m_moduleFactory
->
create
(
m_moduleFactory
->
getPrototypeByName
(
"Navigation Slice Module"
)
)
);
m_moduleContainer
->
add
(
m_moduleFactory
->
create
(
m_moduleFactory
->
getPrototypeByName
(
"Coordinate System Module"
)
)
);
//
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Navigation Slice Module" ) ) );
//
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Coordinate System Module" ) ) );
m_gui
->
wait
(
false
);
m_FinishRequested
=
true
;
...
...
src/kernel/WModule.cpp
View file @
1488673b
...
...
@@ -32,6 +32,7 @@
#include "WModuleOutputConnector.h"
#include "WModuleConnectorSignals.h"
#include "WModuleContainer.h"
#include "WModuleFactory.h"
#include "exceptions/WModuleSignalUnknown.h"
#include "exceptions/WModuleSignalSubscriptionFailed.h"
#include "exceptions/WModuleConnectorInitFailed.h"
...
...
@@ -190,6 +191,11 @@ const t_GenericSignalHandlerType WModule::getSignalHandler( MODULE_CONNECTOR_SIG
}
}
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>
WModule
::
getCompatibles
()
{
return
WModuleFactory
::
getModuleFactory
()
->
getCompatiblePrototypes
(
shared_from_this
()
);
}
bool
WModule
::
isInitialized
()
const
{
return
m_initialized
;
...
...
src/kernel/WModule.h
View file @
1488673b
...
...
@@ -160,6 +160,13 @@ public:
virtual
boost
::
signals2
::
connection
subscribeSignal
(
MODULE_SIGNAL
signal
,
t_ModuleGenericSignalHandlerType
notifier
);
virtual
boost
::
signals2
::
connection
subscribeSignal
(
MODULE_SIGNAL
signal
,
t_ModuleErrorSignalHandlerType
notifier
);
/**
* Returns a set of prototypes compatible with this module's connectors.
*
* \return set of prototypes.
*/
virtual
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>
getCompatibles
();
protected:
/**
...
...
src/kernel/WModuleConnector.h
View file @
1488673b
...
...
@@ -144,8 +144,6 @@ public:
*/
void
setName
(
std
::
string
name
);
protected:
/**
* Checks whether the specified connector is connectable to this one.
*
...
...
@@ -155,6 +153,8 @@ protected:
*/
virtual
bool
connectable
(
boost
::
shared_ptr
<
WModuleConnector
>
con
)
=
0
;
protected:
/**
* List of connectors connected to this connector.
*/
...
...
src/kernel/WModuleFactory.cpp
View file @
1488673b
...
...
@@ -158,11 +158,60 @@ const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByName( std::stri
return
ret
;
}
const
boost
::
shared_ptr
<
WModule
>
WModuleFactory
::
getPrototypeByInstance
(
boost
::
shared_ptr
<
WModule
>
/*
instance
*/
)
const
boost
::
shared_ptr
<
WModule
>
WModuleFactory
::
getPrototypeByInstance
(
boost
::
shared_ptr
<
WModule
>
instance
)
{
// TODO(ebaum): implement
WLogger
::
getLogger
()
->
addLogMessage
(
"Searching prototype by instance, NOT YET IMPLEMENTED"
,
"ModuleFactory"
,
LL_WARNING
);
return
getPrototypeByName
(
instance
->
getName
()
);
}
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>
WModuleFactory
::
getCompatiblePrototypes
(
boost
::
shared_ptr
<
WModule
>
module
)
{
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>
compatibles
;
// for this a read lock is sufficient
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_prototypesLock
);
// get offered outputs
std
::
set
<
boost
::
shared_ptr
<
WModuleOutputConnector
>
>
cons
=
module
->
getOutputConnectors
();
if
(
cons
.
size
()
==
0
)
{
// in this case return the empty list
return
compatibles
;
}
// TODO(ebaum): see ticket #178 for this
if
(
cons
.
size
()
>
1
)
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Can not find compatibles for modules with more than 1 output connector. Using "
+
(
*
cons
.
begin
()
)
->
getCanonicalName
()
+
" for compatibility check."
,
"ModuleFactory"
,
LL_WARNING
);
}
// go through every prototype
for
(
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>::
iterator
listIter
=
m_prototypes
.
begin
();
listIter
!=
m_prototypes
.
end
();
++
listIter
)
{
// get connectors of this prototype
std
::
set
<
boost
::
shared_ptr
<
WModuleInputConnector
>
>
pcons
=
(
*
listIter
)
->
getInputConnectors
();
// ensure we have 1 connector
if
(
pcons
.
size
()
==
0
)
{
continue
;
}
if
(
pcons
.
size
()
>
1
)
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Can not find compatibles for modules with more than 1 input connector. Using "
+
(
*
pcons
.
begin
()
)
->
getCanonicalName
()
+
" for compatibility check."
,
"ModuleFactory"
,
LL_WARNING
);
}
// check whether the outputs are compatible with the inputs of the prototypes
if
(
(
*
cons
.
begin
()
)
->
connectable
(
*
pcons
.
begin
()
)
)
{
// it is compatible -> add to list
compatibles
.
insert
(
*
listIter
);
}
}
slock
.
unlock
();
return
boost
::
shared_ptr
<
WModule
>
()
;
return
compatibles
;
}
src/kernel/WModuleFactory.h
View file @
1488673b
...
...
@@ -94,14 +94,19 @@ public:
/**
* Checks whether the first instance can be casted to the second one.
*
* \param module1 the module to check.
* \param module2 the module to check against.
* \param module the module to check.
*
* \return
* \return
true if the dynamic_cast is successful
*/
template
<
typename
T
>
static
bool
isA
(
boost
::
shared_ptr
<
WModule
>
module
);
/**
* Returns a set of modules compatible with the specified one.
*
* \return set of compatible prototypes.
*/
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>
getCompatiblePrototypes
(
boost
::
shared_ptr
<
WModule
>
module
);
protected:
/**
...
...
src/kernel/WModuleInputConnector.h
View file @
1488673b
...
...
@@ -52,8 +52,6 @@ public:
*/
virtual
~
WModuleInputConnector
();
protected:
/**
* Checks whether the specified connector is an output connector.
*
...
...
@@ -63,6 +61,8 @@ protected:
*/
virtual
bool
connectable
(
boost
::
shared_ptr
<
WModuleConnector
>
con
);
protected:
/**
* Connect additional signals.
*
...
...
src/kernel/WModuleInputData.hpp
View file @
1488673b
...
...
@@ -99,8 +99,6 @@ public:
return
dat
;
};
protected:
/**
* Checks whether the specified connector is an input connector and compatible with T.
*
...
...
@@ -120,6 +118,8 @@ protected:
return
false
;
};
protected:
private:
};
...
...
src/kernel/WModuleOutputConnector.h
View file @
1488673b
...
...
@@ -69,8 +69,6 @@ public:
*/
boost
::
signals2
::
connection
subscribeSignal
(
MODULE_CONNECTOR_SIGNAL
signal
,
t_GenericSignalHandlerType
notifier
);
protected:
/**
* Checks whether the specified connector is an input connector.
*
...
...
@@ -80,6 +78,8 @@ protected:
*/
virtual
bool
connectable
(
boost
::
shared_ptr
<
WModuleConnector
>
con
);
protected:
// If you want to add additional signals an output connector should subscribe FROM an input connector, overwrite
// connectSignals
// virtual void connectSignals( boost::shared_ptr<WModuleConnector> con );
...
...
src/kernel/WModuleOutputData.hpp
View file @
1488673b
...
...
@@ -87,8 +87,6 @@ public:
return
m_data
;
};
protected:
/**
* Checks whether the specified connector is an input connector and compatible with T.
*
...
...
@@ -109,6 +107,8 @@ protected:
return
false
;
};
protected:
private:
/**
...
...
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