Go to the documentation of this file.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 #ifndef __RUNTIMEENV_HPP__
00041 #define __RUNTIMEENV_HPP__
00042
00043 #include <string>
00044 #include <boost/date_time/posix_time/posix_time.hpp>
00045 #include <boost/filesystem/path.hpp>
00046
00047 #include <openfluid/dllexport.hpp>
00048 #include <openfluid/base/EnvProperties.hpp>
00049 #include <openfluid/core/DateTime.hpp>
00050
00051
00052
00053 namespace openfluid { namespace base {
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 class DLLEXPORT RuntimeEnvironment
00064 {
00065 private:
00066
00067 static RuntimeEnvironment* mp_Singleton;
00068
00069 std::string m_Version;
00070 std::string m_FullVersion;
00071 std::string m_MajorMinorVersion;
00072
00073 std::string m_OutputDir;
00074 std::string m_InputDir;
00075 std::string m_UserDataDir;
00076 std::string m_TempDir;
00077 std::string m_HomeDir;
00078 std::string m_MarketBagDir;
00079 std::string m_MarketBagVersionDir;
00080
00081 std::string m_MarketBagSimVersionDir;
00082 std::string m_MarketBagObsVersionDir;
00083 std::string m_MarketBagBuildVersionDir;
00084 std::string m_MarketBagDataVersionDir;
00085 std::string m_MarketBagBinSubDir;
00086 std::string m_MarketBagSrcSubDir;
00087
00088 std::string m_InstallPrefix;
00089
00090 std::vector<std::string> m_DefaultSimulatorsPlugsDirs;
00091 std::vector<std::string> m_ExtraSimulatorsPlugsDirs;
00092
00093 std::vector<std::string> m_DefaultObserversPlugsDirs;
00094 std::vector<std::string> m_ExtraObserversPlugsDirs;
00095
00096
00097 std::string m_ProvidedExamplesDir;
00098 std::string m_UserExamplesDir;
00099
00100 std::string m_UserID;
00101 std::string m_HostName;
00102 std::string m_Arch;
00103
00104 unsigned int m_SimulatorsMaxNumThreads;
00105
00106 std::string m_DefaultConfigFilePath;
00107
00108 bool m_ClearOutputDir;
00109
00110 bool m_WriteResults;
00111
00112 bool m_WriteSimReport;
00113
00114 bool m_Profiling;
00115
00116 unsigned int m_ValuesBufferSize;
00117
00118 bool m_IsUserValuesBufferSize;
00119
00120 openfluid::base::EnvironmentProperties* mp_WareEnv;
00121
00122 openfluid::base::EnvironmentProperties m_ExtraProperties;
00123
00124 boost::posix_time::ptime m_IgnitionDateTime;
00125
00126 boost::posix_time::time_duration m_EffectiveSimulationDuration;
00127
00128 openfluid::core::DateTime m_StartTime;
00129
00130 openfluid::core::DateTime m_EndTime;
00131
00132
00133 int m_TimeStep;
00134
00135 bool m_IsLinkedToProject;
00136
00137
00138
00139
00140
00141 RuntimeEnvironment();
00142
00143 public:
00144
00145 static RuntimeEnvironment* getInstance();
00146
00147
00148
00149
00150 ~RuntimeEnvironment();
00151
00152
00153
00154
00155
00156
00157 std::string getVersion() const { return m_Version; };
00158
00159
00160
00161
00162
00163 std::string getFullVersion() const { return m_FullVersion; };
00164
00165
00166
00167
00168
00169 std::string getMajorMinorVersion() const { return m_MajorMinorVersion; };
00170
00171
00172
00173
00174
00175
00176
00177 void setInputDir(const std::string InputDir)
00178 { m_InputDir = InputDir; mp_WareEnv->setValue("dir.input",m_InputDir); };
00179
00180
00181
00182
00183
00184 inline std::string getInputDir() const { return m_InputDir; };
00185
00186
00187
00188
00189
00190 void setOutputDir(const std::string OutputDir)
00191 { m_OutputDir = OutputDir; mp_WareEnv->setValue("dir.output",m_OutputDir); };
00192
00193
00194
00195
00196
00197 inline std::string getOutputDir() const { return m_OutputDir; };
00198
00199
00200
00201
00202 void setDateTimeOutputDir();
00203
00204
00205
00206
00207
00208 inline std::string getMarketBagDir() const { return m_MarketBagDir; };
00209
00210
00211
00212
00213 inline std::string getMarketBagVersionDir() const { return m_MarketBagVersionDir; };
00214
00215
00216
00217
00218 inline std::string getMarketBagSimVersionDir() const { return m_MarketBagSimVersionDir; };
00219
00220
00221
00222
00223 inline std::string getMarketBagObsVersionDir() const { return m_MarketBagObsVersionDir; };
00224
00225
00226
00227
00228 inline std::string getMarketBagBuildVersionDir() const { return m_MarketBagBuildVersionDir; };
00229
00230
00231
00232
00233 inline std::string getMarketBagDataVersionDir() const { return m_MarketBagDataVersionDir; };
00234
00235
00236
00237
00238 inline std::string getMarketBagBinSubDir() const { return m_MarketBagBinSubDir; };
00239
00240
00241
00242
00243 inline std::string getMarketBagSrcSubDir() const { return m_MarketBagSrcSubDir; };
00244
00245
00246
00247
00248
00249 inline std::string getDefaultConfigFile() const
00250 { return m_DefaultConfigFilePath; };
00251
00252
00253
00254
00255
00256
00257 std::string getConfigFilePath(std::string Filename) const
00258 { return boost::filesystem::path(m_UserDataDir + "/" + Filename).string(); };
00259
00260
00261
00262
00263
00264
00265 std::string getUserHomeDir() const
00266 { return m_HomeDir; };
00267
00268
00269
00270
00271
00272
00273 std::string getUserDataPath(std::string RelativePath) const
00274 { return boost::filesystem::path(m_UserDataDir + "/" + RelativePath).string(); };
00275
00276
00277
00278
00279
00280 inline std::string getTempDir() const
00281 { return m_TempDir; };
00282
00283
00284
00285
00286
00287
00288 std::string getInputFullPath(std::string Filename) const
00289 { return boost::filesystem::path(m_InputDir + "/" + Filename).string(); };
00290
00291
00292
00293
00294
00295
00296 inline std::string getOutputFullPath(std::string Filename) const
00297 { return boost::filesystem::path(m_OutputDir + "/" + Filename).string(); };
00298
00299
00300
00301
00302
00303
00304 std::string getSimulatorPluginFullPath(std::string Filename);
00305
00306
00307
00308
00309
00310
00311 void addExtraSimulatorsPluginsPaths(std::string SemicolonSeparatedPaths);
00312
00313 inline void resetExtraSimulatorsPluginsPaths() { m_ExtraSimulatorsPlugsDirs.clear(); };
00314
00315 inline std::vector<std::string> getDefaultSimulatorsPluginsPaths() const { return m_DefaultSimulatorsPlugsDirs; };
00316
00317 inline std::vector<std::string> getExtraSimulatorsPluginsPaths() const { return m_ExtraSimulatorsPlugsDirs; };
00318
00319
00320
00321
00322
00323 inline std::vector<std::string> getSimulatorsPluginsPaths() const
00324 {
00325 std::vector<std::string> ComposedPaths(m_ExtraSimulatorsPlugsDirs);
00326 ComposedPaths.insert(ComposedPaths.end(), m_DefaultSimulatorsPlugsDirs.begin(), m_DefaultSimulatorsPlugsDirs.end());
00327 return ComposedPaths;
00328 };
00329
00330
00331
00332
00333
00334
00335 std::string getObserverPluginFullPath(std::string Filename);
00336
00337
00338
00339
00340
00341
00342 void addExtraObserversPluginsPaths(std::string SemicolonSeparatedPaths);
00343
00344 inline void resetExtraObserversPluginsPaths() { m_ExtraObserversPlugsDirs.clear(); };
00345
00346 inline std::vector<std::string> getDefaultObserversPluginsPaths() const { return m_DefaultObserversPlugsDirs; };
00347
00348 inline std::vector<std::string> getExtraObserversPluginsPaths() const { return m_ExtraObserversPlugsDirs; };
00349
00350
00351
00352
00353
00354 inline std::vector<std::string> getObserversPluginsPaths() const
00355 {
00356 std::vector<std::string> ComposedPaths(m_ExtraObserversPlugsDirs);
00357 ComposedPaths.insert(ComposedPaths.end(), m_DefaultObserversPlugsDirs.begin(), m_DefaultObserversPlugsDirs.end());
00358 return ComposedPaths;
00359 };
00360
00361
00362
00363
00364
00365
00366
00367
00368 inline std::string getInstallPrefix() const
00369 { return m_InstallPrefix; };
00370
00371
00372
00373
00374
00375 std::string getCommonResourcesDir() const;
00376
00377
00378
00379
00380
00381
00382 std::string getCommonResourceFilePath(std::string RelativeFilePath) const;
00383
00384
00385
00386
00387
00388
00389 std::string getAppResourcesDir(std::string AppName) const;
00390
00391
00392
00393
00394
00395
00396
00397 std::string getAppResourceFilePath(std::string AppName, std::string RelativeFilePath) const;
00398
00399
00400
00401
00402
00403 std::string getTranslationsDir() const;
00404
00405
00406
00407
00408
00409 std::string getProvidedExamplesDir() const { return m_ProvidedExamplesDir; };
00410
00411
00412
00413
00414
00415
00416 std::string getUserExamplesDir() const { return m_UserExamplesDir; };
00417
00418
00419
00420
00421
00422
00423 inline openfluid::base::EnvironmentProperties& getExtraProperties()
00424 { return m_ExtraProperties; };
00425
00426
00427
00428
00429 inline bool isClearOutputDir() const { return m_ClearOutputDir; };
00430
00431
00432
00433
00434
00435 inline void setClearOutputDir(bool ClearDir)
00436 { m_ClearOutputDir = ClearDir; mp_WareEnv->setValue("mode.clearoutputdir",m_ClearOutputDir); };
00437
00438
00439
00440
00441
00442 inline bool isWriteResults() const
00443 { return m_WriteResults; };
00444
00445
00446
00447
00448
00449 void setWriteResults(bool WriteIt)
00450 { m_WriteResults = WriteIt; mp_WareEnv->setValue("mode.saveresults",m_WriteResults); };
00451
00452
00453
00454
00455
00456 inline bool isWriteSimReport() const { return m_WriteSimReport; };
00457
00458
00459
00460
00461
00462 void setWriteSimReport(bool WriteIt)
00463 { m_WriteSimReport = WriteIt; mp_WareEnv->setValue("mode.writereport",m_WriteSimReport); };
00464
00465 openfluid::base::EnvironmentProperties* getWareEnvironment() const
00466 { return mp_WareEnv; };
00467
00468
00469 boost::posix_time::ptime getIgnitionDateTime() const
00470 { return m_IgnitionDateTime; };
00471
00472
00473 void resetIgnitionDateTime();
00474
00475
00476 boost::posix_time::time_duration getEffectiveSimulationDuration() const
00477 { return m_EffectiveSimulationDuration; };
00478
00479
00480 void setEffectiveSimulationDuration(const boost::posix_time::time_duration& TimeDuration)
00481 { m_EffectiveSimulationDuration = TimeDuration; };
00482
00483
00484
00485
00486
00487 std::string getHostName() const {return m_HostName; };
00488
00489
00490
00491
00492
00493 std::string getUserID() const {return m_UserID; };
00494
00495
00496
00497
00498
00499 std::string getArch() const {return m_Arch; };
00500
00501 unsigned int getSimulatorsMaxNumThreads() const { return m_SimulatorsMaxNumThreads; };
00502
00503 void setSimulatorsMaxNumThreads(const unsigned int& MaxNumThreads)
00504 { if (MaxNumThreads > 0) m_SimulatorsMaxNumThreads = MaxNumThreads; };
00505
00506
00507 void setSimulationTimeInformation(openfluid::core::DateTime StartTime,
00508 openfluid::core::DateTime EndTime,
00509 int TimeStep);
00510
00511 openfluid::core::DateTime getSimulationStartTime() const
00512 { return m_StartTime; };
00513
00514 openfluid::core::DateTime getSimulationEndTime() const
00515 { return m_EndTime; };
00516
00517
00518 int getSimulationTimeStep() const
00519 { return m_TimeStep; };
00520
00521 void setValuesBufferSize(const unsigned int StepsNbr)
00522 { m_ValuesBufferSize = StepsNbr; m_IsUserValuesBufferSize = true; };
00523
00524 inline unsigned int getValuesBufferSize() const
00525 { return m_ValuesBufferSize; };
00526
00527 bool isUserValuesBufferSize() const { return m_IsUserValuesBufferSize; };
00528
00529 inline void unsetUserValuesBufferSize()
00530 { m_IsUserValuesBufferSize = false; }
00531
00532 void linkToProject();
00533
00534 void detachFromProject();
00535
00536 bool isLinkedToProject()
00537 { return m_IsLinkedToProject; };
00538
00539 bool isSimulationProfilingEnabled() const { return m_Profiling; };
00540
00541 void setSimulationProfilingEnabled(bool Profiling) { m_Profiling = Profiling; };
00542
00543 };
00544
00545
00546 } }
00547
00548 #endif
00549
00550
00551