WDataHandler.cpp 1.88 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
#include "WDataHandler.h"
28
#include "WSubject.h"
wiebel's avatar
wiebel committed
29
#include "exceptions/WNoSuchDataSetException.h"
30
#include "WLoaderManager.h"
31
#include "../kernel/WKernel.h"
32 33 34 35 36

WDataHandler::WDataHandler()
{
}

wiebel's avatar
wiebel committed
37

38
boost::shared_ptr< const WSubject > WDataHandler::getSubject( const unsigned int subjectId ) const
wiebel's avatar
wiebel committed
39
{
40
    if( subjectId >= m_subjects.size() )
math's avatar
math committed
41
        throw WNoSuchDataSetException( "Index too large." );
42
    return m_subjects.at( subjectId );
wiebel's avatar
wiebel committed
43 44
}

45

46
void WDataHandler::addSubject( boost::shared_ptr< WSubject > newSubject )
wiebel's avatar
wiebel committed
47
{
48
    m_subjects.push_back( newSubject );
wiebel's avatar
wiebel committed
49 50
}

51

52
unsigned int WDataHandler::getNumberOfSubjects() const
wiebel's avatar
wiebel committed
53
{
54
    return m_subjects.size();
wiebel's avatar
wiebel committed
55 56 57
}


58 59 60 61 62
void WDataHandler::loadDataSets( std::vector< std::string > fileNames )
{
    WLoaderManager lm;
    for ( size_t i = 0 ; i < fileNames.size() ; ++i)
    {
63
        // TODO( wiebel ): need to associate the dataset to its subject
64
        lm.load( fileNames[i], WKernel::getRunningKernel()->getDataHandler() );
65 66
    }
}