MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IOHandler.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of MeteoIO.
5  MeteoIO is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  MeteoIO is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef IOHANDLER_H
19 #define IOHANDLER_H
20 
21 #include <meteoio/IOInterface.h>
22 #include <meteoio/DataCreator.h>
23 
24 #include <map>
25 #include <set>
26 #include <string>
27 
28 namespace mio {
29 
36 class IOHandler : public IOInterface {
37  public:
38  IOHandler(const IOHandler&);
39  IOHandler(const Config&);
40 
41  virtual ~IOHandler() throw();
42 
43  IOHandler& operator=(const IOHandler&);
44 
45  //methods defined in the IOInterface class
46  virtual void read2DGrid(Grid2DObject& out_grid, const std::string& parameter="");
47  virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
48  virtual void read3DGrid(Grid3DObject& grid_out, const std::string& i_filename="");
49  virtual void read3DGrid(Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
50 
51  virtual void readDEM(DEMObject& dem_out);
52  virtual void readLanduse(Grid2DObject& landuse_out);
53  virtual void readStationData(const Date& date,
54  STATIONS_SET& vecStation);
55 
56  virtual void writeMeteoData(const std::vector<METEO_SET>& vecMeteo,
57  const std::string& name="");
58  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
59  std::vector<METEO_SET>& vecMeteo);
60 
61  virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
62  virtual void readPOI(std::vector<Coords>& pts);
63  virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& name);
64  virtual void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);
65  virtual void write3DGrid(const Grid3DObject& grid_out, const std::string& options);
66  virtual void write3DGrid(const Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
67 
68  const std::string toString() const;
69 
70  private:
71  IOInterface* getPlugin(const std::string& plugin_name) const;
72  IOInterface* getPlugin(const std::string& cfgkey, const std::string& cfgsection);
73  void create_copy_map();
74  void create_move_map();
75  void create_exclude_map();
76  void create_keep_map();
77  void create_merge_map();
78 
79  static void checkTimestamps(const std::vector<METEO_SET>& vecVecMeteo);
80  void copy_params(std::vector< METEO_SET >& vecMeteo) const;
81  void move_params(std::vector< METEO_SET >& vecMeteo) const;
82  void exclude_params(std::vector<METEO_SET>& vecVecMeteo) const;
83  void keep_params(std::vector<METEO_SET>& vecVecMeteo) const;
84  void merge_stations(std::vector<METEO_SET>& vecVecMeteo) const;
85  void merge_stations(STATIONS_SET& vecStation) const;
86 
87  const Config& cfg;
88  DataCreator dataCreator;
89  std::map<std::string, IOInterface*> mapPlugins;
90  std::map< std::string, std::set<std::string> > excluded_params;
91  std::map< std::string, std::set<std::string> > kept_params;
92  std::map< std::string, std::vector<std::string> > merge_commands;
93  std::map< std::string, std::string > copy_commands;
94  std::map< std::string, std::set<std::string> > move_commands;
95  std::vector<std::string> merged_stations;
96  int merge_strategy;
97  bool copy_ready, move_ready, excludes_ready, keeps_ready, merge_ready;
98 };
99 
100 } //namespace
101 
102 #endif
virtual void readLanduse(Grid2DObject &landuse_out)
Parse the landuse model into the Grid2DObject.
Definition: IOHandler.cc:438
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:486
A class representing the IO Layer of the software Alpine3D. For each type of IO (File, DB, Webservice, etc) a derived class is to be created that holds the specific implementation of the appropriate virtual methods. The IOHandler class is a wrapper class that is able to deal with all above implementations of the IOInterface abstract base class.
Definition: IOInterface.h:43
A class to create new meteo data parameters from user-selected models or parametrizations. This class sits in between the actual implementation of the various methods and the IOManager in order to offer some high level interface. It basically reads the arguments and creates the objects for the various data generators in its constructor and loop through the parameters and stations when called.
Definition: DataCreator.h:43
A class to represent 3D Grids. Typical application: wind field.
Definition: Grid3DObject.h:38
const std::string toString() const
Definition: IOHandler.cc:999
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:497
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: IOHandler.cc:431
IOHandler(const IOHandler &)
Definition: IOHandler.cc:360
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:509
virtual void writeMeteoData(const std::vector< METEO_SET > &vecMeteo, const std::string &name="")
Definition: IOHandler.cc:479
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition: IOHandler.h:36
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:419
std::vector< StationData > STATIONS_SET
Definition: StationData.h:129
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
A class to represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:39
virtual ~IOHandler()
Definition: IOHandler.cc:378
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:37
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:407
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
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:492
virtual void readStationData(const Date &date, STATIONS_SET &vecStation)
Definition: IOHandler.cc:444
IOHandler & operator=(const IOHandler &)
Assignement operator.
Definition: IOHandler.cc:387
Parameters
Definition: MeteoData.h:44
virtual void readMeteoData(const Date &dateStart, const Date &dateEnd, std::vector< METEO_SET > &vecMeteo)
Definition: IOHandler.cc:453