Commit a5f89e76 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - movded WMData to modules. No direct need to be placed inside core anymore

parent 2e8a355d
......@@ -26,6 +26,7 @@
#include <vector>
#include "WModule.h"
#include "WDataModule.h"
#include "WModuleContainer.h"
#include "WModuleFactory.h"
......@@ -64,7 +65,7 @@ void WBatchLoader::threadMain()
);
// set the filename
boost::shared_static_cast< WMData >( mod )->setFilename( *iter );
boost::shared_static_cast< WDataModule >( mod )->setFilename( *iter );
m_targetContainer->add( mod );
// serialize loading of a couple of data sets
......
//---------------------------------------------------------------------------
//
// 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 "WDataModule.h"
WDataModule::WDataModule()
{
// initialize members
}
WDataModule::~WDataModule()
{
// cleanup
}
MODULE_TYPE WDataModule::getType() const
{
return MODULE_DATA;
}
//---------------------------------------------------------------------------
//
// 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 WDATAMODULE_H
#define WDATAMODULE_H
#include <boost/shared_ptr.hpp>
#include "WModule.h"
/**
* Base for all data loader modules. This currently is only a prototype to move WMData out of the core. Later, it will provide a whole interface
* to handle arbitrary data/multi-file data and other complex things.
*/
class WDataModule: public WModule
{
public:
/**
* Convenience typedef for a boost::shared_ptr< WDataModule >.
*/
typedef boost::shared_ptr< WDataModule > SPtr;
/**
* Convenience typedef for a boost::shared_ptr< const WDataModule >.
*/
typedef boost::shared_ptr< const WDataModule > ConstSPtr;
/**
* Default constructor.
*/
WDataModule();
/**
* Destructor.
*/
virtual ~WDataModule();
/**
* Gets the type of the module. This is useful for FAST differentiation between several modules like standard modules and data
* modules which play a special role in OpenWalnut/Kernel.
*
* \return the Type. If you do not overwrite this method, it will return MODULE_ARBITRARY.
*/
virtual MODULE_TYPE getType() const;
/**
* Getter for the dataset.
*
* \return the dataset encapsulated by this module.
*/
virtual boost::shared_ptr< WDataSet > getDataSet() = 0;
/**
* Sets the filename of the file to load. If this method is called multiple times it has no effect. It has to be called right after
* construction BEFORE running the data module.
*
* \note The reason for using this method to set the filename instead of a property is, that a property gets set AFTER ready(), but this (and
* only this module) needs it before ready got called.
*
* \param fname the name of the file
*/
virtual void setFilename( boost::filesystem::path fname ) = 0;
/**
* Gets the path of the file that has been loaded. It always is the value which has been set during the FIRST call of setFilename.
*
* \return the path of the file that has been loaded.
*/
virtual boost::filesystem::path getFilename() const = 0;
protected:
private:
};
#endif // WDATAMODULE_H
......@@ -44,7 +44,7 @@
#include "exceptions/WModuleAlreadyAssociated.h"
#include "exceptions/WModuleSignalSubscriptionFailed.h"
#include "exceptions/WModuleUninitialized.h"
#include "modules/data/WMData.h"
#include "WDataModule.h"
#include "WModuleContainer.h"
......@@ -253,7 +253,7 @@ WModuleContainer::DataModuleListType WModuleContainer::getDataModules()
// is this module a data module?
if( ( *iter )->getType() == MODULE_DATA )
{
boost::shared_ptr< WMData > dm = boost::shared_static_cast< WMData >( *iter );
boost::shared_ptr< WDataModule > dm = boost::shared_static_cast< WDataModule >( *iter );
// now check the contained dataset ( isTexture and whether it is ready )
if( dm->isReady()() )
......
......@@ -45,7 +45,7 @@
class WThreadedRunner;
class WBatchLoader;
class WModule;
class WMData;
class WDataModule;
#include "WExportKernel.h"
......@@ -243,9 +243,9 @@ public:
virtual boost::shared_ptr< WModule > factory() const;
/**
* Simple type for WMData pointer lists.
* Simple type for WDataModule pointer lists.
*/
typedef std::set< boost::shared_ptr< WMData > > DataModuleListType;
typedef std::set< boost::shared_ptr< WDataModule > > DataModuleListType;
/**
* Returns a vector of pointers to the loaded data modules in the container.
......
......@@ -33,7 +33,6 @@
#include "combiner/WApplyCombiner.h"
#include "exceptions/WPrototypeNotUnique.h"
#include "exceptions/WPrototypeUnknown.h"
#include "modules/data/WMData.h" // this is the ONLY module with a special meaning. Everyone knowing the factory also knows this
#include "WModule.h"
#include "WModuleCombiner.h"
#include "WModuleFactory.h"
......@@ -61,9 +60,6 @@ void WModuleFactory::load()
// operation must be exclusive
PrototypeSharedContainerType::WriteTicket m_prototypeAccess = m_prototypes.getWriteTicket();
// These modules need to be added by hand. They are special, obviously.
m_prototypeAccess->get().insert( boost::shared_ptr< WModule >( new WMData() ) );
// Load the dynamic modules here:
m_moduleLoader.load( m_prototypeAccess );
......
......@@ -33,7 +33,6 @@
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include "modules/data/WMData.h" // this is the ONLY module with a special meaning. Every one knowing the factory also knows this
#include "../common/WSharedAssociativeContainer.h"
#include "WModuleCombinerTypes.h"
#include "WModule.h"
......
......@@ -37,6 +37,7 @@
#include "../WModuleFactory.h"
#include "../WModuleConnector.h"
#include "../WModule.h"
#include "../WDataModule.h"
#include "../WModuleInputConnector.h"
#include "../WModuleOutputConnector.h"
#include "../exceptions/WModuleConnectorNotFound.h"
......@@ -128,7 +129,7 @@ bool WModuleProjectFileCombiner::parse( std::string line, unsigned int lineNumbe
}
else
{
boost::shared_static_cast< WMData >( module )->setFilename( parameter );
boost::shared_static_cast< WDataModule >( module )->setFilename( parameter );
m_modules.insert( ModuleID( boost::lexical_cast< unsigned int >( matches[1] ), module ) );
}
}
......@@ -368,7 +369,7 @@ void WModuleProjectFileCombiner::save( std::ostream& output ) // NOLINT
// handle data modules separately
if( ( *iter )->getType() == MODULE_DATA )
{
output << "DATA:" << i << ":" << boost::shared_static_cast< WMData >( ( *iter ) )->getFilename() << std::endl;
output << "DATA:" << i << ":" << boost::shared_static_cast< WDataModule >( ( *iter ) )->getFilename() << std::endl;
}
else
{
......
......@@ -67,7 +67,7 @@ public:
/**
* Apply the internal module structure to the target container. Be aware, that this operation might take some time, as modules can be
* connected only if they are "ready", which, at least with WMData modules, might take some time. It applies the loaded project file.
* connected only if they are "ready", which, at least with WDataModule modules, might take some time. It applies the loaded project file.
*
* \note the loader for project files is very tolerant. It does not abort. It tries to load as much as possible. The only exception that gets
* thrown whenever the file could not be opened.
......
......@@ -25,33 +25,36 @@
#include <string>
#include <vector>
#include "../../../common/WAssert.h"
#include "../../../common/WIOTools.h"
#include "../../../common/WPropertyHelper.h"
#include "../../../dataHandler/WDataSet.h"
#include "../../../dataHandler/WDataSetSingle.h"
#include "../../../dataHandler/WDataSetScalar.h"
#include "../../../dataHandler/WDataSetTimeSeries.h"
#include "../../../dataHandler/WDataSetVector.h"
#include "../../../dataHandler/WSubject.h"
#include "../../../dataHandler/WDataHandler.h"
#include "../../../dataHandler/WDataTexture3D.h"
#include "../../../dataHandler/WEEG2.h"
#include "../../../dataHandler/exceptions/WDHException.h"
#include "../../../dataHandler/io/WReaderBiosig.h"
#include "../../../dataHandler/io/WReaderEEGASCII.h"
#include "../../../dataHandler/io/WReaderLibeep.h"
#include "../../../dataHandler/io/WReaderNIfTI.h"
#include "../../../dataHandler/io/WPagerEEGLibeep.h"
#include "../../../dataHandler/io/WReaderELC.h"
#include "../../../dataHandler/io/WReaderFiberVTK.h"
#include "../../../graphicsEngine/WGEColormapping.h"
#include "../../../kernel/WModuleOutputData.h"
#include "core/common/WAssert.h"
#include "core/common/WIOTools.h"
#include "core/common/WPropertyHelper.h"
#include "core/dataHandler/WDataSet.h"
#include "core/dataHandler/WDataSetSingle.h"
#include "core/dataHandler/WDataSetScalar.h"
#include "core/dataHandler/WDataSetTimeSeries.h"
#include "core/dataHandler/WDataSetVector.h"
#include "core/dataHandler/WSubject.h"
#include "core/dataHandler/WDataHandler.h"
#include "core/dataHandler/WDataTexture3D.h"
#include "core/dataHandler/WEEG2.h"
#include "core/dataHandler/exceptions/WDHException.h"
#include "core/dataHandler/io/WReaderBiosig.h"
#include "core/dataHandler/io/WReaderEEGASCII.h"
#include "core/dataHandler/io/WReaderLibeep.h"
#include "core/dataHandler/io/WReaderNIfTI.h"
#include "core/dataHandler/io/WPagerEEGLibeep.h"
#include "core/dataHandler/io/WReaderELC.h"
#include "core/dataHandler/io/WReaderFiberVTK.h"
#include "core/graphicsEngine/WGEColormapping.h"
#include "core/kernel/WModuleOutputData.h"
#include "WMData.h"
#include "data.xpm"
// This line is needed by the module loader to actually find your module. You need to add this to your module too. Do NOT add a ";" here.
W_LOADABLE_MODULE( WMData )
WMData::WMData():
WModule(),
WDataModule(),
m_fileNameSet( false ),
m_isTexture(),
m_transformNoMatrix( 4, 4 ),
......@@ -105,11 +108,6 @@ boost::filesystem::path WMData::getFilename() const
return m_fileName;
}
MODULE_TYPE WMData::getType() const
{
return MODULE_DATA;
}
void WMData::connectors()
{
// initialize connectors
......@@ -121,7 +119,7 @@ void WMData::connectors()
addConnector( m_output );
// call WModules initialization
WModule::connectors();
WDataModule::connectors();
}
void WMData::properties()
......
......@@ -30,10 +30,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
// #include "../../WKernel.h"
#include "../../WModule.h"
#include "../../WExportKernel.h"
#include "core/kernel/WDataModule.h"
// forward declarations
class WDataSet;
......@@ -46,7 +43,7 @@ template< class T > class WModuleOutputData;
* inherited classes. This class builds a "source" in OpenWalnut's DataFlow Network.
* \ingroup modules
*/
class OWKERNEL_EXPORT WMData: public WModule
class WMData: public WDataModule
{
public:
......@@ -92,14 +89,6 @@ public:
*/
virtual const char** getXPMIcon() const;
/**
* Gets the type of the module. This is useful for FAST differentiation between several modules like standard modules and data
* modules which play a special role in OpenWalnut/Kernel.
*
* \return the Type. This will return MODULE_DATA.
*/
virtual MODULE_TYPE getType() const;
/**
* Sets the filename of the file to load. If this method is called multiple times it has no effect. It has to be called right after
* construction BEFORE running the data module.
......
......@@ -55,7 +55,7 @@
#include "core/dataHandler/WEEG2.h"
#include "core/graphicsEngine/WGEZoomTrackballManipulator.h"
#include "core/graphicsEngine/WROIBox.h"
#include "core/kernel/modules/data/WMData.h"
#include "core/kernel/WDataModule.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleCombiner.h"
......@@ -458,7 +458,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
// data modules contain an member denoting the real data type. Currently we only have one data module and a not very modulated data
// structures.
boost::shared_ptr< WMData > dataModule = boost::shared_static_cast< WMData >( module );
boost::shared_ptr< WDataModule > dataModule = boost::shared_static_cast< WDataModule >( module );
// grab data and identify type
if( dataModule->getDataSet()->isA< WDataSetSingle >() && dataModule->getDataSet()->isTexture() )
......
......@@ -46,7 +46,6 @@
#include "core/dataHandler/WDataHandler.h"
#include "core/dataHandler/WSubject.h"
#include "core/graphicsEngine/WGraphicsEngine.h"
#include "core/kernel/modules/data/WMData.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WModuleContainer.h"
#include "core/kernel/WProjectFile.h"
......@@ -252,11 +251,6 @@ void WQt4Gui::slotActivateDatasetOrModuleInTree( boost::shared_ptr< WModule > mo
void WQt4Gui::slotRemoveDatasetOrModuleInTree( boost::shared_ptr< WModule > module )
{
// create a new event for this and insert it into event queue
if( module->getName() == "Data Module" )
{
boost::shared_ptr< WMData > dataModule = boost::shared_dynamic_cast< WMData >( module );
WAssert( dataModule, "Internal failure." );
}
QCoreApplication::postEvent( m_mainWindow->getNetworkEditor(), new WModuleRemovedEvent( module ) );
QCoreApplication::postEvent( m_mainWindow->getControlPanel(), new WModuleRemovedEvent( module ) );
QCoreApplication::postEvent( m_mainWindow, new WModuleRemovedEvent( module ) );
......
......@@ -38,7 +38,7 @@
#include "core/common/WLogger.h"
#include "core/common/WPredicateHelper.h"
#include "core/dataHandler/WDataSet.h"
#include "core/kernel/modules/data/WMData.h"
#include "core/kernel/WDataModule.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleContainer.h"
......@@ -255,7 +255,7 @@ bool WQtControlPanel::event( QEvent* event )
// finally add the module
// TODO(schurade): is this differentiation between data and "normal" modules really needed?
if( boost::shared_dynamic_cast< WMData >( e1->getModule() ).get() )
if( boost::shared_dynamic_cast< WDataModule >( e1->getModule() ).get() )
{
addDataset( e1->getModule(), 0 );
}
......@@ -666,7 +666,7 @@ void WQtControlPanel::selectTreeItem()
createCompatibleButtons( module );
{
boost::shared_ptr< WMData > dataModule = boost::shared_dynamic_cast< WMData >( module );
boost::shared_ptr< WDataModule > dataModule = boost::shared_dynamic_cast< WDataModule >( module );
// if the selected module contains a texture, select the corresponding texture in the texture sorter.
if( dataModule )
......@@ -779,8 +779,8 @@ void WQtControlPanel::selectDataModule( boost::shared_ptr< WDataSet > dataSet )
{
if( dynamic_cast< WQtDatasetTreeItem* >( *it ) )
{
boost::shared_ptr< WMData > dataModule;
dataModule = boost::shared_dynamic_cast< WMData >( ( dynamic_cast< WQtDatasetTreeItem* >( *it ) )->getModule() );
boost::shared_ptr< WDataModule > dataModule;
dataModule = boost::shared_dynamic_cast< WDataModule >( ( dynamic_cast< WQtDatasetTreeItem* >( *it ) )->getModule() );
if( dataModule )
{
if( dataModule->getDataSet() == dataSet )
......
......@@ -35,7 +35,6 @@
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include "core/kernel/modules/data/WMData.h"
#include "../WQtCombinerToolbar.h"
#include "layout/WNetworkLayout.h"
#include "WQtNetworkItem.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment