• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/filedataexception.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Nicolas PASCAL   *
00003  *   nicolas.pascal@icare.univ-lille1.fr   *
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 FILEDATAEXCEPTION_H
00022 #define FILEDATAEXCEPTION_H
00023 
00024 #include "date.h"
00025 #include "file_tools.h"
00026 #include "tools.h"
00027 #include "file_exceptions.h"
00028 #include "g_exception.h"
00029 
00033 class UnimplementedProduct : public exception {
00034 public:
00041     UnimplementedProduct(const string &src_file, const int src_line, const string & src_method): src_file(src_file),src_line(src_line),src_method(src_method){};
00045     ~UnimplementedProduct() throw() {};
00050     virtual const char* what() const throw() {
00051         string m=src_file+"("+MyTools::to_string(src_line)+") : Unimplemented Product in "+src_method;
00052         return m.c_str();
00053     };
00054 private:
00056     string src_file;
00058     int src_line;
00060     string src_method;
00061 };
00062 
00066 class UnimplementedMethod : public exception {
00067 public:
00074     UnimplementedMethod(const string &src_file, const int src_line, const string & src_method): src_file(src_file),src_line(src_line),src_method(src_method){};
00078     ~UnimplementedMethod() throw() {};
00083     virtual const char* what() const throw() {
00084         string m=src_file+"("+MyTools::to_string(src_line)+") : Unimplemented method "+src_method;
00085         return m.c_str();
00086     };
00087 private:
00089     string src_file;
00091     int src_line;
00093     string src_method;
00094 };
00098 class bad_hdf_type : public exception {
00099 public:
00106     bad_hdf_type(const string &src_file, const int src_line, const string & type): src_file(src_file),src_line(src_line),type(type){};
00107     ~bad_hdf_type() throw() {};
00112     virtual const char* what() const throw() {
00113         string m=src_file+"("+MyTools::to_string(src_line)+") : Bad HDF type used : "+type;
00114         return m.c_str();
00115     };
00116 private:
00117     string src_file;
00118     int src_line;
00119     string type;
00120 };
00124 class invalid_filename : public exception {
00125 public:
00133     invalid_filename(const string &src_file, const int src_line, const string & filename,const string & sensor):src_file(src_file),src_line(src_line),filename(filename),sensor(sensor){};
00137     ~invalid_filename() throw() {}
00138     ;
00143     virtual const char* what() const throw() {
00144         string m=src_file+"("+MyTools::to_string(src_line)+") : Invalid Filename : the file "+filename+" doesn't match a valid "+sensor+" product naming convention";
00145         return m.c_str();
00146     };
00147 private:
00148     string src_file;
00149     int src_line;
00150     string filename;
00151     string sensor;
00152 };
00156 class bad_record_index : public exception {
00157 public:
00158     bad_record_index(const string &filename, const int record_idx, const int nb_record_max, const string &source_file, const int source_line) : filename(filename),record_idx(record_idx),nb_record_max(nb_record_max),source_file(source_file),source_line(source_line){};
00159     ~bad_record_index() throw() {};
00164     virtual const char* what() const throw() {
00165 //         using namespace MyTools; // for to_string
00166         string m=source_file+"("+MyTools::to_string(source_line)+") bad_record_index : the record index "+MyTools::to_string(record_idx)+" can't be accessed in the file "+filename+". It must be in the range [0,"+MyTools::to_string(nb_record_max)+"]";
00167         return m.c_str();
00168     };
00169 private:
00170   string filename;
00171   int record_idx;
00172   int nb_record_max;
00173   string source_file;
00174   int source_line;
00175 };
00179 class bad_level : public exception {
00180 public:
00181     bad_level(const int &level) : level(level){};
00182     ~bad_level() throw() {};
00187     virtual const char* what() const throw() {
00188         string m="bad_level : can't find the level "+level;
00189         return m.c_str();
00190     };
00191 private:
00192     int level;
00193 };
00194 
00198 class bad_product_id : public exception {
00199 public:
00200     bad_product_id(const int &product_id) : product_id(product_id){};
00201     ~bad_product_id() throw() {};
00206     virtual const char* what() const throw() {
00207         string m="bad_product_id : unknown product_id "+product_id;
00208         return m.c_str();
00209     };
00210 private:
00211     int product_id;
00212 };
00213 
00217 class bad_parametre : public exception {
00218 public:
00219     bad_parametre(const string &parametre) : parametre(parametre){};
00220     ~bad_parametre() throw() {};
00225     virtual const char* what() const throw() {
00226         string m="bad_parametre : can't find the parametre "+parametre;
00227         return m.c_str();
00228     };
00229 private:
00230     string parametre;
00231 };
00235 class bad_parametre_idx : public exception {
00236 public:
00237     bad_parametre_idx(const int &parametre_index) : parametre_index(parametre_index){};
00238     ~bad_parametre_idx() throw() {};
00243     virtual const char* what() const throw() {
00244         string m="bad_parametre_idx : can't find a parametre at index "+parametre_index;
00245         return m.c_str();
00246     };
00247 private:
00248     int parametre_index;
00249 };
00253 class bad_rank : public exception {
00254 public:
00261     bad_rank(const int & given_rank, const int & authorized_rank) : given_rank(given_rank), authorized_rank(authorized_rank){};
00262     ~bad_rank() throw() {};
00267     virtual const char* what() const throw() {
00268         string m="Bad Rank : "+MyTools::to_string(given_rank)+" : must be "+MyTools::to_string(authorized_rank)+"]";
00269         return m.c_str();
00270     };
00271 private:
00272     int given_rank;
00273     int authorized_rank;
00274 };
00275 
00279 class bad_index : public exception {
00280 public:
00286     bad_index(const long long & _index, const long long & _index_max) {
00287         index = _index;
00288         index_max = _index_max;
00289     };
00290     ~bad_index() throw() {};
00295     virtual const char* what() const throw() {
00296         string m="Bad index : "+MyTools::to_string(index)+". It must be in the range [0,"+MyTools::to_string(index_max)+"]";
00297         return m.c_str();
00298     };
00299 private:
00300     long long index;
00301     long long index_max;
00302 };
00303 
00308 class bad_type : public exception {
00309 public:
00310     bad_type(const string & t1, const string & t2, const string & _sds) {
00311         invocatedType = t1;
00312         realType = t2;
00313         sds = _sds;
00314     };
00315     ~bad_type() throw() {};
00320     virtual const char* what() const throw() {
00321         string m="bad_type : The data' type in the sds "+sds+" is "+realType+" and you are using "+invocatedType;
00322         return m.c_str();
00323     };
00324 private:
00325     string invocatedType;
00326     string realType;
00327     string sds;
00328 };
00332 class longitude_out_of_file : public exception {
00333 public:
00334     longitude_out_of_file(const string & _filename, const double &_lon):filename(filename),lon(lon) {};
00335     ~longitude_out_of_file() throw() {};
00340     virtual const char* what() const throw() {
00341         string m="longitude_out_of_file : the longitude "+MyTools::to_string(lon)+" can't be found in the file "+filename;
00342         return m.c_str();
00343     };
00344 private:
00345     string filename;
00346     double lon;
00347 };
00351 class latitude_out_of_file : public exception {
00352 public:
00353     latitude_out_of_file(const string & filename, const double &lat):filename(filename),lat(lat) {};
00354     ~latitude_out_of_file() throw() {};
00359     virtual const char* what() const throw() {
00360         string m="latitude_out_of_file : the latitude "+MyTools::to_string(lat)+" can't be found in the file "+filename;
00361         return m.c_str();
00362     };
00363 private:
00364     string filename;
00365     double lat;
00366 };
00367 
00371 class bad_read_file : public exception {
00372 public:
00373     bad_read_file(const string &filename) : filename(filename){};
00374     ~bad_read_file() throw() {};
00379     virtual const char* what() const throw() {
00380         string m="bad_read_file : can't read the data of the file "+filename;
00381         return m.c_str();
00382     };
00383 private:
00384     string filename;
00385 };
00389 class bad_netcdf_file : public exception {
00390 public:
00391     bad_netcdf_file(const string & filename):filename(filename){};
00392     ~bad_netcdf_file() throw() {} ;
00397     virtual const char* what() const throw() {
00398         string m="bad_netcdf_file : can't open "+filename+" as a netcdf one";
00399         return m.c_str();
00400     };
00401 private:
00402     string filename;
00403 };
00404 
00405 #endif

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1