WSL/SLF GitLab Repository

IOHandler.cmake.hpp 4.65 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/***********************************************************************************/
/*  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/>.
*/
#ifndef __IOHANDLER_H__
#define __IOHANDLER_H__

21
/*#ifdef _POPC_
22
#error
23
#endif*/
24

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#cmakedefine PLUGIN_ARCIO
#cmakedefine PLUGIN_A3DIO
#cmakedefine PLUGIN_ARPSIO
#cmakedefine PLUGIN_GRASSIO
#cmakedefine PLUGIN_GEOTOPIO
#cmakedefine PLUGIN_SMETIO
#cmakedefine PLUGIN_SNIO
#cmakedefine PLUGIN_PGMIO
#cmakedefine PLUGIN_IMISIO
#cmakedefine PLUGIN_GRIBIO
#cmakedefine PLUGIN_PNGIO
#cmakedefine PLUGIN_BORMAIO
#cmakedefine PLUGIN_COSMOXMLIO
#cmakedefine PLUGIN_GSNIO

40
41
42
43
#include <meteoio/IOInterface.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/IOPlugin.h>

44
45
46
47
48
49
#include <meteoio/plugins/ARCIO.h>
#include <meteoio/plugins/A3DIO.h>
#include <meteoio/plugins/ARPSIO.h>
#include <meteoio/plugins/GrassIO.h>
#include <meteoio/plugins/GeotopIO.h>
#include <meteoio/plugins/PGMIO.h>
50
#include <meteoio/plugins/SMETIO.h>
51
52
#include <meteoio/plugins/SNIO.h>

53
54
55
56
57
58
59
60
#ifdef PLUGIN_BORMAIO
#include <meteoio/plugins/BormaIO.h>
#endif

#ifdef PLUGIN_COSMOXMLIO
#include <meteoio/plugins/CosmoXMLIO.h>
#endif

61
62
63
64
65
66
67
68
69
70
71
72
#ifdef PLUGIN_IMISIO
#include <meteoio/plugins/ImisIO.h>
#endif

#ifdef PLUGIN_GRIBIO
#include <meteoio/plugins/GRIBIO.h>
#endif

#ifdef PLUGIN_GSNIO
#include <meteoio/plugins/GSNIO.h>
#endif

73
74
75
76
#ifdef PLUGIN_PNGIO
#include <meteoio/plugins/PNGIO.h>
#endif

77
78
79
80
81
82
#include <map>
#include <string>

namespace mio {

/**
83
* @file IOHandler.h
84
85
* @class IOHandler
* @brief This class is the class to use for raw I/O operations. It is responsible for transparently loading the plugins
86
* and it follows the interface defined by the IOInterface class with the addition of a few convenience methods.
87
*/
88
89
90
#ifdef _POPC_
class IOHandler {
#else
91
class IOHandler : public IOInterface {
92
#endif
93
	public:
94
	#ifndef _POPC_
95
		IOHandler(const IOHandler&);
96
	#endif
97
		IOHandler(const Config&);
98
	#ifdef _POPC_
99
		virtual ~IOHandler();
100
	#else
101
		virtual ~IOHandler() throw();
102
	#endif
103
104

		//methods defined in the IOInterface class
105
		virtual void read2DGrid(Grid2DObject& out_grid, const std::string& parameter="");
106
		virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
107
108
		virtual void readDEM(DEMObject& dem_out);
		virtual void readLanduse(Grid2DObject& landuse_out);
109
		virtual void readStationData(const Date& date,
110
		                             STATION_TIMESERIE& vecStation);
111
112
113
114
	#ifdef _POPC_
		virtual void writeMeteoData(std::vector<METEO_TIMESERIE>& vecMeteo,
		                            const std::string& name="");
	#else
115
		virtual void writeMeteoData(const std::vector<METEO_TIMESERIE>& vecMeteo,
116
		                            const std::string& name="");
117
	#endif
118
		virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
119
		                           std::vector<METEO_TIMESERIE>& vecMeteo,
120
		                           const size_t& stationindex=IOUtils::npos);
121
		void readMeteoData(const Date& date, METEO_TIMESERIE& vecMeteo);
122

123
124
125
		virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
		virtual void readSpecialPoints(std::vector<Coords>& pts);
		virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& name);
126
		virtual void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);
127

128
	#ifndef _POPC_
129
		friend std::ostream& operator<<(std::ostream& os, const IOHandler& data);
130
131
132
133
	#endif
	#ifdef _POPC_
		std::string toString();
	#else
134
		std::string toString() const;
135
	#endif
136

137
138
139
140
	private:
		void registerPlugins();
		IOInterface *getPlugin(const std::string& cfgkey, const std::string& cfgsection="GENERAL");

141
142
		void parse_copy_config();
		void copy_parameters(const size_t& stationindex, std::vector< METEO_TIMESERIE >& vecMeteo) const;
143
		const Config& cfg;
144
		std::map<std::string, IOPlugin> mapPlugins;
145
146

		std::vector<std::string> copy_parameter, copy_name;
147
		bool enable_copying;
148
149
};

150
} //namespace
151
152

#endif