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 
107  static QVector<double> getVector( ConfigurationParameters& params, QString paramPath );
108 
112  static bool hasGroup( ConfigurationParameters& params, QString group );
113 
119  static bool hasParameter( ConfigurationParameters& params, QString group, QString paramName );
120 
132  static void throwUserConfigError(QString paramName, QString paramValue, QString description);
133 
144  static void throwUserMissingResourceError(QString resourceName, QString description);
145 
154  static QStringList getDescribedParameterNames( QString type, QString prefix=QString() );
155 
164  static QStringList getDescribedSubgroupNames( QString type, QString prefix=QString() );
165 
179  static QString getParameterTypeName( QString type, QString paramName );
180 
185  static bool isRuntimeParameter( QString type, QString paramName );
186 
192  static bool parameterIsDouble( QString type, QString paramName );
193 
199  static QStringList getParameterEnumValues( QString type, QString paramName );
200 
201 private:
203  ConfigurationHelper() { /* nothing */ };
204 };
205 
206 } // end namespace farsa
207 
208 #endif