Commit 36fa5850 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - added example toolbox to module repository

parent a43bb653
You are free to copy, modify and re-distribute these files as you like.
* This is an example of how to create your own module toolbox
for OpenWalnut (http://www.openwalnut.org).
* You should have a look at our WIKI for further details under
http://www.openwalnut.org/projects/openwalnut/wiki/Module_ExternalDevelopment
* It basically creates one library with two modules in it.
You can use this example as your basic development setup
and extend it as you need.
* Please contact us if you have trouble or if you have added
platform support to the OpenWalnut.cmake script. We
appreciate your help!
Happy coding!
- The OpenWalnut Team -
# OW Version File. This file specifies the version. The line VERSION=X.Y.Z is
# used and parsed. This file has to be here everytime. The VERSION needs to be
# set properly or CMake will fail.
#
# SYNTAX: The version string always is 1.2.3 with an optional postfix of "+hg1234".
# This is useful if building is done by scripts. If you want to automatically
# add the correct HG revision, use only +hgX without number.
#
# IMPORTANT: If you modify the file, cmake re-creates the version header. But
# it is not able to set all library version. Please re-run cmake if
# you change something here.
#
# NOTE: do not add a space after #. The current CMake script will fail.
# Examples:
#VERSION=1.2.0
#VERSION=1.2.0+hgX -> replaces the X with the current revision number
#VERSUIB=1.2.0+hg1234 -> here, revision number was set by the build scripts for example.
VERSION=0.1.0+hgX
This diff is collapsed.
<doxygenlayout version="1.0">
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="mainpage" visible="yes" title=""/>
<tab type="pages" visible="yes" title=""/>
<tab type="modules" visible="yes" title="Groups"/>
<tab type="namespaces" visible="yes" title="">
<tab type="namespaces" visible="yes" title=""/>
<tab type="namespacemembers" visible="yes" title=""/>
</tab>
<tab type="classes" visible="yes" title="">
<tab type="classes" visible="yes" title=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title=""/>
<tab type="classmembers" visible="yes" title=""/>
</tab>
<tab type="files" visible="yes" title="">
<tab type="files" visible="yes" title=""/>
<tab type="globals" visible="yes" title=""/>
</tab>
<tab type="dirs" visible="yes" title=""/>
<tab type="examples" visible="yes" title=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<allmemberslink visible="yes"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<dirs visible="yes" title=""/>
<nestedgroups visible="yes" title=""/>
<files visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>
// C headers
// ...
// C++ headers
#include <string>
// External lib headers
#include <boost/shared_ptr.hpp>
// OW core headers
#include <core/common/WAssert.h>
#include <core/common/WPropertyHelper.h>
// own, local headers
#include "WMAnotherModule.h"
#include "WMAnotherModule.xpm"
WMAnotherModule::WMAnotherModule():
WModule()
{
}
WMAnotherModule::~WMAnotherModule()
{
// cleanup
removeConnectors();
}
boost::shared_ptr< WModule > WMAnotherModule::factory() const
{
// See "src/modules/template/" for an extensively documented example.
return boost::shared_ptr< WModule >( new WMAnotherModule() );
}
const char** WMAnotherModule::getXPMIcon() const
{
return WMAnotherModule_xpm;
}
const std::string WMAnotherModule::getName() const
{
return "My Other Module";
}
const std::string WMAnotherModule::getDescription() const
{
// Specify your module description here. Be detailed. This text is read by the user.
return "TODO: write a module description here";
}
void WMAnotherModule::connectors()
{
// create the inputs
// ...
// and the outputs
// ...
// call WModule's initialization
WModule::connectors();
}
void WMAnotherModule::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
// Add your properties here
// Call parent method
WModule::properties();
}
void WMAnotherModule::moduleMain()
{
m_moduleState.add( m_propCondition );
ready();
// You do not see the debug messages on console output? Set log-level in Settings menu to debug.
debugLog() << "Hey! Here I am (debug).";
infoLog() << "Hey! Here I am (info).";
warnLog() << "Hey! Here I am (warning).";
errorLog() << "Hey! Here I am (error).";
// lets go
while( !m_shutdownFlag() )
{
m_moduleState.wait();
if( m_shutdownFlag() )
{
break;
}
// do your stuff here
}
}
#ifndef WMANOTHERMODULE_H
#define WMANOTHERMODULE_H
#include <string>
#include <core/kernel/WModule.h>
#include <core/kernel/WModuleOutputData.h>
#include <core/kernel/WModuleInputData.h>
#include <core/common/WProperties.h>
/**
* TODO write some documentation here
*
* \ingroup modules
*/
class WMAnotherModule: public WModule
{
public:
/**
* Constructor.
*/
WMAnotherModule();
/**
* Destructor
*/
virtual ~WMAnotherModule();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
* \return The icon.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
private:
/**
* Condition used throughout the module to notify the thread if some changes happened (like properties have changed and similar).
*/
boost::shared_ptr< WCondition > m_propCondition;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Connectors
// * provide all the input and output connections here
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ...
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Properties
// * provide all your module properties here
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ...
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Other members
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ...
};
#endif // WMANOTHERMODULE_H
/* XPM */
static const char * WMAnotherModule_xpm[] = {
"16 16 2 1",
" c None",
". c #000000",
" ",
" ",
" .......... ",
" .......... ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" "};
#ifndef ANICETEST_TEST_H
#define ANICETEST_TEST_H
#include <boost/filesystem.hpp>
#include <cxxtest/TestSuite.h>
#include <core/common/WLogger.h>
/**
* This is an example test. It has no further meaning.
*/
class ANiceTest : public CxxTest::TestSuite
{
public:
/**
* Setup logger and other stuff for each test.
*/
void setUp()
{
// needed if some of your classes use the WLogger
WLogger::startup();
}
/**
* Test whether modules can be initialized without problems.
*/
void testModuleInitialization( void )
{
// you can use test data you have put into the fixtures directory by using the path:
// W_FIXTURE_PATH + "/testfile"
TS_ASSERT( boost::filesystem::exists( W_FIXTURE_PATH + "/testfile" ) );
}
};
#endif // ANICETEST_TEST_H
This is an example for fixtures. If you use uni tests, it might come in handy
to also have test data avilable. Place the test data into the fixtures
directory and our build scripts handle them automatically. They get copied to
the binary dir of the unit test.
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# General CMake Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT( MyOpenWalnutToolbox )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Include the OpenWalnut build system.
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# where to find our utils and cmake modules?
SET( OW_TOOLS_DIR ${PROJECT_SOURCE_DIR}/../tools )
# append search path for FindModules:
LIST( APPEND CMAKE_MODULE_PATH ${OW_TOOLS_DIR}/cmake )
# These scripts contains all the needed tools to setup the build:
# * Compiler Setup
# * Common OpenWalnut Options
# * Third-party Dependencies Setup
# * Unit Testing Setup if found
# * Doxygen Setup if found
INCLUDE( OpenWalnut )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Setup your additional dependencies and tools
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# IMPORTANT: NEVER add any commands bore the line INCLUDE( OpenWalnut ). This might cause problems!
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Setup all modules
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Here, you can add your own targets, call ADD_MODULE provided by OpenWalnut or a combination of it. When using ADD_MODULE or SETUP_MODULE, the
# OpenWalnut CMake scripts manages proper resource handling, test compilation and similar. You should use it whenever possible. More details on
# how to develop external modules, have a look at http://www.openwalnut.org. You can have a look at OpenWalnut.cmake if you want to modify
# the default behaviour.
# Please see the documentation of SETUP_MODULE as it shows how to add custom dependencies (third-party libs)
SETUP_MODULE(
${PROJECT_NAME} # use project name as module(-toolbox) name
"." # where to find the sources
"" # no additonal dependencies
"" # no sources to exclude
)
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Additional Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Add the files under ../resources/MyGlobalResources as additional, global resources
# The first parameter is the directory name, the second parameter is the component name. This is used during installation to identify to which
# install component this belongs. The name is arbitrary but must be unique.
#
# NOTE: The first parameter of SETUP_MODULE is not allowed as component name here because SETUP_MODULE already registers this component. Simply
# append some string.
SETUP_GLOBAL_RESOURCES( "MyGlobalResources" ${PROJECT_NAME}_Global )
// C headers
// ...
// C++ headers
#include <string>