WSL/SLF GitLab Repository

Commit 0394dcf3 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The POPC version has been heavily transformed. Since we would need IOManager...

The POPC version has been heavily transformed. Since we would need IOManager has a popc object and this is quite hard (we need a backreference in Meteo2DInterpolator), all parclasses have been removed. Instead, the user will have the responsability to packaged IOManager in his own parclass if needed. This makes the code simpler and skips difficult issues...

A new fill method has been added to the Array2D and Array3D templates that does the reverse of subset (ie: reassemble arrays).

Better error messages have been put in SNIO.

A new Date setter that takes a Date object has been created.

This version does NOT correctly compile with the autotools (it leads to a segfault when running code using MeteoIO), but the cmake compiled library works fine.
parent bf53437e
......@@ -30,8 +30,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
LIST(APPEND CFLAGS " -DDEBUG_ARITHM -D_USE_MATH_DEFINES") #USE_MATH_DEFINES needed for Win32
ENDIF(DEBUG_ARITHM)
set(OPTIM "-g -O3 -DNDEBUG")
set(ARCH_OPTIM "-march=pentium4 -mtune=native")
set(ARCH_SAFE "-march=pentium4")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.2 OR GCC_VERSION VERSION_EQUAL 4.2)
set(ARCH_OPTIM "-march=native -mtune=native")
endif()
set(ARCH_SAFE "")
set(DEBUG "-g3 -O0 -D__DEBUG")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
......
......@@ -118,7 +118,7 @@ METEOIO_OBJ = $(SRCDIR)/IOManager.o \
$(SRCDIR)/meteolaws/Suntrajectory.o \
$(SRCDIR)/meteolaws/Sun.o
METEOIO_OBJ_POPC = $(SRCDIR)/IOHandler.stub.o \
METEOIO_OBJ_POPC =$(SRCDIR)/IOManager.stub.o \
$(SRCDIR)/marshal_meteoio_par.o \
$(SRCDIR)/IOManager_par.o \
$(SRCDIR)/Matrix_par.o \
......
......@@ -53,7 +53,7 @@ template <class T> class Array2DProxy {
/**
* @class Array2D
* @brief The template class Array2D is a 2D Array (Matrix) able to hold any type of object as datatype.
* @brief The template class Array2D is a 2D Array (Matrix) able to hold any type of object as datatype.
* It relies on the Array2DProxy class to provide the [][] operator (slower than the (i,j) call).
*
* @ingroup data_str
......@@ -104,6 +104,19 @@ template<class T> class Array2D {
void subset(const Array2D<T>& i_array2D, const unsigned int& i_nx, const unsigned int& i_ny,
const unsigned int& i_ncols, const unsigned int& i_nrows);
/**
* @brief A method that can be used to insert a subplane into an existing Array2D object
* that is passed as i_array2D argument. This is exactly the opposite of the subset method
* an can be used to rebuild an array from subsets.
* @param i_array2D array containing to subset values
* @param i_nx lower left corner cell X index
* @param i_ny lower left corner cell Y index
* @param i_ncols number of columns of the new array
* @param i_nrows number of rows of the new array
*/
void fill(const Array2D<T>& i_array2D, const unsigned int& i_nx, const unsigned int& i_ny,
const unsigned int& i_ncols, const unsigned int& i_nrows);
void resize(const unsigned int& nx, const unsigned int& ny);
void resize(const unsigned int& nx, const unsigned int& ny, const T& init);
void size(unsigned int& nx, unsigned int& ny) const;
......@@ -127,8 +140,8 @@ template<class T> class Array2D {
*/
T getMean(const IOUtils::nodata_handling flag_nodata=IOUtils::PARSE_NODATA) const;
/**
* @brief returns the number of points contained in the grid.
* If flag_nodata==IOUtils::RAW_NODATA, then the number of points is the size of the grid.
* @brief returns the number of points contained in the grid.
* If flag_nodata==IOUtils::RAW_NODATA, then the number of points is the size of the grid.
* If flag_nodata==IOUtils::PARSE_NODATA, then it is the number of non-nodata values in the grid
* @param flag_nodata specify how to process nodata values (see NODATA_HANLDING)
* @return count
......@@ -240,6 +253,24 @@ template<class T> void Array2D<T>::subset(const Array2D<T>& i_array2D, const uns
}
}
template<class T> void Array2D<T>::fill(const Array2D<T>& i_array2D, const unsigned int& i_nx, const unsigned int& i_ny,
const unsigned int& i_ncols, const unsigned int& i_nrows)
{
if (((i_nx+i_ncols) > nx) || ((i_ny+i_nrows) > ny))
throw IndexOutOfBoundsException("Trying to insert an array whose size is too big!", AT);
if ((i_ncols == 0) || (i_nrows == 0)) //the plane to copy has to make sense
throw IndexOutOfBoundsException("Copying a null sized array!", AT);
for(unsigned int jj=i_ny; jj<(i_ny+i_nrows); jj++) {
for(unsigned int ii=i_nx; ii<(i_nx+i_ncols); ii++) {
const unsigned int ix = ii-i_nx;
const unsigned int iy = jj-i_ny;
operator()(ii,jj) = i_array2D(ix, iy);
}
}
}
template<class T> Array2D<T>::Array2D(const unsigned int& anx, const unsigned int& any, const T& init) {
nx = ny = 0;
resize(anx,any,init);
......@@ -335,7 +366,7 @@ template<class T> T Array2D<T>::getMean(const IOUtils::nodata_handling flag_noda
T mean = 0;
const unsigned int nxy = nx*ny;
if(flag_nodata==IOUtils::RAW_NODATA) {
for (unsigned int jj=0; jj<nxy; jj++) {
const T val = operator()(jj);
......@@ -414,7 +445,8 @@ template<class T> Array2D<T>& Array2D<T>::operator=(const Array2D<T>& source) {
}
template<class T> Array2D<T>& Array2D<T>::operator=(const T& value) {
std::fill(vecData.begin(), vecData.end(), value);
//std::fill(vecData.begin(), vecData.end(), value);
for(unsigned int i=0; i<vecData.size(); i++) vecData[i] = value;
return *this;
}
......
......@@ -72,12 +72,12 @@ template <class T> class Array3DProxy2 {
Array3D<T>& array3D;
const unsigned int anx;
const unsigned int any;
};
};
/**
* @class Array3D
* @brief The template class Array3D is a 3D Array (Tensor) able to hold any type of object as datatype.
* @brief The template class Array3D is a 3D Array (Tensor) able to hold any type of object as datatype.
* It relies on the Array3DProxy2 class to provide the [][][] operator (slower than the (i,j,k) call).
* @ingroup data_str
* @date 2009-07-19
......@@ -136,6 +136,22 @@ template<class T> class Array3D {
const unsigned int& i_nx, const unsigned int& i_ny, const unsigned int& i_nz,
const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepth);
/**
* @brief A method that can be used to insert a subplane into an existing Array2D object
* that is passed as i_array2D argument. This is exactly the opposite of the subset method
* an can be used to rebuild an array from subsets.
* @param i_array3D array containing to extract the values from
* @param i_nx lower left corner cell X index
* @param i_ny lower left corner cell Y index
* @param i_nz lower left corner cell Z index
* @param i_ncols number of columns of the new array
* @param i_nrows number of rows of the new array
* @param i_ndepth number of depths of the new array
*/
void fill(const Array3D<T>& i_array3D,
const unsigned int& i_nx, const unsigned int& i_ny, const unsigned int& i_nz,
const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepth);
void resize(const unsigned int& anx, const unsigned int& any, const unsigned int& anz);
void resize(const unsigned int& anx, const unsigned int& any, const unsigned int& anz, const T& init);
void size(unsigned int& anx, unsigned int& any, unsigned int& anz) const;
......@@ -160,8 +176,8 @@ template<class T> class Array3D {
*/
T getMean(const IOUtils::nodata_handling flag_nodata=IOUtils::PARSE_NODATA) const;
/**
* @brief returns the number of points contained in the grid.
* If flag_nodata==IOUtils::RAW_NODATA, then the number of points is the size of the grid.
* @brief returns the number of points contained in the grid.
* If flag_nodata==IOUtils::RAW_NODATA, then the number of points is the size of the grid.
* If flag_nodata==IOUtils::PARSE_NODATA, then it is the number of non-nodata values in the grid
* @param flag_nodata specify how to process nodata values (see NODATA_HANLDING)
* @return count
......@@ -176,7 +192,7 @@ template<class T> class Array3D {
void abs(const IOUtils::nodata_handling flag_nodata=IOUtils::PARSE_NODATA);
template<class P> friend std::ostream& operator<<(std::ostream& os, const Array3D<P>& array);
T& operator ()(const unsigned int& i);
const T operator ()(const unsigned int& i) const;
T& operator ()(const unsigned int& x, const unsigned int& y, const unsigned int& z);
......@@ -185,7 +201,7 @@ template<class T> class Array3D {
Array3D<T>& operator =(const Array3D<T>&);
Array3D<T>& operator =(const T& value);
Array3D<T>& operator+=(const T& rhs);
const Array3D<T> operator+(const T& rhs);
Array3D<T>& operator+=(const Array3D<T>& rhs);
......@@ -243,7 +259,7 @@ template<class T> const T Array3D<T>::operator()(const unsigned int& x, const un
}
template<class T> Array3DProxy<T> Array3D<T>::operator[](const unsigned int& i) {
return Array3DProxy<T>(*this, i);
return Array3DProxy<T>(*this, i);
}
......@@ -262,17 +278,17 @@ template<class T> void Array3D<T>::subset(const Array3D<T>& i_array3D,
const unsigned int& i_nx, const unsigned int& i_ny, const unsigned int& i_nz,
const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepth)
{
if (((i_nx+i_ncols) > i_array3D.nx) || ((i_ny+i_nrows) > i_array3D.ny) || ((i_nz+i_ndepth) > i_array3D.nz))
throw IndexOutOfBoundsException("", AT);
throw IndexOutOfBoundsException("Trying to cut an array to a size bigger than its original size!", AT);
if ((i_ncols == 0) || (i_nrows == 0) || (i_ndepth == 0)) //the space has to make sense
throw IndexOutOfBoundsException("", AT);
throw IndexOutOfBoundsException("Copying an array into a null sized array!", AT);
resize(i_ncols, i_nrows, i_ndepth); //create new Array3D object
//Copy by value subspace
for (unsigned int ii=0; ii<nz; ii++) {
for (unsigned int ii=0; ii<nz; ii++) {
for (unsigned int jj=0; jj<ny; jj++) {
for (unsigned int kk=0; kk<nx; kk++) {
//Running through the vector in order of memory alignment
......@@ -282,6 +298,31 @@ template<class T> void Array3D<T>::subset(const Array3D<T>& i_array3D,
}
}
template<class T> void Array3D<T>::fill(const Array3D<T>& i_array3D,
const unsigned int& i_nx, const unsigned int& i_ny, const unsigned int& i_nz,
const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepth)
{
if (((i_nx+i_ncols) > i_array3D.nx) || ((i_ny+i_nrows) > i_array3D.ny) || ((i_nz+i_ndepth) > i_array3D.nz))
throw IndexOutOfBoundsException("Trying to insert an array whose size is too big!", AT);
if ((i_ncols == 0) || (i_nrows == 0) || (i_ndepth == 0)) //the space has to make sense
throw IndexOutOfBoundsException("Copying a null sized array!", AT);
//Copy by value subspace
for (unsigned int ii=i_nz; ii<(i_nz+i_ndepth); ii++) {
for (unsigned int jj=i_ny; jj<(i_ny+i_nrows); jj++) {
for (unsigned int kk=i_nx; kk<(i_nx+i_ncols); kk++) {
const unsigned int ix = kk-i_nx;
const unsigned int iy = jj-i_ny;
const unsigned int iz = ii-i_nz;
operator()(kk,jj,ii) = i_array3D(ix, iy, iz);
}
}
}
}
template<class T> Array3D<T>::Array3D(const unsigned int& anx, const unsigned int& any, const unsigned int& anz) {
resize(anx, any, anz);
}
......@@ -334,7 +375,7 @@ template<class T> T Array3D<T>::getMin(const IOUtils::nodata_handling flag_nodat
T min = std::numeric_limits<T>::max();
const unsigned int nxyz = ny*nx*nz;
if(flag_nodata==IOUtils::RAW_NODATA) {
for (unsigned int jj=0; jj<nxyz; jj++) {
const T val = operator()(jj);
......@@ -357,7 +398,7 @@ template<class T> T Array3D<T>::getMax(const IOUtils::nodata_handling flag_nodat
T max = -std::numeric_limits<T>::max();
const unsigned int nxyz = ny*nx*nz;
if(flag_nodata==IOUtils::RAW_NODATA) {
for (unsigned int jj=0; jj<nxyz; jj++) {
const T val = operator()(jj);
......@@ -380,7 +421,7 @@ template<class T> T Array3D<T>::getMean(const IOUtils::nodata_handling flag_noda
T mean = 0;
const unsigned int nxyz = nx*ny*nz;
if(flag_nodata==IOUtils::RAW_NODATA) {
for (unsigned int jj=0; jj<nxyz; jj++) {
const T val = operator()(jj);
......
......@@ -47,8 +47,8 @@ namespace mio {
* (10% by default)
* - BUFF_BEFORE: alternate way of buffer centering: When rebuffering, the new date will be located BUFF_BEFORE days from the
* begining of the buffer (therefore, it takes a value in days); [General] section, optional. Only one of
* two centering option can be used.
*
* two centering option can be used.
*
* @author Thomas Egger
* @date 2009-07-25
*/
......@@ -88,7 +88,7 @@ class BufferedIOHandler : public IOInterface {
} buffer_policy;
/**
* @brief Read the metadata for a given date.
* @brief Read the metadata for a given date.
* @param date date for which to read the metadata
* @param vecStation vector of metadata
*/
......@@ -120,15 +120,15 @@ class BufferedIOHandler : public IOInterface {
friend std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data);
friend class IOManager;
//friend class IOManager;
private:
//private:
//private methods
const std::vector<METEO_TIMESERIE>& get_complete_buffer(Date& start, Date& end);
void push_meteo_data(const Date& date_start, const Date& date_end,
const std::vector< METEO_TIMESERIE >& vecMeteo);
private:
void setDfltBufferProperties();
void bufferData(const Date& date_start, const Date& date_end, std::vector< METEO_TIMESERIE >& vecvecMeteo);
......
......@@ -34,12 +34,12 @@ Config::Config(const std::string& i_filename)
addFile(i_filename);
}
ConfigProxy Config::get(const std::string& key, const Options& opt) const
ConfigProxy Config::get(const std::string& key, const Options& opt) const
{
return ConfigProxy(*this, key, Config::defaultSection, opt);
}
ConfigProxy Config::get(const std::string& key, const std::string& section, const Options& opt) const
ConfigProxy Config::get(const std::string& key, const std::string& section, const Options& opt) const
{
return ConfigProxy(*this, key, section, opt);
}
......@@ -100,16 +100,16 @@ void Config::parseFile(const std::string& filename)
std::ifstream fin; //Input file streams
unsigned int linenr = 0;
std::string line="", section=defaultSection;
if (!IOUtils::validFileName(filename)) {
throw InvalidFileNameException(filename,AT);
}
//Check whether file exists
if (!IOUtils::fileExists(filename)) {
throw FileNotFoundException(filename, AT);
}
//Open file
fin.open (filename.c_str(), ifstream::in);
if (fin.fail()) {
......@@ -117,7 +117,7 @@ void Config::parseFile(const std::string& filename)
}
char eoln = IOUtils::getEoln(fin); //get the end of line character for the file
try {
do {
getline(fin, line, eoln); //read complete line
......@@ -143,7 +143,7 @@ void Config::parseLine(const unsigned int& linenr, std::string& line, std::strin
stringstream tmp; //stringstream to convert the unsigned int linenr into a string
if (line[0] == '['){
size_t endpos = line.find_last_of(']');
const size_t endpos = line.find_last_of(']');
if ((endpos == string::npos) || (endpos < 2) || (endpos != (line.length()-1))){
tmp << linenr;
throw IOException("Section header corrupt in line " + tmp.str(), AT);
......@@ -157,7 +157,7 @@ void Config::parseLine(const unsigned int& linenr, std::string& line, std::strin
//At this point line can only be a key value pair
if (!IOUtils::readKeyValuePair(line, "=", properties, section+"::", true)){
tmp << linenr;
throw InvalidFormatException("Error reading key value pair in " + sourcename + " line:" + tmp.str(), AT);
throw InvalidFormatException("Error reading key value pair in " + sourcename + " line:" + tmp.str(), AT);
}
}
......@@ -167,8 +167,8 @@ std::string Config::getSourceName()
return sourcename;
}
unsigned int Config::findKeys(std::vector<std::string>& vecResult, std::string keystart,
std::string section) const
unsigned int Config::findKeys(std::vector<std::string>& vecResult, std::string keystart,
std::string section) const
{
vecResult.clear();
......@@ -177,19 +177,16 @@ unsigned int Config::findKeys(std::vector<std::string>& vecResult, std::string k
IOUtils::toUpper(section);
IOUtils::toUpper(keystart);
string tmp_keystart = section + "::" + keystart;
const string tmp_keystart = section + "::" + keystart;
//Loop through keys, look for substring match - push it into vecResult
map<string,string>::const_iterator it;
for (it=properties.begin(); it != properties.end(); it++){
string tmp = (*it).first;
tmp = tmp.substr(0, tmp_keystart.length());
const string tmp = (it->first).substr(0, tmp_keystart.length());
int matchcount = tmp_keystart.compare(tmp);
if (matchcount == 0){ //perfect match
string tmp2 = it->first;
tmp2 = tmp2.substr(section.length() + 2);
const string tmp2 = (it->first).substr(section.length() + 2);
vecResult.push_back(tmp2);
}
}
......@@ -211,10 +208,10 @@ std::string Config::extract_section(std::string& key)
void Config::write(const std::string& filename)
{
std::ofstream fout;
fout.open(filename.c_str());
if (fout.fail())
if (fout.fail())
throw FileAccessException(filename, AT);
try {
......@@ -223,7 +220,7 @@ void Config::write(const std::string& filename)
unsigned int sectioncount = 0;
for (it=properties.begin(); it != properties.end(); it++){
string tmp = it->first;
string section = extract_section(tmp);
const string section = extract_section(tmp);
if (current_section != section){
current_section = section;
......
......@@ -104,7 +104,7 @@ class Config {
void deleteKey(std::string key, std::string section=Config::defaultSection);
/**
* @brief Add a specific key/value pair to the internal key/value map object.
* @brief Add a specific key/value pair to the internal key/value map object.
* key and section are case insensitive
* @param[in] key string representing the key to be added
* @param[in] section std::string representing a section name; the key has to be part of this section
......@@ -168,7 +168,7 @@ class Config {
* @param[in] opt indicating whether an exception should be raised, when key is not present
*/
template <typename T> void getValue(const std::string& key, const std::string& section,
std::vector<T>& vecT, const Options& opt=Config::dothrow) const
std::vector<T>& vecT, const Options& opt=Config::dothrow) const
{
try {
vecT.clear();
......@@ -281,15 +281,15 @@ class ConfigProxy {
const std::string& section;
const Config::Options& opt;
ConfigProxy(const Config& i_cfg, const std::string& i_key,
const std::string& i_section, const Config::Options& i_opt)
ConfigProxy(const Config& i_cfg, const std::string& i_key,
const std::string& i_section, const Config::Options& i_opt)
: proxycfg(i_cfg), key(i_key),section(i_section), opt(i_opt) { }
template<typename T> operator T()
{
{
T tmp;
proxycfg.getValue(key, section, tmp, opt);
return tmp;
return tmp;
}
};
......
......@@ -89,13 +89,7 @@ Date::Date(const Date& in_date) : paroc_base()
Date::Date(const Date& in_date)
#endif
{
if(in_date.isUndef()) {
dst = false;
setDate(0., 0., false);
undef = true;
} else {
setDate(in_date.getJulianDate(), in_date.getTimeZone(), in_date.getDST());
}
setDate(in_date);
}
/**
......@@ -152,6 +146,21 @@ void Date::setTimeZone(const double& in_timezone, const bool& in_dst) {
dst = in_dst;
}
/**
* @brief Copy setter.
* @param in_date Date object to copy
*/
void Date::setDate(const Date& in_date)
{
if(in_date.isUndef()) {
dst = false;
setDate(0., 0., false);
undef = true;
} else {
setDate(in_date.getJulianDate(), in_date.getTimeZone(), in_date.getDST());
}
}
/**
* @brief Set date by elements.
* All values are checked for plausibility.
......@@ -323,7 +332,7 @@ double Date::getModifiedJulianDate(const bool& gmt) const {
/**
* @brief Return truncated julian date (TJD).
* The truncated julian date is defined as the julian day shifted to start at 00:00 and modulo 10000 days.
* The last origin (ie: 0) was 1995-10-10T00:00
* The last origin (ie: 0) was 1995-10-10T00:00
* (definition by National Institute of Standards and Technology).
* @param gmt convert returned value to GMT? (default: false)
* @return truncated julian date in the current timezone / in GMT depending on the gmt parameter
......@@ -387,7 +396,7 @@ double Date::getExcelDate(const bool& gmt) const {
}
/**
* @brief Return Matlab date.
* @brief Return Matlab date.
* This is the number of days since 0000-01-01T00:00:00. See http://www.mathworks.com/help/techdoc/ref/datenum.html
* @param gmt convert returned value to GMT? (default: false)
* @return Matlab date in the current timezone / in GMT depending on the gmt parameter
......@@ -785,21 +794,21 @@ const string Date::toString(FORMATS type, const bool& gmt) const
stringstream tmpstr;
if(type==ISO) {
tmpstr
tmpstr
<< setw(4) << setfill('0') << year_out << "-"
<< setw(2) << setfill('0') << month_out << "-"
<< setw(2) << setfill('0') << day_out << "T"
<< setw(2) << setfill('0') << hour_out << ":"
<< setw(2) << setfill('0') << minute_out;
} else if(type==NUM) {
tmpstr
tmpstr
<< setw(4) << setfill('0') << year_out
<< setw(2) << setfill('0') << month_out
<< setw(2) << setfill('0') << day_out
<< setw(2) << setfill('0') << hour_out
<< setw(2) << setfill('0') << minute_out ;
} else if(type==FULL) {
tmpstr
tmpstr
<< setw(4) << setfill('0') << year_out << "-"
<< setw(2) << setfill('0') << month_out << "-"
<< setw(2) << setfill('0') << day_out << "T"
......@@ -808,7 +817,7 @@ const string Date::toString(FORMATS type, const bool& gmt) const
<< setprecision(10) << julian_out << ") GMT"
<< setw(2) << setfill('0') << showpos << timezone << noshowpos;
} else if(type==DIN) {
tmpstr
tmpstr
<< setw(2) << setfill('0') << day_out << "."
<< setw(2) << setfill('0') << month_out << "."
<< setw(4) << setfill('0') << year_out << " "
......@@ -872,7 +881,7 @@ bool Date::isLeapYear(const int& i_year) const
long Date::getJulianDayNumber(const int& i_year, const int& i_month, const int& i_day) const
{ //given year, month, day, calculate the matching julian day
//see Fliegel, H. F. and van Flandern, T. C. 1968. Letters to the editor: a machine algorithm for processing calendar dates. Commun. ACM 11, 10 (Oct. 1968), 657. DOI= http://doi.acm.org/10.1145/364096.364097
//see Fliegel, H. F. and van Flandern, T. C. 1968. Letters to the editor: a machine algorithm for processing calendar dates. Commun. ACM 11, 10 (Oct. 1968), 657. DOI= http://doi.acm.org/10.1145/364096.364097
const long lmonth = (long) i_month, lday = (long) i_day;
long lyear = (long) i_year;
......@@ -891,10 +900,10 @@ long Date::getJulianDayNumber(const int& i_year, const int& i_month, const int&
void Date::plausibilityCheck(const int& in_year, const int& in_month, const int& in_day, const int& in_hour, const int& in_minute) const {
if ((in_year < -4713) || (in_year >3000)
|| (in_month < 1) || (in_month > 12)
|| (in_day < 1) || ((in_day > daysNonLeapYear[in_month-1]) && !isLeapYear(in_year))
|| ((in_day > daysLeapYear[in_month-1]) && isLeapYear(in_year))
|| (in_hour < 0) || (in_hour > 24)
|| (in_month < 1) || (in_month > 12)
|| (in_day < 1) || ((in_day > daysNonLeapYear[in_month-1]) && !isLeapYear(in_year))
|| ((in_day > daysLeapYear[in_month-1]) && isLeapYear(in_year))
|| (in_hour < 0) || (in_hour > 24)
|| (in_minute < 0) || (in_minute > 59)) {
stringstream ss;
ss << "Invalid Date requested: " << in_year << " " << in_month;
......
......@@ -35,11 +35,11 @@ namespace mio {
* This class handles conversion between different time display formats (ISO, numeric) as well as different
* time representation (julian date, modified julian date, etc). It also handles time zones as well as
* very basic Daylight Saving Time (DST). Since the activation dates of DST are political and not technical,
* it can not be automatically calculated. Therefore, it has to be provided by the caller: when the dst flag
* it can not be automatically calculated. Therefore, it has to be provided by the caller: when the dst flag
* is set, the dst time shift is automatically applied. When the dst flag ceases to be set, the dst time shift
* is no longer applied. This is very crude, but please keep in mind that using DST for monitoring data is
* usually a bad idea...
*
*
* Internally, the date is stored as true julian date in GMT.
* The maximal precision is 1 minute (that can be easily brought to 1 seconds if
* it would appear necessary/useful, with the limitation that leap seconds are currently not handled).
......@@ -65,7 +65,7 @@ class Date : POPBase {
void Serialize(POPBuffer &buf, bool pack);
#else
class Date {
#endif
#endif
public:
///Keywords for selecting the date formats
typedef enum {
......@@ -98,6 +98,7 @@ class Date {
void setFromSys();
void setTimeZone(const double& in_timezone, const bool& in_dst=false);
void setDate(const Date& in_date);
void setDate(const double& julian_in, const double& in_timezone, const bool& in_dst=false);
void setDate(const int& year, const int& month, const int& day, const int& hour, const int& minute, const double& in_timezone, const bool& in_dst=false);
void setDate(const int& year, const unsigned int& month, const unsigned int& day, const unsigned int& hour, const unsigned int& minute, const double& in_timezone, const bool& in_dst=false);
......@@ -141,7 +142,7 @@ class Date {
bool operator<=(const Date&) const;
bool operator>(const Date&) const;
bool operator>=(const Date&) const;
///Intervals arithmetic
///Can be used to add an interval to an existing Date object.
///Construct a Date object representing the interval e.g. Date(1.0) for 1 day and add that to another Date object.
......
......@@ -22,7 +22,7 @@ using namespace std;
namespace mio {
#ifdef _POPC_
IOException::IOException(const std::string& message, const std::string& position):POPException(STD_EXCEPTION)
IOException::IOException(const std::string& message, const std::string& position) : POPException(STD_EXCEPTION)
#else
IOException::IOException(const std::string& message, const std::string& position)