WSL/SLF GitLab Repository

ProcessingBlock.h 3.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/***********************************************************************************/
/*  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 __PROCESSINGBLOCK_H__
#define __PROCESSINGBLOCK_H__

#include <meteoio/MeteoData.h>
#include <vector>
#include <string>
#include <set>

namespace mio {

class ProcessingProperties {
	public:
30
31
32
33
34
35
36
		typedef enum PROC_STAGE { none, ///< never activate this block
		                     first, ///< activate at first stage
		                     second, ///< activate at second stage
		                     both ///< activate at both first and second stage
		                     //once ///< activate at stage one or two, but only once
		                   } proc_stage;

37
38
39
40
41
42
		ProcessingProperties() : time_before(0., 0.), time_after(0., 0.),
		                         points_before(0), points_after(0),
		                         stage(first) {}

		const std::string toString() const;

43
44
		Duration time_before;
		Duration time_after;
45

Mathias Bavay's avatar
Mathias Bavay committed
46
47
		size_t points_before;
		size_t points_after;
48

49
		proc_stage stage;
50
51
52
53
};

/**
 * @class  ProcessingBlock
54
 * @brief  An abstract class
55
56
57
58
59
60
 * @author Thomas Egger
 * @date   2011-01-02
 */
class ProcessingBlock {
	public:
		virtual ~ProcessingBlock();
61

62
		virtual void process(const unsigned int& param, const std::vector<MeteoData>& ivec,
63
		                     std::vector<MeteoData>& ovec) = 0;
64
65
66

		std::string getName() const;
		const ProcessingProperties& getProperties() const;
67
		const std::string toString() const;
68
69
70
71

	protected:
		ProcessingBlock(const std::string& name); ///< protected constructor only to be called by children

72
73
74
75
76
		void convert_args(const size_t& min_nargs, const size_t& max_nargs,
		                  const std::vector<std::string>& vec_args, std::vector<double>& dbl_args) const;

		static bool is_soft(std::vector<std::string>& vec_args);

77
		ProcessingProperties properties;
78
		const std::string block_name;
79
80
81
82
83
84
85
86
87
88
89
90
91
92
};

class BlockFactory {
	public:
		static ProcessingBlock* getBlock(const std::string& blockname, const std::vector<std::string>& vec_args);

		static std::set<std::string> availableBlocks; ///<all blocks that exist
		static const bool __init;    ///<helper variable to enable the init of static collection data
		static bool initStaticData();///<initialize the static availableBlocks
};

} //end namespace

#endif