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
00041 #ifndef __SIMULATIONDRIVENWARE_HPP__
00042 #define __SIMULATIONDRIVENWARE_HPP__
00043
00044
00045 #include <openfluid/ware/PluggableWare.hpp>
00046 #include <openfluid/base/SimulationLogger.hpp>
00047 #include <openfluid/base/StdoutFileOStream.hpp>
00048 #include <openfluid/ware/WareException.hpp>
00049 #include <openfluid/base/SimulationStatus.hpp>
00050 #include <openfluid/base/FrameworkException.hpp>
00051 #include <openfluid/dllexport.hpp>
00052
00053
00054 #define REQUIRE_SIMULATION_STAGE(stage,sender,msg) \
00055 if (OPENFLUID_GetCurrentStage() != (stage)) \
00056 throw openfluid::base::FrameworkException(sender,msg);
00057
00058 #define REQUIRE_SIMULATION_STAGE_GE(stage,sender,msg) \
00059 if (OPENFLUID_GetCurrentStage() < (stage)) \
00060 throw openfluid::base::FrameworkException(sender,msg);
00061
00062 #define REQUIRE_SIMULATION_STAGE_LE(stage,sender,msg) \
00063 if (OPENFLUID_GetCurrentStage() > (stage)) \
00064 throw openfluid::base::FrameworkException(sender,msg);
00065
00066
00067 namespace openfluid { namespace ware {
00068
00069
00070 class DLLEXPORT SimulationDrivenWare : public PluggableWare
00071 {
00072 private:
00073
00074 const openfluid::base::SimulationStatus* mp_SimStatus;
00075
00076 openfluid::core::TimeIndex_t m_PreviousTimeIndex;
00077
00078
00079 protected:
00080
00081
00082
00083
00084
00085 openfluid::base::SimulationLogger* mp_SimLogger;
00086
00087
00088 virtual bool isLinked() const { return (PluggableWare::isLinked() && mp_SimLogger != NULL && mp_SimStatus != NULL); };
00089
00090
00091
00092
00093
00094 openfluid::core::DateTime OPENFLUID_GetBeginDate() const;
00095
00096
00097
00098
00099
00100 openfluid::core::DateTime OPENFLUID_GetEndDate() const;
00101
00102
00103
00104
00105
00106 openfluid::core::DateTime OPENFLUID_GetCurrentDate() const;
00107
00108
00109
00110
00111
00112 openfluid::core::Duration_t OPENFLUID_GetSimulationDuration() const;
00113
00114
00115
00116
00117
00118 openfluid::core::Duration_t OPENFLUID_GetDefaultDeltaT() const;
00119
00120
00121
00122
00123
00124
00125 openfluid::core::TimeIndex_t OPENFLUID_GetCurrentTimeIndex() const;
00126
00127
00128
00129
00130
00131 openfluid::core::TimeIndex_t OPENFLUID_GetPreviousRunTimeIndex() const;
00132
00133
00134
00135
00136
00137 openfluid::base::SimulationStatus::SimulationStage OPENFLUID_GetCurrentStage() const;
00138
00139
00140
00141
00142
00143 openfluid::base::SimulationStatus::SchedulingConstraint OPENFLUID_GetSchedulingConstraint() const;
00144
00145
00146
00147
00148
00149 virtual void OPENFLUID_RaiseWarning(const std::string& Msg);
00150
00151
00152
00153
00154
00155
00156 virtual void OPENFLUID_RaiseWarning(const std::string& Source, const std::string& Msg);
00157
00158
00159
00160
00161
00162 virtual void OPENFLUID_RaiseError(const std::string& Msg);
00163
00164
00165
00166
00167
00168
00169 virtual void OPENFLUID_RaiseError(const std::string& Source, const std::string& Msg);
00170
00171 openfluid::base::StdoutAndFileOutputStream OPENFLUID_Logger;
00172
00173 SimulationDrivenWare(WareType WType) : PluggableWare(WType),
00174 mp_SimStatus(NULL), m_PreviousTimeIndex(0), mp_SimLogger(NULL) { };
00175
00176
00177 public:
00178
00179 virtual ~SimulationDrivenWare()
00180 { };
00181
00182 void linkToSimulation(const openfluid::base::SimulationStatus* SimStatus);
00183
00184 void linkToSimulationLogger(openfluid::base::SimulationLogger* SimLogger)
00185 {
00186 mp_SimLogger = SimLogger;
00187 };
00188
00189 void initializeWare(const WareID_t& ID);
00190
00191 void finalizeWare();
00192
00193 void setPreviousTimeIndex(const openfluid::core::TimeIndex_t& TimeIndex) { m_PreviousTimeIndex = TimeIndex; };
00194
00195 };
00196
00197
00198
00199 } }
00200
00201
00202
00203 #endif