PulseScenarioExec.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5
6#include "engine/CommonDefs.h"
7#include "engine/PulseScenario.h"
8#include "cdm/scenario/SEScenarioExec.h"
9#include <thread>
10
14class PULSE_DECL PulseScenarioExec : public SEScenarioExec
15{
16
17public:
18 PulseScenarioExec(Logger* logger) : SEScenarioExec(logger) { Clear(); }
19
20 void Clear() override;
21 void Copy(const PulseScenarioExec& src);
22
23 eModelType GetModelType() const { return m_ModelType; }
24 void SetModelType(eModelType mt) { m_ModelType = mt; }
25
26 bool SerializeToString(std::string& output, eSerializationFormat m, Logger* logger = nullptr) const;
27 bool SerializeFromString(const std::string& src, eSerializationFormat m, Logger* logger = nullptr);
28
29 bool Execute();
30
31protected:
32 size_t ComputeNumThreads();
33 bool Execute(PulseScenario& sce, SEScenarioExecStatus* status=nullptr);
34 bool ConvertLog();
35
36 // For threaded scenario excution
37 static void ControllerLoop(const std::string copy,
38 std::mutex* m,
39 std::vector<SEScenarioExecStatus>* s,
40 size_t* completed,
41 const std::string fn,
42 Logger* logger);
43
44 std::vector<std::thread> m_Threads;
45 std::mutex m_Mutex;
46 std::vector<SEScenarioExecStatus> m_Statuses;
48
49 eModelType m_ModelType = eModelType::HumanAdultWholeBody;
50};
Definition: Logger.h:71
Create a Pulse engine and execute the scenario opts.
Definition: PulseScenarioExec.h:15
size_t m_Completed
Definition: PulseScenarioExec.h:47
PulseScenarioExec(Logger *logger)
Definition: PulseScenarioExec.h:18
eModelType GetModelType() const
Definition: PulseScenarioExec.h:23
std::vector< std::thread > m_Threads
Definition: PulseScenarioExec.h:44
std::mutex m_Mutex
Definition: PulseScenarioExec.h:45
void SetModelType(eModelType mt)
Definition: PulseScenarioExec.h:24
std::vector< SEScenarioExecStatus > m_Statuses
Definition: PulseScenarioExec.h:46
A Pulse specific scenario (i.e. holds a Pulse configuration object)
Definition: PulseScenario.h:15
Definition: SEScenarioExec.h:20
bool SerializeToString(std::string &output, eSerializationFormat m) const
Definition: SEScenarioExec.cpp:83
void Copy(const SEScenarioExec &src)
Definition: SEScenarioExec.cpp:78
virtual void Clear()
Definition: SEScenarioExec.cpp:36
bool SerializeFromString(const std::string &src, eSerializationFormat m)
Definition: SEScenarioExec.cpp:87
bool ConvertLog()
Definition: SEScenarioExec.cpp:502
bool Execute(PhysiologyEngine &pe, SEScenario &sce, SEScenarioExecStatus *status=nullptr)
Definition: SEScenarioExec.cpp:103
Definition: SEScenarioExec.h:220

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.