From b4f8e465056faf0c607149c180fd7421f0f43bdf Mon Sep 17 00:00:00 2001 From: eidekrist Date: Wed, 28 Aug 2019 08:32:07 +0200 Subject: [PATCH] #265 Review followup. Fix stragglers, rename methods in simulator class. --- include/cse.h | 2 +- include/cse/algorithm.hpp | 8 +-- include/cse/observer/time_series_provider.hpp | 8 +-- src/c/cse.cpp | 10 ++-- src/cpp/cse/slave_simulator.hpp | 8 +-- src/cpp/execution.cpp | 8 +-- src/cpp/slave_simulator.cpp | 56 +++++++++---------- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/cse.h b/include/cse.h index 770cbec52..27e728fc6 100644 --- a/include/cse.h +++ b/include/cse.h @@ -384,7 +384,7 @@ typedef struct cse_slave_index slave_index; /// The type of the variable. cse_variable_type type; - /// The variables value reference. + /// The variable's value reference. cse_value_reference value_reference; } cse_variable_id; diff --git a/include/cse/algorithm.hpp b/include/cse/algorithm.hpp index f137b2571..6ec75210d 100644 --- a/include/cse/algorithm.hpp +++ b/include/cse/algorithm.hpp @@ -182,16 +182,16 @@ class simulator : public observable std::optional relativeTolerance) = 0; /// Returns all value references of real type that currently have an active modifier. - virtual const std::unordered_set& get_modified_real_references() const = 0; + virtual const std::unordered_set& get_modified_real_variables() const = 0; /// Returns all value references of integer type that currently have an active modifier. - virtual const std::unordered_set& get_modified_integer_references() const = 0; + virtual const std::unordered_set& get_modified_integer_variables() const = 0; /// Returns all value references of boolean type that currently have an active modifier. - virtual const std::unordered_set& get_modified_boolean_references() const = 0; + virtual const std::unordered_set& get_modified_boolean_variables() const = 0; /// Returns all value references of string type that currently have an active modifier. - virtual const std::unordered_set& get_modified_string_references() const = 0; + virtual const std::unordered_set& get_modified_string_variables() const = 0; /** * Updates the simulator with new input values and makes it calculate diff --git a/include/cse/observer/time_series_provider.hpp b/include/cse/observer/time_series_provider.hpp index ea5cac379..627fba520 100644 --- a/include/cse/observer/time_series_provider.hpp +++ b/include/cse/observer/time_series_provider.hpp @@ -29,7 +29,7 @@ class time_series_provider : public observer * Retrieves a series of observed values, step numbers and times for a real variable. * * \param [in] sim index of the simulator - * \param [in] valueReference the variable index + * \param [in] valueReference the value reference * \param [in] fromStep the step number to start from * \param [out] values the series of observed values * \param [out] steps the corresponding step numbers @@ -50,7 +50,7 @@ class time_series_provider : public observer * Retrieves a series of observed values, step numbers and times for an integer variable. * * \param [in] sim index of the simulator - * \param [in] valueReference the variable index + * \param [in] valueReference the value reference * \param [in] fromStep the step number to start from * \param [out] values the series of observed values * \param [out] steps the corresponding step numbers @@ -103,9 +103,9 @@ class time_series_provider : public observer * Retrieves two time-synchronized series of observed values for two real variables. * * \param [in] sim1 index of the first simulator - * \param [in] valueReference1 the first variable index + * \param [in] valueReference1 the first value reference * \param [in] sim2 index of the second simulator - * \param [in] valueReference2 the second variable index + * \param [in] valueReference2 the second value reference * \param [in] fromStep the step number to start from * \param [out] values1 the first series of observed values * \param [out] values2 the second series of observed values diff --git a/src/c/cse.cpp b/src/c/cse.cpp index 82415ea28..7fff7c7fd 100644 --- a/src/c/cse.cpp +++ b/src/c/cse.cpp @@ -224,7 +224,7 @@ int cse_slave_get_num_variables(cse_execution* execution, cse_slave_index slave) return static_cast(entry.second.description.variables.size()); } } - set_last_error(CSE_ERRC_OUT_OF_RANGE, "Invalid slave reference"); + set_last_error(CSE_ERRC_OUT_OF_RANGE, "Invalid slave index"); return -1; } @@ -631,7 +631,7 @@ int cse_observer_slave_get_string( int64_t cse_observer_slave_get_real_samples( cse_observer* observer, cse_slave_index slave, - cse_value_reference ValueReference, + cse_value_reference valueReference, cse_step_number fromStep, size_t nSamples, double values[], @@ -644,7 +644,7 @@ int64_t cse_observer_slave_get_real_samples( if (!obs) { throw std::invalid_argument("Invalid observer! The provided observer must be a time_series_observer."); } - size_t samplesRead = obs->get_real_samples(slave, ValueReference, fromStep, + size_t samplesRead = obs->get_real_samples(slave, valueReference, fromStep, gsl::make_span(values, nSamples), gsl::make_span(steps, nSamples), timePoints); for (size_t i = 0; i < samplesRead; ++i) { @@ -692,7 +692,7 @@ int64_t cse_observer_slave_get_real_synchronized_series( int64_t cse_observer_slave_get_integer_samples( cse_observer* observer, cse_slave_index slave, - cse_value_reference ValueReference, + cse_value_reference valueReference, cse_step_number fromStep, size_t nSamples, int values[], @@ -705,7 +705,7 @@ int64_t cse_observer_slave_get_integer_samples( if (!obs) { throw std::invalid_argument("Invalid observer! The provided observer must be a time_series_observer."); } - size_t samplesRead = obs->get_integer_samples(slave, ValueReference, fromStep, + size_t samplesRead = obs->get_integer_samples(slave, valueReference, fromStep, gsl::make_span(values, nSamples), gsl::make_span(steps, nSamples), timePoints); for (size_t i = 0; i < samplesRead; ++i) { diff --git a/src/cpp/cse/slave_simulator.hpp b/src/cpp/cse/slave_simulator.hpp index a826e5955..85eafca2f 100644 --- a/src/cpp/cse/slave_simulator.hpp +++ b/src/cpp/cse/slave_simulator.hpp @@ -71,10 +71,10 @@ class slave_simulator : public simulator value_reference reference, std::function modifier) override; - std::unordered_set& get_modified_real_references() const override; - std::unordered_set& get_modified_integer_references() const override; - std::unordered_set& get_modified_boolean_references() const override; - std::unordered_set& get_modified_string_references() const override; + std::unordered_set& get_modified_real_variables() const override; + std::unordered_set& get_modified_integer_variables() const override; + std::unordered_set& get_modified_boolean_variables() const override; + std::unordered_set& get_modified_string_variables() const override; boost::fibers::future setup( time_point startTime, diff --git a/src/cpp/execution.cpp b/src/cpp/execution.cpp index 5ab99f31a..f00d4edc1 100644 --- a/src/cpp/execution.cpp +++ b/src/cpp/execution.cpp @@ -204,10 +204,10 @@ class execution::impl auto index = 0; for (const auto& sim : simulators_) { - const auto& realRefs = sim->get_modified_real_references(); - const auto& integerRefs = sim->get_modified_integer_references(); - const auto& booleanRefs = sim->get_modified_boolean_references(); - const auto& stringRefs = sim->get_modified_string_references(); + const auto& realRefs = sim->get_modified_real_variables(); + const auto& integerRefs = sim->get_modified_integer_variables(); + const auto& booleanRefs = sim->get_modified_boolean_variables(); + const auto& stringRefs = sim->get_modified_string_variables(); for (const auto& ref : realRefs) { variable_id var = {index, variable_type::real, ref}; diff --git a/src/cpp/slave_simulator.cpp b/src/cpp/slave_simulator.cpp index f83aaf2b6..3f32f3ccc 100644 --- a/src/cpp/slave_simulator.cpp +++ b/src/cpp/slave_simulator.cpp @@ -322,7 +322,7 @@ class slave_simulator::impl std::function modifier) { realSetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedRealReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedRealVariables_, ref, modifier ? true : false); } void set_integer_input_modifier( @@ -330,7 +330,7 @@ class slave_simulator::impl std::function modifier) { integerSetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedIntegerReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedIntegerVariables_, ref, modifier ? true : false); } void set_boolean_input_modifier( @@ -338,7 +338,7 @@ class slave_simulator::impl std::function modifier) { booleanSetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedBooleanReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedBooleanVariables_, ref, modifier ? true : false); } void set_string_input_modifier( @@ -346,7 +346,7 @@ class slave_simulator::impl std::function modifier) { stringSetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedStringReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedStringVariables_, ref, modifier ? true : false); } void set_real_output_modifier( @@ -354,7 +354,7 @@ class slave_simulator::impl std::function modifier) { realGetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedRealReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedRealVariables_, ref, modifier ? true : false); } void set_integer_output_modifier( @@ -362,7 +362,7 @@ class slave_simulator::impl std::function modifier) { integerGetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedIntegerReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedIntegerVariables_, ref, modifier ? true : false); } void set_boolean_output_modifier( @@ -370,7 +370,7 @@ class slave_simulator::impl std::function modifier) { booleanGetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedBooleanReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedBooleanVariables_, ref, modifier ? true : false); } void set_string_output_modifier( @@ -378,27 +378,27 @@ class slave_simulator::impl std::function modifier) { stringGetCache_.set_modifier(ref, modifier); - set_modified_reference(modifiedStringReferences_, ref, modifier ? true : false); + set_modified_reference(modifiedStringVariables_, ref, modifier ? true : false); } - std::unordered_set& get_modified_real_references() + std::unordered_set& get_modified_real_variables() { - return modifiedRealReferences_; + return modifiedRealVariables_; } - std::unordered_set& get_modified_integer_references() + std::unordered_set& get_modified_integer_variables() { - return modifiedIntegerReferences_; + return modifiedIntegerVariables_; } - std::unordered_set& get_modified_boolean_references() + std::unordered_set& get_modified_boolean_variables() { - return modifiedBooleanReferences_; + return modifiedBooleanVariables_; } - std::unordered_set& get_modified_string_references() + std::unordered_set& get_modified_string_variables() { - return modifiedStringReferences_; + return modifiedStringVariables_; } boost::fibers::future setup( @@ -517,10 +517,10 @@ class slave_simulator::impl set_variable_cache booleanSetCache_; set_variable_cache stringSetCache_; - std::unordered_set modifiedRealReferences_; - std::unordered_set modifiedIntegerReferences_; - std::unordered_set modifiedBooleanReferences_; - std::unordered_set modifiedStringReferences_; + std::unordered_set modifiedRealVariables_; + std::unordered_set modifiedIntegerVariables_; + std::unordered_set modifiedBooleanVariables_; + std::unordered_set modifiedStringVariables_; }; @@ -666,24 +666,24 @@ void slave_simulator::set_string_output_modifier( pimpl_->set_string_output_modifier(ref, modifier); } -std::unordered_set& slave_simulator::get_modified_real_references() const +std::unordered_set& slave_simulator::get_modified_real_variables() const { - return pimpl_->get_modified_real_references(); + return pimpl_->get_modified_real_variables(); } -std::unordered_set& slave_simulator::get_modified_integer_references() const +std::unordered_set& slave_simulator::get_modified_integer_variables() const { - return pimpl_->get_modified_integer_references(); + return pimpl_->get_modified_integer_variables(); } -std::unordered_set& slave_simulator::get_modified_boolean_references() const +std::unordered_set& slave_simulator::get_modified_boolean_variables() const { - return pimpl_->get_modified_boolean_references(); + return pimpl_->get_modified_boolean_variables(); } -std::unordered_set& slave_simulator::get_modified_string_references() const +std::unordered_set& slave_simulator::get_modified_string_variables() const { - return pimpl_->get_modified_string_references(); + return pimpl_->get_modified_string_variables(); } boost::fibers::future slave_simulator::setup(