Commit 75c83b81 authored by wiebel's avatar wiebel

[ADD #8 #45] Drafted framework

parent 4957d94d
ADD_SUBDIRECTORY( io )
FILE( GLOB DATAHANDLER_SRC "*.cpp" )
ADD_LIBRARY( dataHandler SHARED ${DATAHANDLER_SRC} )
# Unit tests
IF( CXXTEST_FOUND )
CXXTEST_ADD_TEST( unittest_WMetaInfo
WMetaInfo_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WMetaInfo_test.h )
TARGET_LINK_LIBRARIES( unittest_WMetaInfo dataHandler )
CXXTEST_ADD_TEST( unittest_WGrid
WGrid_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WGrid_test.h )
TARGET_LINK_LIBRARIES( unittest_WGrid dataHandler )
CXXTEST_ADD_TEST( unittest_WValueSet
WValueSet_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WValueSet_test.h )
TARGET_LINK_LIBRARIES( unittest_WValueSet dataHandler )
CXXTEST_ADD_TEST( unittest_WDataSet
WDataSet_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WDataSet_test.h )
TARGET_LINK_LIBRARIES( unittest_WDataSet dataHandler )
CXXTEST_ADD_TEST( unittest_WDataSetSingle
WDataSetSingle_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WDataSetSingle_test.h )
TARGET_LINK_LIBRARIES( unittest_WDataSetSingle dataHandler )
CXXTEST_ADD_TEST( unittest_WDataSetTimeDependent
WDataSetTimeDependent_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WDataSetTimeDependent_test.h )
TARGET_LINK_LIBRARIES( unittest_WDataSetTimeDependent dataHandler )
CXXTEST_ADD_TEST( unittest_WDataHandler
WDataHandler_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/test/WDataHandler_test.h )
TARGET_LINK_LIBRARIES( unittest_WDataHandler dataHandler )
ENDIF( CXXTEST_FOUND )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WDataHandler.h"
#include "WDataSet.h"
#include "exceptions/WNoSuchDataSetException.h"
boost::shared_ptr< WDataSet > WDataHandler::getDataSet( unsigned int dataSetId ) const
{
if( dataSetId >= m_dataSets.size() )
throw WNoSuchDataSetException( "Index to large." );
return m_dataSets[dataSetId];
}
void WDataHandler::addDataSet( boost::shared_ptr< WDataSet > newDataSet )
{
m_dataSets.push_back( newDataSet );
}
unsigned int WDataHandler::getNumberOfDataSets() const
{
return m_dataSets.size();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WDATAHANDLER_H
#define WDATAHANDLER_H
#include <boost/shared_ptr.hpp>
#include <vector>
class WDataSet;
/**
* Provides the environment for storing and accessing data sets.
* \ingroup dataHandler
*/
class WDataHandler
{
public:
boost::shared_ptr< WDataSet > getDataSet( unsigned int dataSetId ) const;
void addDataSet( boost::shared_ptr< WDataSet > newDataSet );
unsigned int getNumberOfDataSets() const;
protected:
private:
std::vector< boost::shared_ptr< WDataSet > > m_dataSets;
};
/**
\defgroup dataHandler Data Handler
\brief
This module implements the data storage facility of OpenWalnut.
*/
#endif // WDATAHANDLER_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WDataSet.h"
WDataSet::WDataSet( boost::shared_ptr<WMetaInfo> newMetaInfo ) :
m_metaInfo( newMetaInfo )
{
assert( newMetaInfo );
}
boost::shared_ptr<WMetaInfo> WDataSet::getMetaInfo() const
{
return m_metaInfo;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WDATASET_H
#define WDATASET_H
#include <boost/shared_ptr.hpp>
class WMetaInfo;
/**
* Base class for all data set types. This class has a number of
* subclasses specifying the different types of data sets.
* Two of dataset type reprent single and time-dependent
* datasets (compound of several time steps) respectively.
* This bas class contains the pointer to the meta information.
*
*/
class WDataSet
{
public:
explicit WDataSet( boost::shared_ptr< WMetaInfo > newMetaInfo );
boost::shared_ptr< WMetaInfo > getMetaInfo() const;
protected:
boost::shared_ptr< WMetaInfo > m_metaInfo;
private:
};
#endif // WDATASET_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WDataSetSingle.h"
#include "WValueSet.h"
#include "WGrid.h"
WDataSetSingle::WDataSetSingle( boost::shared_ptr<WValueSet> newValueSet,
boost::shared_ptr<WGrid> newGrid,
boost::shared_ptr< WMetaInfo > newMetaInfo )
:WDataSet( newMetaInfo )
{
assert( newValueSet );
assert( newGrid );
assert( newMetaInfo );
assert( newValueSet->getNumberOfValues() == newGrid->getNumberOfPositions() );
m_valueSet = newValueSet;
m_grid = newGrid;
}
WDataSetSingle::~WDataSetSingle()
{
// TODO(wiebel) Auto-generated destructor stub
}
boost::shared_ptr<WValueSet> WDataSetSingle::getValueSet() const
{
return m_valueSet;
}
boost::shared_ptr<WGrid> WDataSetSingle::getGrid() const
{
return m_grid;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WDATASETSINGLE_H
#define WDATASETSINGLE_H
#include <boost/shared_ptr.hpp>
#include "WDataSet.h"
class WValueSet;
class WGrid;
/**
* A data set consisting of a set of values based on a grid.
*/
class WDataSetSingle : WDataSet
{
public:
WDataSetSingle( boost::shared_ptr<WValueSet> newValueSet,
boost::shared_ptr<WGrid> newGrid,
boost::shared_ptr<WMetaInfo> newMetaInfo );
virtual ~WDataSetSingle();
boost::shared_ptr<WValueSet> getValueSet() const;
boost::shared_ptr<WGrid> getGrid() const;
private:
boost::shared_ptr< WGrid > m_grid;
boost::shared_ptr< WValueSet > m_valueSet;
};
#endif // WDATASETSINGLE_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WDataSetTimeDependent.h"
WDataSetTimeDependent::WDataSetTimeDependent()
{
// TODO(wiebel) Auto-generated constructor stub
}
WDataSetTimeDependent::~WDataSetTimeDependent()
{
// TODO(wiebel) Auto-generated destructor stub
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WDATASETTIMEDEPENDENT_H
#define WDATASETTIMEDEPENDENT_H
/*
*
*/
class WDataSetTimeDependent
{
public:
WDataSetTimeDependent();
virtual ~WDataSetTimeDependent();
};
#endif // WDATASETTIMEDEPENDENT_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WGrid.h"
WGrid::WGrid()
:m_numberOfPositions( 0 )
{
}
unsigned int WGrid::getNumberOfPositions() const
{
return m_numberOfPositions;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WGRID_H
#define WGRID_H
/**
* Base class for all different grid types. The first and most
* important will be some kind of regular grid.
*/
class WGrid
{
public:
WGrid();
unsigned int getNumberOfPositions() const;
protected:
private:
unsigned int m_numberOfPositions;
};
#endif // WGRID_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WMetaInfo.h"
std::string WMetaInfo::getName() const
{
return m_name;
}
void WMetaInfo::setName( std::string name )
{
m_name = name;
}
std::string WMetaInfo::getFileName() const
{
return m_fileName;
}
void WMetaInfo::setFileName( std::string fileName )
{
m_fileName = fileName;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WMETAINFO_H
#define WMETAINFO_H
#include <string>
/**
* Stores meta information for data sets loaded into OpenWalnut
*/
class WMetaInfo
{
public:
std::string getName() const;
void setName( std::string name );
std::string getFileName() const;
void setFileName( std::string fileName );
protected:
private:
std::string m_name;
std::string m_fileName;
};
#endif // WMETAINFO_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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/>.
//
//---------------------------------------------------------------------------