00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00055 #ifndef __RUNTIMEENV_HPP__
00056 #define __RUNTIMEENV_HPP__
00057
00058
00059 #include <openfluid/dllexport.hpp>
00060 #include <openfluid/tools.hpp>
00061 #include <openfluid/base/EnvProperties.hpp>
00062
00063
00064 #include <boost/filesystem/path.hpp>
00065 #include <boost/date_time/posix_time/posix_time.hpp>
00066
00067
00068 namespace openfluid { namespace base {
00069
00070
00071
00072
00073
00074
00078 class DLLEXPORT RuntimeEnvironment
00079 {
00080 private:
00081
00082 static RuntimeEnvironment* mp_Singleton;
00083
00084 std::string m_OutputDir;
00085 std::string m_InputDir;
00086 std::string m_UserDataDir;
00087 std::string m_TempDir;
00088
00089 std::vector<std::string> m_PlugsDirs;
00090
00091 std::string m_UserID;
00092
00093 std::string m_HostName;
00094
00095 bool m_ClearOutputDir;
00096
00097 bool m_WriteResults;
00098
00099 bool m_WriteSimReport;
00100
00101 unsigned int m_ValuesBufferSize;
00102
00103 bool m_IsUserValuesBufferSize;
00104
00105 unsigned int m_FilesBufferSize;
00106
00107 openfluid::base::EnvironmentProperties* mp_FuncEnv;
00108
00109 openfluid::base::EnvironmentProperties m_ExtraProperties;
00110
00111 boost::posix_time::ptime m_IgnitionDateTime;
00112
00113 std::string m_SimulationID;
00114
00115 boost::posix_time::time_duration m_EffectiveSimulationDuration;
00116
00117 openfluid::core::DateTime m_StartTime;
00118
00119 openfluid::core::DateTime m_EndTime;
00120
00121
00122 int m_TimeStep;
00123
00127 RuntimeEnvironment();
00128
00129 public:
00130
00131 static RuntimeEnvironment* getInstance();
00132
00136 ~RuntimeEnvironment();
00137
00138 void setInputDir(const std::string InputDir)
00139 { m_InputDir = InputDir; mp_FuncEnv->setValue("dir.input",m_InputDir); };
00140
00141 inline std::string getInputDir() const { return m_InputDir; };
00142
00143 void setOutputDir(const std::string OutputDir)
00144 { m_OutputDir = OutputDir; mp_FuncEnv->setValue("dir.output",m_OutputDir); };
00145
00146 std::string getOutputDir() const { return m_OutputDir; };
00147
00148 void setDateTimeOutputDir();
00149
00150 inline std::string getTempDir() const
00151 { return m_TempDir; mp_FuncEnv->setValue("dir.temp",m_OutputDir); };
00152
00153 std::string getInputFullPath(std::string Filename) const
00154 { return boost::filesystem::path(m_InputDir + "/" + Filename).string(); };
00155
00156 inline std::string getOutputFullPath(std::string Filename) const
00157 { return boost::filesystem::path(m_OutputDir + "/" + Filename).string(); };
00158
00159 std::string getPluginFullPath(std::string Filename);
00160
00161 void addExtraPluginsPaths(std::string SemicolonSeparatedPaths);
00162
00163 inline std::vector<std::string> getPluginsPaths() const { return m_PlugsDirs; };
00164
00165 inline openfluid::base::EnvironmentProperties& getExtraProperties()
00166 { return m_ExtraProperties; };
00167
00168 inline bool isClearOutputDir() const { return m_ClearOutputDir; };
00169
00170 inline void setClearOutputDir(bool ClearDir)
00171 { m_ClearOutputDir = ClearDir; mp_FuncEnv->setValue("mode.clearoutputdir",m_ClearOutputDir); };
00172
00173 inline bool isWriteResults() const
00174 { return m_WriteResults; };
00175
00176 void setWriteResults(bool WriteIt)
00177 { m_WriteResults = WriteIt; mp_FuncEnv->setValue("mode.saveresults",m_WriteResults); };
00178
00179 inline bool isWriteSimReport() const { return m_WriteSimReport; };
00180
00181 void setWriteSimReport(bool WriteIt)
00182 { m_WriteSimReport = WriteIt; mp_FuncEnv->setValue("mode.writereport",m_WriteSimReport); };
00183
00184 openfluid::base::EnvironmentProperties* getFunctionEnvironment() const
00185 { return mp_FuncEnv; };
00186
00187
00188 boost::posix_time::ptime getIgnitionDateTime() const
00189 { return m_IgnitionDateTime; };
00190
00191 inline std::string getSimulationID() const {return m_SimulationID; };
00192
00193 void setSimulationID(const std::string SimID) { m_SimulationID = SimID; };
00194
00195 boost::posix_time::time_duration getEffectiveSimulationDuration() const
00196 { return m_EffectiveSimulationDuration; };
00197
00198 void setEffectiveSimulationDuration(const boost::posix_time::time_duration& TimeDuration)
00199 { m_EffectiveSimulationDuration = TimeDuration; };
00200
00201 std::string getHostName() const {return m_HostName; };
00202
00203 std::string getUserID() const {return m_UserID; };
00204
00205 void setSimulationTimeInformation(openfluid::core::DateTime StartTime,
00206 openfluid::core::DateTime EndTime,
00207 int TimeStep);
00208
00209 openfluid::core::DateTime getSimulationStartTime() const
00210 { return m_StartTime; };
00211
00212 openfluid::core::DateTime getSimulationEndTime() const
00213 { return m_EndTime; };
00214
00215
00216 int getSimulationTimeStep() const
00217 { return m_TimeStep; };
00218
00219 void setValuesBufferSize(const unsigned int StepsNbr)
00220 {m_ValuesBufferSize = StepsNbr; m_IsUserValuesBufferSize = true;};
00221
00222 inline unsigned int getValuesBufferSize() const
00223 { return m_ValuesBufferSize; };
00224
00225 bool isUserValuesBufferSize() const { return m_IsUserValuesBufferSize; };
00226
00227 void setFilesBufferSize(const unsigned int Bytes)
00228 {m_FilesBufferSize = Bytes; };
00229
00230 inline unsigned int getFilesBufferSize() const
00231 { return m_FilesBufferSize; };
00232
00233 };
00234
00235
00236 } }
00237
00238 #endif
00239
00240
00241