WSL/SLF GitLab Repository

Commit 83d65fc6 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The proper marshaling for MeteoData has been implemented, but not yet tested...

parent 886f3a28
......@@ -301,42 +301,49 @@ void MeteoData::initAllParameters()
}
}
} //namespace
#ifdef _POPC_
#include "marshal_meteoio.h"
using namespace mio; //HACK for POPC
void MeteoData::Serialize(POPBuffer &buf, bool pack)
{
if (pack){
buf.Pack(&resampled,1);
date.Serialize(buf,true);
buf.Pack(&nrOfAllParameters,1);
buf.Pack(&ta,1);
buf.Pack(&iswr,1);
buf.Pack(&vw,1);
buf.Pack(&dw,1);
buf.Pack(&rh,1);
buf.Pack(&ilwr,1);
//buf.Pack(&ea,1);
buf.Pack(&hnw,1);
buf.Pack(&iswr,1);
buf.Pack(&rswr,1);
buf.Pack(&ilwr,1);
buf.Pack(&tsg,1);
buf.Pack(&tss,1);
buf.Pack(&hs,1);
buf.Pack(&rswr,1);
buf.Pack(&p,1);
marshal_map_str_dbl(buf, extraparameters, 0, FLAG_MARSHAL, NULL);
}else{
buf.UnPack(&resampled,1);
date.Serialize(buf,false);
buf.UnPack(&nrOfAllParameters,1);
buf.UnPack(&ta,1);
buf.UnPack(&iswr,1);
buf.UnPack(&vw,1);
buf.UnPack(&dw,1);
buf.UnPack(&rh,1);
buf.UnPack(&ilwr,1);
//buf.UnPack(&ea,1);
buf.UnPack(&hnw,1);
buf.UnPack(&iswr,1);
buf.UnPack(&rswr,1);
buf.UnPack(&ilwr,1);
buf.UnPack(&tsg,1);
buf.UnPack(&tss,1);
buf.UnPack(&hs,1);
buf.UnPack(&rswr,1);
buf.UnPack(&p,1);
marshal_map_str_dbl(buf, extraparameters, 0, !FLAG_MARSHAL, NULL);
initParameterMap();
}
}
#endif
} //namespace
......@@ -127,6 +127,32 @@ void marshal_vector_METEO_DATASET(POPBuffer &buf, std::vector<METEO_DATASET> &da
}
}
void marshal_map_str_dbl(POPBuffer &buf, std::map<std::string, double> &data_map, int maxsize, int flag, POPMemspool *temp)
{
(void)maxsize;
(void)*temp;
if(flag&FLAG_MARSHAL) {
int n=data_map.size();
buf.Pack(&n,1);
for(std::map<std::string, double>::const_iterator it = data_map.begin(); it != data_map.end(); ++it) {
buf.Pack(&(it->first),1);
buf.Pack(&(it->second),1);
}
} else {
int n=0;
std::string key;
double value;
buf.UnPack(&n,1);
data_map.clear();
for(int i=0;i<n;i++) {
buf.UnPack(&key,1);
buf.UnPack(&value,1);
data_map[key] = value;
}
}
}
void marshal_map_str_str(POPBuffer &buf, std::map<std::string, std::string> &data_map, int maxsize, int flag, POPMemspool *temp)
{
(void)maxsize;
......
......@@ -59,6 +59,8 @@ void marshal_vecstr(POPBuffer &buf, std::vector<std::string> &data, int maxsize,
void marshal_map_str_str(POPBuffer &buf, std::map<std::string, std::string> &data_map, int maxsize, int flag, POPMemspool *temp);
void marshal_map_str_dbl(POPBuffer &buf, std::map<std::string, double> &data_map, int maxsize, int flag, POPMemspool *temp);
void marshal_map_str_vecstr(POPBuffer &buf, std::map<std::string, STR_VECTOR> &data_map, int maxsize, int flag, POPMemspool *temp);
void marshal_Coords(POPBuffer &buf, Coords &data, int maxsize, int flag, POPMemspool *temp);
......
......@@ -105,6 +105,7 @@ void BormaIO::writeMeteoData(const std::vector< std::vector<MeteoData> >&,
void BormaIO::readStationData(const Date&, std::vector<StationData>&)
{
//HACK: this method MUST be implemented for BufferedIOHandler to properly work
//Nothing so far
throw IOException("Nothing implemented here", AT);
}
......
......@@ -187,6 +187,7 @@ void SMETIO::readAssimilationData(const Date& /*date_in*/, Grid2DObject& /*da_ou
void SMETIO::readStationData(const Date&, std::vector<StationData>& vecStation)
{//big HACK: this is a barbaric code duplication!! Plus it should support coordinates in the data
//ie: it should use the given date!
unsigned int startindex=0, endindex=vecFiles.size();
vecStation.clear();
......
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