ChronFileInterpolator.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file ChronFileInterpolator.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_TOOLS_CHRONFILEINTERPOLATOR_HPP__
41 #define __OPENFLUID_TOOLS_CHRONFILEINTERPOLATOR_HPP__
42 
43 
44 #include <list>
45 #include <iostream>
46 
49 #include <openfluid/dllexport.hpp>
50 
51 
52 namespace openfluid { namespace tools {
53 
54 
56 {
57  public:
58 
59  enum PreProcess { PREPROCESS_NONE, PREPROCESS_CUMULATE };
60 
61 
62  private:
63 
64  void checkPreload();
65 
66  void checkPostload();
67 
68 
69  protected:
70 
71  std::string m_InFilePath;
72 
73  std::string m_InDateFormat;
74 
75  std::string m_InColumnSeparators;
76 
77  std::string m_InCommentChar;
78 
79  std::string m_OutFilePath;
80 
81  std::string m_OutDateFormat;
82 
83  std::string m_OutColumnSeparator;
84 
85  std::string m_OutCommentChar;
86 
88 
90 
92 
94 
95  void loadInFile(ChronologicalSerie& Data);
96 
98  {
99  ChronologicalSerie::iterator it;
100  ChronologicalSerie::iterator itb = Data.begin();
101  ChronologicalSerie::iterator ite = Data.end();
102 
103  std::cout << "--------------------------------" << std::endl;
104  for (it=itb;it!=ite;++it)
105  {
106  std::cout << (*it).first.getAsISOString() << " -> " << (*it).second << std::endl;
107  }
108  std::cout << "--------------------------------" << std::endl;
109  }
110 
111 
112  public:
113 
114 
115  ChronFileInterpolator(const std::string& InFilePath, const std::string& OutFilePath,
116  const openfluid::core::DateTime& BeginDate, const openfluid::core::DateTime& EndDate,
117  const openfluid::core::Duration_t& DeltaT, PreProcess PrePcs = PREPROCESS_NONE);
118 
119  virtual ~ChronFileInterpolator();
120 
121 
122  virtual void runInterpolation() = 0;
123 
124 
125  std::string getInColumnSeparators() const
126  {
127  return m_InColumnSeparators;
128  }
129 
130  void setInColumnSeparators(const std::string& InColumnSeparators)
131  {
132  m_InColumnSeparators = InColumnSeparators;
133  }
134 
135  std::string getInCommentChar() const
136  {
137  return m_InCommentChar;
138  }
139 
140  void setInCommentChar(const std::string& InCommentChar)
141  {
142  m_InCommentChar = InCommentChar;
143  }
144 
145  std::string getInDateFormat() const
146  {
147  return m_InDateFormat;
148  }
149 
150  void setInDateFormat(const std::string& InDateFormat)
151  {
152  m_InDateFormat = InDateFormat;
153  }
154 
155  std::string getInFilePath() const
156  {
157  return m_InFilePath;
158  }
159 
160  std::string getOutColumnSeparator() const
161  {
162  return m_OutColumnSeparator;
163  }
164 
165  void setOutColumnSeparator(const std::string& OutColumnSeparator)
166  {
167  m_OutColumnSeparator = OutColumnSeparator;
168  }
169 
170  std::string getOutCommentChar() const
171  {
172  return m_OutCommentChar;
173  }
174 
175  void setOutCommentChar(const std::string& OutCommentChar)
176  {
177  m_OutCommentChar = OutCommentChar;
178  }
179 
180  std::string getOutDateFormat() const
181  {
182  return m_OutDateFormat;
183  }
184 
185  void setOutDateFormat(const std::string& OutDateFormat)
186  {
187  m_OutDateFormat = OutDateFormat;
188  }
189 
190  std::string getOutFilePath() const
191  {
192  return m_OutFilePath;
193  }
194 
196  {
197  return m_BeginDate;
198  }
199 
201  {
202  return m_DeltaT;
203  }
204 
206  {
207  return m_EndDate;
208  }
209 
211  {
212  return m_PreProcess;
213  }
214 };
215 
216 
217 } } // namespaces
218 
219 
220 #endif /* __OPENFLUID_TOOLS_CHRONFILEINTERPOLATOR_HPP__ */
Class for management of date and time information.
Definition: DateTime.hpp:116
void setOutCommentChar(const std::string &OutCommentChar)
Definition: ChronFileInterpolator.hpp:175
Definition: ChronologicalSerie.hpp:59
PreProcess m_PreProcess
Definition: ChronFileInterpolator.hpp:93
std::string m_OutDateFormat
Definition: ChronFileInterpolator.hpp:81
void setInDateFormat(const std::string &InDateFormat)
Definition: ChronFileInterpolator.hpp:150
openfluid::core::Duration_t m_DeltaT
Definition: ChronFileInterpolator.hpp:91
openfluid::core::DateTime getEndDate() const
Definition: ChronFileInterpolator.hpp:205
openfluid::core::DateTime getBeginDate() const
Definition: ChronFileInterpolator.hpp:195
PreProcess
Definition: ChronFileInterpolator.hpp:59
openfluid::core::Duration_t getDeltaT() const
Definition: ChronFileInterpolator.hpp:200
std::string m_InDateFormat
Definition: ChronFileInterpolator.hpp:73
void setOutColumnSeparator(const std::string &OutColumnSeparator)
Definition: ChronFileInterpolator.hpp:165
std::string m_InCommentChar
Definition: ChronFileInterpolator.hpp:77
std::string getOutColumnSeparator() const
Definition: ChronFileInterpolator.hpp:160
std::string getOutFilePath() const
Definition: ChronFileInterpolator.hpp:190
std::string m_OutCommentChar
Definition: ChronFileInterpolator.hpp:85
PreProcess getPreProcess() const
Definition: ChronFileInterpolator.hpp:210
std::string getInColumnSeparators() const
Definition: ChronFileInterpolator.hpp:125
void setOutDateFormat(const std::string &OutDateFormat)
Definition: ChronFileInterpolator.hpp:185
std::string getInDateFormat() const
Definition: ChronFileInterpolator.hpp:145
static void displayChronSerie(ChronologicalSerie &Data)
Definition: ChronFileInterpolator.hpp:97
openfluid::core::DateTime m_EndDate
Definition: ChronFileInterpolator.hpp:89
std::string getInCommentChar() const
Definition: ChronFileInterpolator.hpp:135
std::string m_InColumnSeparators
Definition: ChronFileInterpolator.hpp:75
Definition: ApplicationException.hpp:47
std::string m_OutColumnSeparator
Definition: ChronFileInterpolator.hpp:83
std::string getOutDateFormat() const
Definition: ChronFileInterpolator.hpp:180
Definition: ChronFileInterpolator.hpp:59
openfluid::core::DateTime m_BeginDate
Definition: ChronFileInterpolator.hpp:87
std::uint64_t Duration_t
Definition: TypeDefs.hpp:186
std::string getOutCommentChar() const
Definition: ChronFileInterpolator.hpp:170
#define OPENFLUID_API
Definition: dllexport.hpp:86
void setInCommentChar(const std::string &InCommentChar)
Definition: ChronFileInterpolator.hpp:140
std::string m_InFilePath
Definition: ChronFileInterpolator.hpp:71
void setInColumnSeparators(const std::string &InColumnSeparators)
Definition: ChronFileInterpolator.hpp:130
Definition: ChronFileInterpolator.hpp:55
std::string getInFilePath() const
Definition: ChronFileInterpolator.hpp:155
std::string m_OutFilePath
Definition: ChronFileInterpolator.hpp:79