configuration/include/configurationhelper.h

00001 /***************************************************************************
00002  *   Copyright (C) 2008-2011 by Tomassino Ferrauto, Gianluca Massera       *
00003  *   t_ferrauto@yahoo.it                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef CONFIGURATION_HELPER_H
00022 #define CONFIGURATION_HELPER_H
00023 
00024 #include "configurationparameters.h"
00025 #include <QVector>
00026 
00027 namespace farsa {
00028 
00034 class FARSA_CONF_API ConfigurationHelper {
00035 public:
00041     static int getInt( ConfigurationParameters& params, QString paramPath, int def = 0 );
00042 
00048     static unsigned int getUnsignedInt( ConfigurationParameters& params, QString paramPath, unsigned int def = 0 );
00049     
00055     static double getDouble( ConfigurationParameters& params, QString paramPath, double def = 0 );
00056 
00073     static bool getBool( ConfigurationParameters& params, QString paramPath, bool def = false );
00074 
00082     static QString getString( ConfigurationParameters& params, QString paramPath, QString def = QString() );
00083     
00089     static QStringList getStringList( ConfigurationParameters& params, QString paramPath, QString delimiter = QString(" ") );
00090 
00107     static QVector<double> getVector( ConfigurationParameters& params, QString paramPath );
00108     
00112     static bool hasGroup( ConfigurationParameters& params, QString group );
00113 
00119     static bool hasParameter( ConfigurationParameters& params, QString group, QString paramName );
00120 
00132     static void throwUserConfigError(QString paramName, QString paramValue, QString description);
00133 
00144     static void throwUserMissingResourceError(QString resourceName, QString description);
00145 
00146 private:
00148     ConfigurationHelper() { /* nothing */ };
00149 };
00150 
00151 } // end namespace farsa
00152 
00153 #endif