MeteoIODoc 2.11.0
IOHandler.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4/***********************************************************************************/
5/* This file is part of MeteoIO.
6 MeteoIO is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 MeteoIO is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef IOHANDLER_H
20#define IOHANDLER_H
21
22#include <meteoio/IOInterface.h>
23#include <meteoio/DataEditing.h>
24
25#include <map>
26#include <set>
27#include <string>
28
29namespace mio {
30
37class IOHandler : public IOInterface {
38 public:
39 IOHandler(const IOHandler&);
40 IOHandler(const Config&);
41
42 virtual ~IOHandler() noexcept;
43
45
46 //methods defined in the IOInterface class
47 virtual bool list2DGrids(const Date& start, const Date& end, std::map<Date, std::set<size_t> > &list);
48 virtual void read2DGrid(Grid2DObject& out_grid, const std::string& parameter="");
49 virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
50 virtual void readPointsIn2DGrid(std::vector<double>& data, const MeteoGrids::Parameters& parameter, const Date& date, const std::vector< std::pair<size_t, size_t> >& Pts);
51 virtual void read3DGrid(Grid3DObject& grid_out, const std::string& i_filename="");
52 virtual void read3DGrid(Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
53
54 virtual void readDEM(DEMObject& dem_out);
55 virtual void readLanduse(Grid2DObject& landuse_out);
56 virtual void readGlacier(Grid2DObject& glacier_out);
57
58 virtual void readStationData(const Date& date,
59 STATIONS_SET& vecStation);
60
61 virtual void writeMeteoData(const std::vector<METEO_SET>& vecMeteo,
62 const std::string& name="");
63 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
64 std::vector<METEO_SET>& vecMeteo);
65
66 virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
67 virtual void readPOI(std::vector<Coords>& pts);
68 virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& name);
69 virtual void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);
70 virtual void write3DGrid(const Grid3DObject& grid_out, const std::string& options);
71 virtual void write3DGrid(const Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
72
73 const std::string toString() const;
74
75 private:
76 IOInterface* getPlugin(std::string plugin_name, const Config& i_cfg) const;
77 IOInterface* getPlugin(const std::string& cfgkey, const std::string& cfgsection, const std::string& sec_rename="");
78 std::vector<std::string> getListOfSources(const std::string& plugin_key, const std::string& sec_pattern) const;
79
80 const Config& cfg;
81 DataEditing preProcessor;
82 std::map<std::string, IOInterface*> mapPlugins;
83};
84
85} //namespace
86
87#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
A class to represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:40
Definition: DataEditing.h:45
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:42
A class to represent 3D Grids. Typical application: wind field.
Definition: Grid3DObject.h:39
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition: IOHandler.h:37
virtual bool list2DGrids(const Date &start, const Date &end, std::map< Date, std::set< size_t > > &list)
Return the list of grids within a given time period that could be read by the plugin,...
Definition: IOHandler.cc:416
virtual void readPointsIn2DGrid(std::vector< double > &data, const MeteoGrids::Parameters &parameter, const Date &date, const std::vector< std::pair< size_t, size_t > > &Pts)
Read the given meteo parameter into a vector for a list of points. Each plugin has its own logic for ...
Definition: IOHandler.cc:434
virtual void readMeteoData(const Date &dateStart, const Date &dateEnd, std::vector< METEO_SET > &vecMeteo)
Definition: IOHandler.cc:491
IOHandler & operator=(const IOHandler &)
Assignement operator.
Definition: IOHandler.cc:393
virtual void write2DGrid(const Grid2DObject &grid_in, const std::string &name)
Write a Grid2DObject The filename is specified relative to GRID2DPATH for most plugins.
Definition: IOHandler.cc:534
virtual void readLanduse(Grid2DObject &landuse_out)
Parse the landuse model into the Grid2DObject.
Definition: IOHandler.cc:459
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: IOHandler.cc:452
virtual void readAssimilationData(const Date &, Grid2DObject &da_out)
Parse the assimilation data into a Grid2DObject for a certain date represented by the Date object.
Definition: IOHandler.cc:523
virtual void read2DGrid(Grid2DObject &out_grid, const std::string &parameter="")
A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for a...
Definition: IOHandler.cc:422
virtual void readGlacier(Grid2DObject &glacier_out)
Parse the input glacier grid into the Grid2DObject.
Definition: IOHandler.cc:465
virtual void write3DGrid(const Grid3DObject &grid_out, const std::string &options)
Write a Grid3DObject The filename is specified relative to GRID3DPATH for most plugins.
Definition: IOHandler.cc:546
const std::string toString() const
Definition: IOHandler.cc:558
virtual ~IOHandler() noexcept
Definition: IOHandler.cc:384
virtual void readPOI(std::vector< Coords > &pts)
Read a list of points by their grid coordinates This allows for example to get a list of points where...
Definition: IOHandler.cc:529
IOHandler(const IOHandler &)
Definition: IOHandler.cc:376
virtual void writeMeteoData(const std::vector< METEO_SET > &vecMeteo, const std::string &name="")
Definition: IOHandler.cc:516
virtual void read3DGrid(Grid3DObject &grid_out, const std::string &i_filename="")
A generic function for parsing 3D grids into a Grid3DObject. The string parameter shall be used for a...
Definition: IOHandler.cc:440
virtual void readStationData(const Date &date, STATIONS_SET &vecStation)
Definition: IOHandler.cc:471
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
Parameters
this enum provides names for possible meteogrids (from an ARPS file, etc)
Definition: MeteoData.h:46
Definition: Config.cc:31
std::vector< StationData > STATIONS_SET
Definition: StationData.h:141