WSL/SLF GitLab Repository

Commit d8790389 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The definition of the "<<" operator has been written for IOManager and made...

The definition of the "<<" operator has been written for IOManager and made more consistent for others
parent 964aacc2
......@@ -403,12 +403,8 @@ void BufferedIOHandler::clearBuffer(){
std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data)
{
os << "<BufferedIOHandler>\n";
os << "Config cfg; (not expanded)\n";
#ifndef _POPC_
os << data.iohandler;
#else
os << data.iohandler.toString();
#endif
os << "Config cfg = " << hex << &data.cfg << "\n";
os << "IOHandler &iohandler = " << hex << &data.iohandler << "\n";
os << data.meteoprocessor;
os << "Rebuffer if not found: " << data.always_rebuffer << "\n";
......
......@@ -294,7 +294,7 @@ std::string IOHandler::toString() const
{
std::stringstream os;
os << "<IOHandler>\n";
os << cfg;
os << "Config cfg = " << hex << &cfg << "\n";
os << "<mapPlugins>\n";
os << setw(10) << "Keyword" << " = " << IOPlugin::header << "\n";
......
......@@ -207,4 +207,51 @@ void IOManager::write2DGrid(const Grid2DObject& grid2D, const std::string& name)
}
}
std::ostream& operator<<(std::ostream& os, const IOManager& io)
{
os << "<IOManager>\n";
os << "Config cfg = " << hex << &io.cfg << "\n";
os << io.rawio;
os << io.bufferedio;
os << io.meteoprocessor;
os << "Processing level = " << io.processing_level << "\n";
unsigned int count=0;
unsigned int min_stations=std::numeric_limits<unsigned int>::max();
unsigned int max_stations=-std::numeric_limits<unsigned int>::max();
std::map<Date, std::vector<MeteoData> >::const_iterator iter = io.meteo_cache.begin();
for (; iter != io.meteo_cache.end(); iter++) {
const unsigned int nb_stations = iter->second.size();
if(nb_stations>max_stations) max_stations=nb_stations;
if(nb_stations<min_stations) min_stations=nb_stations;
count++;
}
if(count==0) {
os << "Meteo cache is empty\n";
}
if(count==1) {
os << "Meteo cache contains 1 element at " << io.meteo_cache.begin()->first.toString(Date::ISO);
os << " for ";
if(max_stations==min_stations)
os << min_stations << " station(s)\n";
else
os << "between " << min_stations << " and " << max_stations << " stations\n";
}
if(count>1) {
const double avg_sampling = ( (io.meteo_cache.rbegin()->first.getJulianDate()) - (io.meteo_cache.begin()->first.getJulianDate()) ) / (double)(count-1);
os << "Meteo cache goes from " << io.meteo_cache.begin()->first.toString(Date::ISO);
os << " to " << io.meteo_cache.rbegin()->first.toString(Date::ISO);
os << " with " << count << " timesteps (" << setprecision(3) << fixed << avg_sampling*24.*3600. << " s sampling rate)";
os << " for ";
if(max_stations==min_stations)
os << min_stations << " station(s)\n";
else
os << "between " << min_stations << " and " << max_stations << " stations\n";
}
os << "</IOManager>\n";
return os;
}
} //namespace
......@@ -65,6 +65,8 @@ class IOManager {
void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo, const std::string& name="");
friend std::ostream& operator<<(std::ostream& os, const IOManager& io);
private:
void add_to_cache(const Date& i_date, const std::vector<MeteoData>& vecMeteo);
......
......@@ -130,9 +130,9 @@ string Meteo1DInterpolator::getInterpolationForParameter(const std::string& parn
std::ostream& operator<<(std::ostream& os, const Meteo1DInterpolator& Interpolator) {
os << "<Meteo1DInterpolator>\n";
os << "Config cfg; (not expanded)\n";
os << "Config cfg = " << hex << &Interpolator.cfg << "\n";
for (unsigned int jj=0; jj<Interpolator.tasklist.size(); jj++){
os << MeteoData::getParameterName(jj) << "::" << Interpolator.tasklist[jj] << "\t";
os << setw(10) << MeteoData::getParameterName(jj) << "::" << Interpolator.tasklist[jj] << "\t";
for (unsigned int ii=0; ii<Interpolator.taskargs[jj].size(); ii++){
os << "ARGS: " << Interpolator.taskargs[jj][ii] << " ";
}
......
......@@ -203,6 +203,7 @@ void Meteo2DInterpolator::checkMinMax(const double& minval, const double& maxval
std::ostream& operator<<(std::ostream &os, const Meteo2DInterpolator &mi) {
os << "<Meteo2DInterpolator>\n";
os << "Config *cfg = " << hex << &mi.cfg << "\n";
os << "IOManager *iomanager = " << hex << &mi.iomanager << "\n";
//os << "DemObject *dem= " << hex << &mi.dem << "\n";
//const unsigned int nb_stations = mi.vecMeteo.size();
......
......@@ -116,7 +116,7 @@ std::ostream& operator<<(std::ostream& os, const MeteoFilter& data)
os << "<MeteoFilter>\n";
for (unsigned int ii=0; ii<data.tasklist.size(); ii++){ //For all meteo parameters
os << std::setw(5) << MeteoData::getParameterName(ii) << " =\t";
os << std::setw(10) << MeteoData::getParameterName(ii) << " = ";
for (unsigned int jj=0; jj<data.tasklist[ii].size(); jj++){ //For eack activated filter
os << "[ " << data.tasklist[ii][jj] << " ";
for(unsigned int kk=0; kk<data.taskargs.at(ii).at(jj).size(); kk++)
......
......@@ -73,6 +73,7 @@ std::ostream& operator<<(std::ostream& os, const MeteoProcessor& data)
os << "<MeteoProcessor>\n";
os << data.mf;
os << data.mi1d;
os << "window_half_size = " << data.window_half_size << "\n";
os << "</MeteoProcessor>\n";
return os;
}
......
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