WSL/SLF GitLab Repository

Commit 2fcab6ac authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Last general warnings from Weffc++ addressed and we now move a step further:...

Last general warnings from Weffc++ addressed and we now move a step further: almost all the "deep" warnings as well as Weffc++ are now enabled in debug compilation.
parent d3aa8889
......@@ -40,11 +40,11 @@ ELSE(MSVC)
#we consider that all other compilers support "-" options and silently ignore what they don't know
SET(WARNINGS "-Wall")
SET(PROFILING "-pg -fprofile-arcs")
SET(DEEP_WARNINGS "-Wunused-value -Wshadow -Wpointer-arith -Wconversion -Wpadded -Winline -Wdisabled-optimization") #-Wfloat-equal
SET(DEEP_WARNINGS "-Wunused-value -Wshadow -Wpointer-arith -Wconversion -Winline -Wdisabled-optimization") #-Wfloat-equal -Wpadded
IF(POPC)
SET(EXTRA_WARNINGS "-Wextra -Wno-ignored-qualifiers")
ELSE(POPC)
SET(EXTRA_WARNINGS "-Wextra -pedantic") #-Weffc++
SET(EXTRA_WARNINGS "-Wextra -pedantic -Weffc++ ${DEEP_WARNINGS}") #-Weffc++
ENDIF(POPC)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(EXTRA_WARNINGS "${EXTRA_WARNINGS} -ansi")
......
......@@ -65,6 +65,8 @@ class Config {
*/
Config();
virtual ~Config() {};
/**
* @brief Main constructor. The file is parsed and a key/value map object is internally created
* @param[in] filename_in string representing the absolute filename of the key/value file
......
......@@ -350,7 +350,7 @@ void Gradient::setNrOfLevels(const unsigned char& i_nr_unique_levels) {
ss << reserved_idx << " colors!";
throw InvalidArgumentException(ss.str(), AT);
}
nr_unique_cols = i_nr_unique_levels - reserved_idx;
nr_unique_cols = static_cast<unsigned char>(i_nr_unique_levels - reserved_idx);
}
//val between min_val and max_val
......@@ -405,19 +405,27 @@ void Gradient::getColor(const double& val, unsigned char& index) const
}
if(val==IOUtils::nodata) {
index=0;
index = 0;
return;
}
if(val==legend::bg_color) {
index=1;
index = 1;
return;
}
if(val==legend::text_color) {
index=2;
index = 2;
return;
}
if(delta==0) { //otherwise constant data throughout the grid makes a division by zero...
index=nr_unique_cols/2 + reserved_idx;
#ifndef NOSAFECHECKS
if((nr_unique_cols/2 + reserved_idx) > std::numeric_limits<unsigned char>::max()) {
std::stringstream ss;
ss << "[E] Number of unique colors in gradient and/or reserved index too large to fit in index: ";
ss << (nr_unique_cols/2 + reserved_idx) << " when it should be at most " << std::numeric_limits<unsigned char>::max();
throw IndexOutOfBoundsException(ss.str(), AT);
}
#endif
index = static_cast<unsigned char>(nr_unique_cols/2 + reserved_idx);
return;
}
......@@ -428,7 +436,7 @@ void Gradient::getColor(const double& val, unsigned char& index) const
//watch out!! the palette contains some reserved values at the begining
if(val<min) index=reserved_idx-2;
else if(val>max) index=reserved_idx-1;
else index = static_cast<unsigned char>( (val-min)/delta*(double)nr_unique_cols ) + reserved_idx;
else index = static_cast<unsigned char>( static_cast<unsigned char>((val-min)/delta*(double)nr_unique_cols) + reserved_idx);
}
void Gradient::getPalette(std::vector<unsigned char> &palette, size_t &nr_colors) const
......@@ -553,7 +561,9 @@ gr_blue_pink::gr_blue_pink(const double& /*i_min*/, const double& /*i_max*/, con
X.push_back(1.); v_h.push_back(281.); v_s.push_back(.7); v_v.push_back(.95); //bright violet
}
gr_freeze::gr_freeze(const double& i_min, const double& i_max, const bool& /*i_autoscale*/) {
gr_freeze::gr_freeze(const double& i_min, const double& i_max, const bool& /*i_autoscale*/)
: Gradient_model(), X(), v_r(), v_g(), v_b()
{
//we want the yellow/green step to always be at zero celsius
double begin=0., middle=0.5, end=1.;
if(i_min<0. && i_max>0.) {
......
......@@ -50,7 +50,7 @@ const std::string ARPSIO::default_ext=".asc"; //filename extension
ARPSIO::ARPSIO(const std::string& configfile)
: cfg(configfile),
fin(NULL), fout(), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
fin(NULL), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), ext(default_ext), dimx(0), dimy(0), dimz(0), cellsize(0.),
xcoord(IOUtils::nodata), ycoord(IOUtils::nodata), zcoord(), is_true_arps(true)
{
......@@ -60,7 +60,7 @@ ARPSIO::ARPSIO(const std::string& configfile)
ARPSIO::ARPSIO(const Config& cfgreader)
: cfg(cfgreader),
fin(NULL), fout(), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
fin(NULL), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), ext(default_ext), dimx(0), dimy(0), dimz(0), cellsize(0.),
xcoord(IOUtils::nodata), ycoord(IOUtils::nodata), zcoord(), is_true_arps(true)
{
......@@ -68,6 +68,28 @@ ARPSIO::ARPSIO(const Config& cfgreader)
setOptions();
}
ARPSIO& ARPSIO::operator=(const ARPSIO& source) {
if(this != &source) {
fin = NULL;
filename = source.filename;
coordin = source.coordin;
coordinparam = source.coordinparam;
coordout = source.coordout;
coordoutparam = source.coordoutparam;
grid2dpath_in = source. grid2dpath_in;
ext = source.ext;
dimx = source.dimx;
dimy = source.dimy;
dimz = source.dimz;
cellsize = source.cellsize;
xcoord = source.xcoord;
ycoord = source.ycoord;
zcoord = source.zcoord;
is_true_arps = source.is_true_arps;
}
return *this;
}
void ARPSIO::setOptions()
{
string tmp="";
......@@ -424,9 +446,6 @@ void ARPSIO::cleanup() throw()
/*if (fin.is_open()) {//close fin if open
fin.close();
}*/
if (fout.is_open()) {//close fout if open
fout.close();
}
zcoord.clear();
}
......
......@@ -50,6 +50,8 @@ class ARPSIO : public IOInterface {
ARPSIO(const Config& cfgreader);
~ARPSIO() throw();
ARPSIO& operator=(const ARPSIO&); ///<Assignement operator, required because of pointer member
virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
......@@ -83,7 +85,6 @@ class ARPSIO : public IOInterface {
const Config& cfg;
//std::ifstream fin; //Input file streams
FILE *fin;
std::ofstream fout;//Output file streams
std::string filename;
static const double plugin_nodata; //plugin specific nodata value, e.g. -999
static const std::string default_ext;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment