WDataHandler.cpp 1.78 KB
Newer Older
wiebel's avatar
wiebel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------

24 25 26
#include <string>
#include <vector>

wiebel's avatar
wiebel committed
27 28 29
#include "WDataHandler.h"
#include "WDataSet.h"
#include "exceptions/WNoSuchDataSetException.h"
30 31 32 33 34 35
#include "WLoaderManager.h"

WDataHandler::WDataHandler()
{
}

wiebel's avatar
wiebel committed
36

math's avatar
math committed
37
boost::shared_ptr< const WDataSet > WDataHandler::getDataSet( const unsigned int dataSetId ) const
wiebel's avatar
wiebel committed
38 39
{
    if( dataSetId >= m_dataSets.size() )
math's avatar
math committed
40 41
        throw WNoSuchDataSetException( "Index too large." );
    return m_dataSets.at(dataSetId);
wiebel's avatar
wiebel committed
42 43
}

44

wiebel's avatar
wiebel committed
45 46 47 48 49
void WDataHandler::addDataSet( boost::shared_ptr< WDataSet > newDataSet )
{
    m_dataSets.push_back( newDataSet );
}

50

wiebel's avatar
wiebel committed
51 52 53 54 55 56
unsigned int WDataHandler::getNumberOfDataSets() const
{
    return m_dataSets.size();
}


57 58 59 60 61 62 63 64
void WDataHandler::loadDataSets( std::vector< std::string > fileNames )
{
    WLoaderManager lm;
    for ( size_t i = 0 ; i < fileNames.size() ; ++i)
    {
        lm.load( fileNames[i], ( boost::shared_ptr<WDataHandler> )this );
    }
}