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 
176  static bool orderByNumberAfterColon(const QString& s1, const QString& s2);
177 
181  static bool hasGroup( ConfigurationParameters& params, QString group );
182 
188  static bool hasParameter( ConfigurationParameters& params, QString group, QString paramName );
189 
201  static void throwUserConfigError(QString paramName, QString paramValue, QString description);
202 
213  static void throwUserMissingResourceError(QString resourceName, QString description);
214 
223  static QStringList getDescribedParameterNames( QString type, QString prefix=QString() );
224 
233  static QStringList getDescribedSubgroupNames( QString type, QString prefix=QString() );
234 
248  static QString getParameterTypeName( QString type, QString paramName );
249 
254  static bool isRuntimeParameter( QString type, QString paramName );
255 
261  static bool parameterIsDouble( QString type, QString paramName );
262 
268  static QStringList getParameterEnumValues( QString type, QString paramName );
269 
270 private:
272  ConfigurationHelper() { /* nothing */ };
273 };
274 
275 } // end namespace farsa
276 
277 #endif
The class containing configuration parameters.
The class containing some helper function for configuration parameters.