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
1ea8e12f
Commit
1ea8e12f
authored
Dec 07, 2009
by
Sebastian Eichelbaum
Browse files
[CHANGE] - basic skeleton added for applying modules on others
parent
b1f1c802
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
144 additions
and
0 deletions
+144
-0
src/kernel/WModuleContainer.cpp
src/kernel/WModuleContainer.cpp
+28
-0
src/kernel/WModuleContainer.h
src/kernel/WModuleContainer.h
+20
-0
src/kernel/exceptions/WModuleAlreadyAssociated.cpp
src/kernel/exceptions/WModuleAlreadyAssociated.cpp
+39
-0
src/kernel/exceptions/WModuleAlreadyAssociated.h
src/kernel/exceptions/WModuleAlreadyAssociated.h
+57
-0
No files found.
src/kernel/WModuleContainer.cpp
View file @
1ea8e12f
...
...
@@ -29,9 +29,11 @@
#include "WModule.h"
#include "exceptions/WModuleUninitialized.h"
#include "exceptions/WModuleAlreadyAssociated.h"
#include "exceptions/WModuleSignalSubscriptionFailed.h"
#include "../common/WLogger.h"
#include "WKernel.h"
#include "WModuleFactory.h"
#include "WModuleContainer.h"
...
...
@@ -198,3 +200,29 @@ void WModuleContainer::addDefaultNotifier( MODULE_SIGNAL signal, t_ModuleErrorSi
}
}
boost
::
shared_ptr
<
WModule
>
WModuleContainer
::
applyModule
(
boost
::
shared_ptr
<
WModule
>
applyOn
,
std
::
string
what
)
{
return
applyModule
(
applyOn
,
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
what
)
);
}
boost
::
shared_ptr
<
WModule
>
WModuleContainer
::
applyModule
(
boost
::
shared_ptr
<
WModule
>
applyOn
,
boost
::
shared_ptr
<
WModule
>
prototype
)
{
// is this module already associated with another container?
if
(
applyOn
->
isAssociated
()()
&&
(
applyOn
->
getAssociatedContainer
()
!=
shared_from_this
()
)
)
{
throw
WModuleAlreadyAssociated
(
"The specified module
\"
"
+
applyOn
->
getName
()
+
"
\"
is associated with another container."
);
}
// create a new initialized instance of the module
boost
::
shared_ptr
<
WModule
>
m
=
WModuleFactory
::
getModuleFactory
()
->
create
(
prototype
);
// add it
add
(
m
,
true
);
// TODO(ebaum): do actual connection stuff
WLogger
::
getLogger
()
->
addLogMessage
(
"Combining modules
\"
"
+
applyOn
->
getName
()
+
"
\"
and
\"
"
+
m
->
getName
()
+
"
\"
not yet implemented."
,
"ModuleContainer ("
+
m_name
+
")"
,
LL_WARNING
);
return
m
;
}
src/kernel/WModuleContainer.h
View file @
1ea8e12f
...
...
@@ -108,6 +108,26 @@ public:
*/
virtual
void
addDefaultNotifier
(
MODULE_SIGNAL
signal
,
t_ModuleGenericSignalHandlerType
notifier
);
/**
* Function combines to modules.
*
* \param applyOn the module which already has to be in the container and to apply the other one on.
* \param what the prototype name of the module to apply on the other one specified.
*
* \return the newly created module connected with the one specified in applyOn.
*/
virtual
boost
::
shared_ptr
<
WModule
>
applyModule
(
boost
::
shared_ptr
<
WModule
>
applyOn
,
std
::
string
what
);
/**
* Function combines to modules.
*
* \param applyOn the module which already has to be in the container and to apply the other one on.
* \param prototype the prototype of the module to apply on the other one specified.
*
* \return the newly created module connected with the one specified in applyOn.
*/
virtual
boost
::
shared_ptr
<
WModule
>
applyModule
(
boost
::
shared_ptr
<
WModule
>
applyOn
,
boost
::
shared_ptr
<
WModule
>
prototype
);
protected:
/**
...
...
src/kernel/exceptions/WModuleAlreadyAssociated.cpp
0 → 100644
View file @
1ea8e12f
//---------------------------------------------------------------------------
//
// 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 <string>
#include "WModuleAlreadyAssociated.h"
WModuleAlreadyAssociated
::
WModuleAlreadyAssociated
(
const
std
::
string
&
msg
)
:
WModuleException
(
msg
)
{
// initialize members
}
WModuleAlreadyAssociated
::~
WModuleAlreadyAssociated
()
throw
()
{
// cleanup
}
src/kernel/exceptions/WModuleAlreadyAssociated.h
0 → 100644
View file @
1ea8e12f
//---------------------------------------------------------------------------
//
// 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 WMODULEALREADYASSOCIATED_H
#define WMODULEALREADYASSOCIATED_H
#include <string>
#include "WModuleException.h"
/**
* General purpose exception and therefore base class for all kernel related exceptions.
* \ingroup kernel
*/
class
WModuleAlreadyAssociated
:
public
WModuleException
{
public:
/**
* Default constructor.
* \param msg the exception message.
*/
explicit
WModuleAlreadyAssociated
(
const
std
::
string
&
msg
=
"Module already associated with another container."
);
/**
* Destructor.
*/
virtual
~
WModuleAlreadyAssociated
()
throw
();
protected:
private:
};
#endif // WMODULEALREADYASSOCIATED_H
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