tools/ChronFileInterpolator.hpp
Go to the documentation of this file.
00001 /*
00002 
00003   This file is part of OpenFLUID software
00004   Copyright(c) 2007, INRA - Montpellier SupAgro
00005 
00006 
00007  == GNU General Public License Usage ==
00008 
00009   OpenFLUID is free software: you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation, either version 3 of the License, or
00012   (at your option) any later version.
00013 
00014   OpenFLUID is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
00021 
00022 
00023  == Other Usage ==
00024 
00025   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00026   license, and requires a written agreement between You and INRA.
00027   Licensees for Other Usage of OpenFLUID may use this file in accordance
00028   with the terms contained in the written agreement between You and INRA.
00029   
00030 */
00031 
00032 
00033 /**
00034   \file ChronFileInterpolator.hpp
00035   \brief Header of ...
00036 
00037   \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
00038  */
00039 
00040 
00041 #ifndef __CHRONFILEINTERPOLATOR_HPP__
00042 #define __CHRONFILEINTERPOLATOR_HPP__
00043 
00044 #include <list>
00045 #include <iostream>
00046 #include <openfluid/core/DateTime.hpp>
00047 #include <openfluid/tools/ChronologicalSerie.hpp>
00048 #include <openfluid/dllexport.hpp>
00049 
00050 namespace openfluid { namespace tools {
00051 
00052 
00053 class DLLEXPORT ChronFileInterpolator
00054 {
00055   public:
00056 
00057     enum PreProcess { PREPROCESS_NONE, PREPROCESS_CUMULATE };
00058 
00059   private:
00060 
00061     void checkPreload();
00062 
00063     void checkPostload();
00064 
00065   protected:
00066 
00067     std::string m_InFilePath;
00068 
00069     std::string m_InDateFormat;
00070 
00071     std::string m_InColumnSeparators;
00072 
00073     std::string m_InCommentChar;
00074 
00075     std::string m_OutFilePath;
00076 
00077     std::string m_OutDateFormat;
00078 
00079     std::string m_OutColumnSeparator;
00080 
00081     std::string m_OutCommentChar;
00082 
00083     openfluid::core::DateTime m_BeginDate;
00084 
00085     openfluid::core::DateTime m_EndDate;
00086 
00087     openfluid::core::Duration_t m_DeltaT;
00088 
00089     PreProcess m_PreProcess;
00090 
00091     void loadInFile(ChronologicalSerie& Data);
00092 
00093     void displayChronSerie(ChronologicalSerie& Data)
00094     {
00095       ChronologicalSerie::iterator it;
00096       ChronologicalSerie::iterator itb = Data.begin();
00097       ChronologicalSerie::iterator ite = Data.end();
00098 
00099       std::cout << "--------------------------------" << std::endl;
00100       for (it=itb;it!=ite;++it)
00101       {
00102         std::cout << (*it).first.getAsISOString() << " -> " << (*it).second << std::endl;
00103       }
00104       std::cout << "--------------------------------" << std::endl;
00105     }
00106 
00107   public:
00108 
00109 
00110     ChronFileInterpolator(const std::string& InFilePath, const std::string& OutFilePath,
00111                           const openfluid::core::DateTime& BeginDate, const openfluid::core::DateTime& EndDate,
00112                           const openfluid::core::Duration_t& DeltaT, PreProcess PrePcs = PREPROCESS_NONE);
00113 
00114     virtual ~ChronFileInterpolator();
00115 
00116 
00117     virtual void runInterpolation() = 0;
00118 
00119 
00120     std::string getInColumnSeparators() const
00121     {
00122       return m_InColumnSeparators;
00123     }
00124 
00125     void setInColumnSeparators(const std::string& InColumnSeparators)
00126     {
00127       m_InColumnSeparators = InColumnSeparators;
00128     }
00129 
00130     std::string getInCommentChar() const
00131     {
00132       return m_InCommentChar;
00133     }
00134 
00135     void setInCommentChar(const std::string& InCommentChar)
00136     {
00137       m_InCommentChar = InCommentChar;
00138     }
00139 
00140     std::string getInDateFormat() const
00141     {
00142       return m_InDateFormat;
00143     }
00144 
00145     void setInDateFormat(const std::string& InDateFormat)
00146     {
00147       m_InDateFormat = InDateFormat;
00148     }
00149 
00150     std::string getInFilePath() const
00151     {
00152       return m_InFilePath;
00153     }
00154 
00155     std::string getOutColumnSeparator() const
00156     {
00157       return m_OutColumnSeparator;
00158     }
00159 
00160     void setOutColumnSeparator(const std::string& OutColumnSeparator)
00161     {
00162       m_OutColumnSeparator = OutColumnSeparator;
00163     }
00164 
00165     std::string getOutCommentChar() const
00166     {
00167       return m_OutCommentChar;
00168     }
00169 
00170     void setOutCommentChar(const std::string& OutCommentChar)
00171     {
00172       m_OutCommentChar = OutCommentChar;
00173     }
00174 
00175     std::string getOutDateFormat() const
00176     {
00177       return m_OutDateFormat;
00178     }
00179 
00180     void setOutDateFormat(const std::string& OutDateFormat)
00181     {
00182       m_OutDateFormat = OutDateFormat;
00183     }
00184 
00185     std::string getOutFilePath() const
00186     {
00187       return m_OutFilePath;
00188     }
00189 
00190     openfluid::core::DateTime getBeginDate() const
00191     {
00192       return m_BeginDate;
00193     }
00194 
00195     openfluid::core::Duration_t getDeltaT() const
00196     {
00197       return m_DeltaT;
00198     }
00199 
00200     openfluid::core::DateTime getEndDate() const
00201     {
00202       return m_EndDate;
00203     }
00204 
00205     PreProcess getPreProcess() const
00206     {
00207       return m_PreProcess;
00208     }
00209 };
00210 
00211 
00212 } } // namespaces
00213 
00214 
00215 #endif /* __CHRONFILEINTERPOLATOR_HPP__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines