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@supagro.inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_TOOLS_CHRONFILEINTERPOLATOR_HPP__
41 #define __OPENFLUID_TOOLS_CHRONFILEINTERPOLATOR_HPP__
42 
43 #include <list>
44 #include <iostream>
47 #include <openfluid/dllexport.hpp>
48 
49 namespace openfluid { namespace tools {
50 
51 
53 {
54  public:
55 
56  enum PreProcess { PREPROCESS_NONE, PREPROCESS_CUMULATE };
57 
58 
59  private:
60 
61  void checkPreload();
62 
63  void checkPostload();
64 
65 
66  protected:
67 
68  std::string m_InFilePath;
69 
70  std::string m_InDateFormat;
71 
72  std::string m_InColumnSeparators;
73 
74  std::string m_InCommentChar;
75 
76  std::string m_OutFilePath;
77 
78  std::string m_OutDateFormat;
79 
80  std::string m_OutColumnSeparator;
81 
82  std::string m_OutCommentChar;
83 
85 
87 
89 
91 
92  void loadInFile(ChronologicalSerie& Data);
93 
95  {
96  ChronologicalSerie::iterator it;
97  ChronologicalSerie::iterator itb = Data.begin();
98  ChronologicalSerie::iterator ite = Data.end();
99 
100  std::cout << "--------------------------------" << std::endl;
101  for (it=itb;it!=ite;++it)
102  {
103  std::cout << (*it).first.getAsISOString() << " -> " << (*it).second << std::endl;
104  }
105  std::cout << "--------------------------------" << std::endl;
106  }
107 
108 
109  public:
110 
111 
112  ChronFileInterpolator(const std::string& InFilePath, const std::string& OutFilePath,
113  const openfluid::core::DateTime& BeginDate, const openfluid::core::DateTime& EndDate,
114  const openfluid::core::Duration_t& DeltaT, PreProcess PrePcs = PREPROCESS_NONE);
115 
116  virtual ~ChronFileInterpolator();
117 
118 
119  virtual void runInterpolation() = 0;
120 
121 
122  std::string getInColumnSeparators() const
123  {
124  return m_InColumnSeparators;
125  }
126 
127  void setInColumnSeparators(const std::string& InColumnSeparators)
128  {
129  m_InColumnSeparators = InColumnSeparators;
130  }
131 
132  std::string getInCommentChar() const
133  {
134  return m_InCommentChar;
135  }
136 
137  void setInCommentChar(const std::string& InCommentChar)
138  {
139  m_InCommentChar = InCommentChar;
140  }
141 
142  std::string getInDateFormat() const
143  {
144  return m_InDateFormat;
145  }
146 
147  void setInDateFormat(const std::string& InDateFormat)
148  {
149  m_InDateFormat = InDateFormat;
150  }
151 
152  std::string getInFilePath() const
153  {
154  return m_InFilePath;
155  }
156 
157  std::string getOutColumnSeparator() const
158  {
159  return m_OutColumnSeparator;
160  }
161 
162  void setOutColumnSeparator(const std::string& OutColumnSeparator)
163  {
164  m_OutColumnSeparator = OutColumnSeparator;
165  }
166 
167  std::string getOutCommentChar() const
168  {
169  return m_OutCommentChar;
170  }
171 
172  void setOutCommentChar(const std::string& OutCommentChar)
173  {
174  m_OutCommentChar = OutCommentChar;
175  }
176 
177  std::string getOutDateFormat() const
178  {
179  return m_OutDateFormat;
180  }
181 
182  void setOutDateFormat(const std::string& OutDateFormat)
183  {
184  m_OutDateFormat = OutDateFormat;
185  }
186 
187  std::string getOutFilePath() const
188  {
189  return m_OutFilePath;
190  }
191 
193  {
194  return m_BeginDate;
195  }
196 
198  {
199  return m_DeltaT;
200  }
201 
203  {
204  return m_EndDate;
205  }
206 
208  {
209  return m_PreProcess;
210  }
211 };
212 
213 
214 } } // namespaces
215 
216 
217 #endif /* __OPENFLUID_TOOLS_CHRONFILEINTERPOLATOR_HPP__ */
PreProcess getPreProcess() const
Definition: ChronFileInterpolator.hpp:207
unsigned long long Duration_t
Definition: DateTime.hpp:68
openfluid::core::DateTime getBeginDate() const
Definition: ChronFileInterpolator.hpp:192
std::string m_InFilePath
Definition: ChronFileInterpolator.hpp:68
Definition: ChronFileInterpolator.hpp:52
void setOutDateFormat(const std::string &OutDateFormat)
Definition: ChronFileInterpolator.hpp:182
std::string getInColumnSeparators() const
Definition: ChronFileInterpolator.hpp:122
std::string getOutColumnSeparator() const
Definition: ChronFileInterpolator.hpp:157
PreProcess
Definition: ChronFileInterpolator.hpp:56
std::string m_OutCommentChar
Definition: ChronFileInterpolator.hpp:82
std::string m_InCommentChar
Definition: ChronFileInterpolator.hpp:74
void setOutColumnSeparator(const std::string &OutColumnSeparator)
Definition: ChronFileInterpolator.hpp:162
void setInColumnSeparators(const std::string &InColumnSeparators)
Definition: ChronFileInterpolator.hpp:127
Definition: ChronFileInterpolator.hpp:56
openfluid::core::DateTime m_EndDate
Definition: ChronFileInterpolator.hpp:86
void setInCommentChar(const std::string &InCommentChar)
Definition: ChronFileInterpolator.hpp:137
static void displayChronSerie(ChronologicalSerie &Data)
Definition: ChronFileInterpolator.hpp:94
std::string m_InColumnSeparators
Definition: ChronFileInterpolator.hpp:72
std::string getInDateFormat() const
Definition: ChronFileInterpolator.hpp:142
std::string m_InDateFormat
Definition: ChronFileInterpolator.hpp:70
Definition: ChronologicalSerie.hpp:59
std::string getOutFilePath() const
Definition: ChronFileInterpolator.hpp:187
PreProcess m_PreProcess
Definition: ChronFileInterpolator.hpp:90
void setOutCommentChar(const std::string &OutCommentChar)
Definition: ChronFileInterpolator.hpp:172
std::string m_OutFilePath
Definition: ChronFileInterpolator.hpp:76
std::string m_OutDateFormat
Definition: ChronFileInterpolator.hpp:78
void setInDateFormat(const std::string &InDateFormat)
Definition: ChronFileInterpolator.hpp:147
openfluid::core::DateTime getEndDate() const
Definition: ChronFileInterpolator.hpp:202
std::string getInFilePath() const
Definition: ChronFileInterpolator.hpp:152
Definition: ApplicationException.hpp:47
std::string getOutCommentChar() const
Definition: ChronFileInterpolator.hpp:167
std::string getInCommentChar() const
Definition: ChronFileInterpolator.hpp:132
openfluid::core::Duration_t getDeltaT() const
Definition: ChronFileInterpolator.hpp:197
std::string getOutDateFormat() const
Definition: ChronFileInterpolator.hpp:177
#define OPENFLUID_API
Definition: dllexport.hpp:87
std::string m_OutColumnSeparator
Definition: ChronFileInterpolator.hpp:80
openfluid::core::Duration_t m_DeltaT
Definition: ChronFileInterpolator.hpp:88
Class for management of date and time information.
Definition: DateTime.hpp:132
openfluid::core::DateTime m_BeginDate
Definition: ChronFileInterpolator.hpp:84