configurationhelper.h
1 /***************************************************************************
2  * Copyright (C) 2008-2011 by Tomassino Ferrauto, Gianluca Massera *
3  * t_ferrauto@yahoo.it *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 #ifndef CONFIGURATION_HELPER_H
22 #define CONFIGURATION_HELPER_H
23 
24 #include "configurationparameters.h"
25 #include <QVector>
26 
27 namespace farsa {
28 
34 class FARSA_CONF_API ConfigurationHelper {
35 public:
41  static int getInt( ConfigurationParameters& params, QString paramPath, int def = 0 );
42 
48  static unsigned int getUnsignedInt( ConfigurationParameters& params, QString paramPath, unsigned int def = 0 );
49 
55  static double getDouble( ConfigurationParameters& params, QString paramPath, double def = 0 );
56 
73  static bool getBool( ConfigurationParameters& params, QString paramPath, bool def = false );
74 
82  static QString getString( ConfigurationParameters& params, QString paramPath, QString def = QString() );
83 
89  static QStringList getStringList( ConfigurationParameters& params, QString paramPath, QString delimiter = QString(" ") );
90 
108  static QVector<double> getVector( ConfigurationParameters& params, QString paramPath, QString def = QString() );
109 
127  static QVector<int> getIntegerVector(ConfigurationParameters& params, QString paramPath, QString def = QString());
128 
147  static QVector<unsigned int> getUnsignedIntegerVector(ConfigurationParameters& params, QString paramPath, QString def = QString());
148 
161  static QVector<bool> getBoolVector(ConfigurationParameters& params, QString paramPath, QString def = QString());
162 
166  static bool hasGroup( ConfigurationParameters& params, QString group );
167 
173  static bool hasParameter( ConfigurationParameters& params, QString group, QString paramName );
174 
186  static void throwUserConfigError(QString paramName, QString paramValue, QString description);
187 
198  static void throwUserMissingResourceError(QString resourceName, QString description);
199 
208  static QStringList getDescribedParameterNames( QString type, QString prefix=QString() );
209 
218  static QStringList getDescribedSubgroupNames( QString type, QString prefix=QString() );
219 
233  static QString getParameterTypeName( QString type, QString paramName );
234 
239  static bool isRuntimeParameter( QString type, QString paramName );
240 
246  static bool parameterIsDouble( QString type, QString paramName );
247 
253  static QStringList getParameterEnumValues( QString type, QString paramName );
254 
255 private:
257  ConfigurationHelper() { /* nothing */ };
258 };
259 
260 } // end namespace farsa
261 
262 #endif