1414#include " VCellCVodeSolver.h"
1515#include " VCellIDASolver.h"
1616#ifdef USE_MESSAGING
17- static void loadJMSInfo (std::istream &ifsInput, int taskID);
17+ # include < VCELL/SimulationMessaging.h >
1818#endif
1919// Forward Declarations
2020static void readDiscontinuities (std::istream &inputStream, VCellSolverInputBreakdown& inputBreakdown);
@@ -54,12 +54,7 @@ VCellSolverInputBreakdown VCellSolverFactory::parseInputFile(std::ifstream& inpu
5454 inputFileStream >> nextToken;
5555 if (nextToken.empty ()) continue ;
5656 if (nextToken[0 ] == ' #' ) std::getline (inputFileStream, nextToken);
57- else if (nextToken == " JMS_PARAM_BEGIN" ) {
58- #ifdef USE_MESSAGING
59- loadJMSInfo (inputFileStream, taskID);
60- SimulationMessaging::getInstVar ()->start (); // start the thread
61- #endif
62- } else if (nextToken == " SOLVER" ) {
57+ else if (nextToken == " SOLVER" ) {
6358 std::string solverName;
6459 inputFileStream >> solverName;
6560 inputBreakdown.solverType = determineSolverType (solverName);
@@ -112,10 +107,13 @@ VCellSolverInputBreakdown VCellSolverFactory::parseInputFile(std::ifstream& inpu
112107}
113108
114109VCellSolverTypes VCellSolverFactory::determineSolverType (const std::string& solverName){
115- if (solverName == " CVODE" ) return VCellSolverTypes::CVODE;
116- if (solverName == " IDA" ) return VCellSolverTypes::IDA;
117- if (solverName == " CSSS" ) return VCellSolverTypes::STEADY_STATE; // copasi-style steady-state
118- throw new std::runtime_error (" Unknown solver type: `" + solverName + " `" );
110+ if (solverName == " CVODE" )
111+ return VCellSolverTypes::CVODE;
112+ if (solverName == " IDA" )
113+ return VCellSolverTypes::IDA;
114+ if (solverName == " CSSS" )
115+ return VCellSolverTypes::STEADY_STATE; // copasi-style steady-state
116+ throw std::runtime_error (" Unknown solver type: `" + solverName + " `" );
119117}
120118
121119void VCellSolverFactory::processEquations (std::ifstream& inputFileStream, VCellSolverInputBreakdown& inputBreakdown) {
@@ -127,51 +125,6 @@ void VCellSolverFactory::processEquations(std::ifstream& inputFileStream, VCellS
127125 * Local Helper Functions
128126 * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
129127
130- #ifdef USE_MESSAGING
131- static void loadJMSInfo (std::istream &ifsInput, int taskID) {
132- if (taskID < 0 ) {
133- SimulationMessaging::create ();
134- return ; // No need to do any parsing
135- }
136- std::string broker;
137- std::string smqUserName;
138- std::string password;
139- std::string qName;
140- std::string topicName;
141- std::string vCellUsername;
142- int simKey, jobIndex;
143-
144- while (!ifsInput.eof ()) {
145- std::string nextToken;
146- ifsInput >> nextToken;
147- if (nextToken.empty ()) continue ;
148- if (nextToken[0 ] == ' #' ) {
149- // std::getline(ifsInput, nextToken); // Is this ignoring because of a comment?
150- ifsInput.ignore (' \n ' );
151- continue ;
152- }
153- if (nextToken == " JMS_PARAM_END" ) { ifsInput.ignore (EOF); } else if (
154- nextToken == " JMS_BROKER" ) { ifsInput >> broker; } else if (
155- nextToken == " JMS_USER" ) { ifsInput >> smqUserName >> password; } else if (
156- nextToken == " JMS_QUEUE" ) { ifsInput >> qName; } else if (
157- nextToken == " JMS_TOPIC" ) { ifsInput >> topicName; } else if (nextToken == " VCELL_USER" ) {
158- ifsInput >> vCellUsername;
159- } else if (nextToken == " SIMULATION_KEY" ) {
160- ifsInput >> simKey;
161- continue ;
162- } else if (nextToken == " JOB_INDEX" ) {
163- ifsInput >> jobIndex;
164- continue ;
165- }
166- }
167-
168- SimulationMessaging::create (broker.c_str (), smqUserName.c_str (),
169- password.c_str (), qName.c_str (), topicName.c_str (),
170- vCellUsername.c_str (), simKey, jobIndex, taskID);
171-
172- }
173- #endif
174-
175128static void readDiscontinuities (std::istream &inputStream, VCellSolverInputBreakdown& inputBreakdown) {
176129 VCellSolverInputBreakdown::DiscontinuityComponents discontinuityComponents;
177130 std::size_t numOfDiscontinuities;
@@ -483,7 +436,10 @@ static void loadJMSInfo(std::istream &ifsInput, int taskID) {
483436 std::string vCellUsername;
484437 int simKey, jobIndex;
485438
486- while (!ifsInput.eof ()) {
439+ while (true ) {
440+ if (ifsInput.eof ())
441+ throw std::runtime_error (" VCellSolverFactory::loadJMSInfo() reached end of file, but no `JMS_PARAM_END` reached!" );
442+
487443 std::string nextToken;
488444 ifsInput >> nextToken;
489445 if (nextToken.empty ()) continue ;
@@ -492,19 +448,15 @@ static void loadJMSInfo(std::istream &ifsInput, int taskID) {
492448 ifsInput.ignore (' \n ' );
493449 continue ;
494450 }
495- if (nextToken == " JMS_PARAM_END" ) { ifsInput.ignore (EOF); } else if (
496- nextToken == " JMS_BROKER" ) { ifsInput >> broker; } else if (
497- nextToken == " JMS_USER" ) { ifsInput >> smqUserName >> password; } else if (
498- nextToken == " JMS_QUEUE" ) { ifsInput >> qName; } else if (
499- nextToken == " JMS_TOPIC" ) { ifsInput >> topicName; } else if (nextToken == " VCELL_USER" ) {
500- ifsInput >> vCellUsername;
501- } else if (nextToken == " SIMULATION_KEY" ) {
502- ifsInput >> simKey;
503- continue ;
504- } else if (nextToken == " JOB_INDEX" ) {
505- ifsInput >> jobIndex;
506- continue ;
507- }
451+ if (nextToken == " JMS_PARAM_END" ) break ; // Non-error stop condition
452+
453+ if (nextToken == " JMS_BROKER" ) ifsInput >> broker;
454+ else if (nextToken == " JMS_USER" ) ifsInput >> smqUserName >> password;
455+ else if (nextToken == " JMS_QUEUE" ) ifsInput >> qName;
456+ else if (nextToken == " JMS_TOPIC" ) ifsInput >> topicName;
457+ else if (nextToken == " VCELL_USER" ) ifsInput >> vCellUsername;
458+ else if (nextToken == " SIMULATION_KEY" ) ifsInput >> simKey;
459+ else if (nextToken == " JOB_INDEX" ) ifsInput >> jobIndex;
508460 }
509461
510462 SimulationMessaging::create (broker.c_str (), smqUserName.c_str (),
0 commit comments