From 0394867dfd60cb54964956d9f3b1aad711170db1 Mon Sep 17 00:00:00 2001 From: Derek Bankieris Date: Tue, 4 Dec 2018 10:25:03 -0600 Subject: [PATCH] Add MonteCarlo::variables accessor Closes #713 --- include/trick/MonteCarlo.hh | 9 +++++++++ .../sim_services/MonteCarlo/MonteCarlo_funcs.cpp | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/include/trick/MonteCarlo.hh b/include/trick/MonteCarlo.hh index 5cd56172..6cf7daec 100644 --- a/include/trick/MonteCarlo.hh +++ b/include/trick/MonteCarlo.hh @@ -17,6 +17,8 @@ #ifdef SWIG // This instructs SWIG to use dynamic_cast and return one of the derived type for the get_variable function. %factory(Trick::MonteVar * Trick::MonteCarlo::get_variable, Trick::MonteVarCalculated, Trick::MonteVarFile, Trick::MonteVarFixed, Trick::MonteVarRandom) ; +// This, paired with get_variables, allows access to the variables from the input file. +%template(MonteVarVector) std::vector; #endif namespace Trick { @@ -625,6 +627,13 @@ namespace Trick { */ Trick::MonteVar * get_variable(std::string variable_name); + /** + * Gets the list of added variables. + * + * @return the current list of variables + */ + const std::vector& get_variables(); + /** * Adds a new slave with the specified machine name. * diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp index c6786863..6a62f792 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp @@ -178,6 +178,10 @@ Trick::MonteVar * Trick::MonteCarlo::get_variable(std::string variable_name) { return (NULL); } +const std::vector& Trick::MonteCarlo::get_variables() { + return variables; +} + void Trick::MonteCarlo::add_slave(std::string in_machine_name) { add_slave(new MonteSlave(in_machine_name)); }