WSL/SLF GitLab Repository

IOHandler.h 3.78 KB
Newer Older
Thomas Egger's avatar
Thomas Egger committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/***********************************************************************************/
/*  Copyright 2009 WSL Institute for Snow and Avalanche Research    SLF-DAVOS      */
/***********************************************************************************/
/* This file is part of MeteoIO.
    MeteoIO is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    MeteoIO is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with MeteoIO.  If not, see <http://www.gnu.org/licenses/>.
*/
18
19
#ifndef IOHANDLER_H
#define IOHANDLER_H
Thomas Egger's avatar
Thomas Egger committed
20
21
22
23
24

#include <meteoio/IOInterface.h>
#include <meteoio/IOExceptions.h>

#include <map>
25
#include <set>
Thomas Egger's avatar
Thomas Egger committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <string>

namespace mio {

/**
* @file IOHandler.h
* @class IOHandler
* @brief This class is the class to use for raw I/O operations. It is responsible for transparently loading the plugins
* and it follows the interface defined by the IOInterface class with the addition of a few convenience methods.
*/
class IOHandler : public IOInterface {
	public:
		IOHandler(const IOHandler&);
		IOHandler(const Config&);
Mathias Bavay's avatar
Mathias Bavay committed
40

Thomas Egger's avatar
Thomas Egger committed
41
42
		virtual ~IOHandler() throw();

43
44
		IOHandler& operator=(const IOHandler&); ///<Assignement operator

Thomas Egger's avatar
Thomas Egger committed
45
46
47
48
49
50
		//methods defined in the IOInterface class
		virtual void read2DGrid(Grid2DObject& out_grid, const std::string& parameter="");
		virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
		virtual void readDEM(DEMObject& dem_out);
		virtual void readLanduse(Grid2DObject& landuse_out);
		virtual void readStationData(const Date& date,
51
		                             STATIONS_SET& vecStation);
Mathias Bavay's avatar
Mathias Bavay committed
52

53
		virtual void writeMeteoData(const std::vector<METEO_SET>& vecMeteo,
Thomas Egger's avatar
Thomas Egger committed
54
55
		                            const std::string& name="");
		virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
56
		                           std::vector<METEO_SET>& vecMeteo,
Thomas Egger's avatar
Thomas Egger committed
57
58
59
		                           const size_t& stationindex=IOUtils::npos);

		virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
60
		virtual void readPOI(std::vector<Coords>& pts);
Thomas Egger's avatar
Thomas Egger committed
61
62
63
		virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& name);
		virtual void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);

64
		const std::string toString() const;
Thomas Egger's avatar
Thomas Egger committed
65
66

	private:
67
68
		IOInterface* getPlugin(const std::string& plugin_name) const;
		IOInterface* getPlugin(const std::string& cfgkey, const std::string& cfgsection);
Thomas Egger's avatar
Thomas Egger committed
69
		void parse_copy_config();
70
		void create_exclude_map();
71
		void create_keep_map();
72
		void create_merge_map();
73
		void checkTimestamps(const std::vector<METEO_SET>& vecVecMeteo) const;
74
		void exclude_params(std::vector<METEO_SET>& vecVecMeteo) const;
75
		void keep_params(std::vector<METEO_SET>& vecVecMeteo) const;
76
		void copy_parameters(const size_t& stationindex, std::vector< METEO_SET >& vecMeteo) const;
77
78
		void merge_stations(std::vector<METEO_SET>& vecVecMeteo) const;
		void merge_stations(STATIONS_SET& vecStation) const;
79

Thomas Egger's avatar
Thomas Egger committed
80
		const Config& cfg;
81
		std::map<std::string, IOInterface*> mapPlugins;
82
		std::map< std::string, std::set<std::string> > excluded_params;
83
		std::map< std::string, std::set<std::string> > kept_params;
84
85
86
		std::map< std::string, std::vector<std::string> > merge_commands;
		std::vector<std::string> merged_stations, copy_parameter, copy_name;
		bool enable_copying, excludes_ready, keeps_ready, merge_ready;
Thomas Egger's avatar
Thomas Egger committed
87
88
89
90
91
};

} //namespace

#endif