diff --git a/include/trick/MonteCarlo.hh b/include/trick/MonteCarlo.hh index f0776b27..bbdc9b82 100644 --- a/include/trick/MonteCarlo.hh +++ b/include/trick/MonteCarlo.hh @@ -21,6 +21,18 @@ %template(MonteVarVector) std::vector; #endif +/* strings to match ExitStatus enum in MonteRun */ +static const char* MC_exit_status_string[] = { + "Incomplete", + "Complete", + "Failed", + "Core Dumped", + "Timed Out", + "No Permission to Output Directory", + "Bad Input", + "Unrecognized Return Code" +} ; + namespace Trick { /** @@ -36,7 +48,10 @@ namespace Trick { class MonteRun { public: - /** Details the manner in which this run exited. */ + /** + * Details the manner in which this run exited. Update + * Strings in MC_exit_status_string above when editing enum. + */ enum ExitStatus { MC_RUN_INCOMPLETE, /**< not completed */ MC_RUN_COMPLETE, /**< process completed with exit status zero */ @@ -78,6 +93,8 @@ namespace Trick { end_time(0), exit_status(MC_RUN_INCOMPLETE) {} + /* return exit status string that matches enum value */ + const char* exit_status_string() const; }; /** diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp index 0cc791d5..e1785f08 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo.cpp @@ -72,4 +72,8 @@ Trick::MonteCarlo::~MonteCarlo() { connection_device.error_handler = NULL ; } +const char* Trick::MonteRun::exit_status_string() const { + return MC_exit_status_string[exit_status]; +} + diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp index e2ca026d..38b67256 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_master_shutdown.cpp @@ -60,10 +60,8 @@ void Trick::MonteCarlo::shutdown_slaves() { } } } + void Trick::MonteCarlo::print_statistics(FILE** fp) { - static const char *exit_status_string[] = - {"Incomplete", "Complete", "Core Dumped", "Timed Out", - "No Permission to Output Directory", "Bad Input" } ; fprintf(*fp, "\nMonte Carlo complete: %u runs (%zu successful) (%zu non-zero exit status) (%zu errors) (%u out of range)\n", @@ -109,7 +107,7 @@ void Trick::MonteCarlo::print_statistics(FILE** fp) { fprintf(*fp, "\nThe following runs failed to complete:\n"); for (const MonteRun* run : error_runs) { fprintf(*fp, "RUN_%05d MonteRun::ExitStatus = %s (%d)\n", run->id, - exit_status_string[run->exit_status], run->exit_status); + run->exit_status_string(), run->exit_status); } } }