1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Stephan Aiche $
25
// $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
26
// --------------------------------------------------------------------------
29
#ifndef OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSALPHABETPARSER_H
30
#define OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSALPHABETPARSER_H
37
#include <OpenMS/CONCEPT/Exception.h>
44
@brief An abstract templatized parser to load the data that is used to initialize @c Alphabet objects.
46
@c AlphabetParser reads the input source, which is given as a template parameter @c InputSource , by
47
@c load (const std::string& fname) function where @c fname is the source name.
48
Loaded data can be retrieved by calling @c getElements().
52
template <typename AlphabetElementType = double,
53
typename Container = std::map<std::string, AlphabetElementType>,
54
typename InputSource = std::istream>
55
class IMSAlphabetParser
59
Type of data to be loaded.
61
typedef Container ContainerType;
64
Loads the data from the InputSource with the name @c fname.
65
If there is an error occurred while reading data from InputSource,
66
@c IOException is thrown.
68
@param fname The name of the input source.
70
void load(const std::string& fname);
73
Gets the data that was loaded.
77
virtual ContainerType& getElements() = 0;
80
Parses the the given input source @c is .
82
@param is The InputSource
85
virtual void parse(InputSource& is) = 0;
90
virtual ~IMSAlphabetParser() {}
93
template <typename AlphabetElementType, typename Container, typename InputSource>
94
void IMSAlphabetParser<AlphabetElementType, Container, InputSource>::load(const std::string& fname)
96
std::ifstream ifs(fname.c_str());
99
throw Exception::IOException(__FILE__, __LINE__, __PRETTY_FUNCTION__,fname);
106
} // namespace OpenMS
108
#endif // OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_ALPHABETPARSER_H