Skip to content

Commit

Permalink
#265 Review followup. Fix stragglers, rename methods in simulator class.
Browse files Browse the repository at this point in the history
  • Loading branch information
eidekrist committed Aug 28, 2019
1 parent fb464ad commit b4f8e46
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion include/cse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions include/cse/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,16 @@ class simulator : public observable
std::optional<double> relativeTolerance) = 0;

/// Returns all value references of real type that currently have an active modifier.
virtual const std::unordered_set<value_reference>& get_modified_real_references() const = 0;
virtual const std::unordered_set<value_reference>& get_modified_real_variables() const = 0;

/// Returns all value references of integer type that currently have an active modifier.
virtual const std::unordered_set<value_reference>& get_modified_integer_references() const = 0;
virtual const std::unordered_set<value_reference>& get_modified_integer_variables() const = 0;

/// Returns all value references of boolean type that currently have an active modifier.
virtual const std::unordered_set<value_reference>& get_modified_boolean_references() const = 0;
virtual const std::unordered_set<value_reference>& get_modified_boolean_variables() const = 0;

/// Returns all value references of string type that currently have an active modifier.
virtual const std::unordered_set<value_reference>& get_modified_string_references() const = 0;
virtual const std::unordered_set<value_reference>& get_modified_string_variables() const = 0;

/**
* Updates the simulator with new input values and makes it calculate
Expand Down
8 changes: 4 additions & 4 deletions include/cse/observer/time_series_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/c/cse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int cse_slave_get_num_variables(cse_execution* execution, cse_slave_index slave)
return static_cast<int>(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;
}

Expand Down Expand Up @@ -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[],
Expand All @@ -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) {
Expand Down Expand Up @@ -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[],
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/cse/slave_simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class slave_simulator : public simulator
value_reference reference,
std::function<std::string(std::string_view)> modifier) override;

std::unordered_set<value_reference>& get_modified_real_references() const override;
std::unordered_set<value_reference>& get_modified_integer_references() const override;
std::unordered_set<value_reference>& get_modified_boolean_references() const override;
std::unordered_set<value_reference>& get_modified_string_references() const override;
std::unordered_set<value_reference>& get_modified_real_variables() const override;
std::unordered_set<value_reference>& get_modified_integer_variables() const override;
std::unordered_set<value_reference>& get_modified_boolean_variables() const override;
std::unordered_set<value_reference>& get_modified_string_variables() const override;

boost::fibers::future<void> setup(
time_point startTime,
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
56 changes: 28 additions & 28 deletions src/cpp/slave_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,83 +322,83 @@ class slave_simulator::impl
std::function<double(double)> 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(
value_reference ref,
std::function<int(int)> 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(
value_reference ref,
std::function<bool(bool)> 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(
value_reference ref,
std::function<std::string(std::string_view)> 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(
value_reference ref,
std::function<double(double)> 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(
value_reference ref,
std::function<int(int)> 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(
value_reference ref,
std::function<bool(bool)> 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(
value_reference ref,
std::function<std::string(std::string_view)> 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<value_reference>& get_modified_real_references()
std::unordered_set<value_reference>& get_modified_real_variables()
{
return modifiedRealReferences_;
return modifiedRealVariables_;
}

std::unordered_set<value_reference>& get_modified_integer_references()
std::unordered_set<value_reference>& get_modified_integer_variables()
{
return modifiedIntegerReferences_;
return modifiedIntegerVariables_;
}

std::unordered_set<value_reference>& get_modified_boolean_references()
std::unordered_set<value_reference>& get_modified_boolean_variables()
{
return modifiedBooleanReferences_;
return modifiedBooleanVariables_;
}

std::unordered_set<value_reference>& get_modified_string_references()
std::unordered_set<value_reference>& get_modified_string_variables()
{
return modifiedStringReferences_;
return modifiedStringVariables_;
}

boost::fibers::future<void> setup(
Expand Down Expand Up @@ -517,10 +517,10 @@ class slave_simulator::impl
set_variable_cache<bool> booleanSetCache_;
set_variable_cache<std::string> stringSetCache_;

std::unordered_set<value_reference> modifiedRealReferences_;
std::unordered_set<value_reference> modifiedIntegerReferences_;
std::unordered_set<value_reference> modifiedBooleanReferences_;
std::unordered_set<value_reference> modifiedStringReferences_;
std::unordered_set<value_reference> modifiedRealVariables_;
std::unordered_set<value_reference> modifiedIntegerVariables_;
std::unordered_set<value_reference> modifiedBooleanVariables_;
std::unordered_set<value_reference> modifiedStringVariables_;
};


Expand Down Expand Up @@ -666,24 +666,24 @@ void slave_simulator::set_string_output_modifier(
pimpl_->set_string_output_modifier(ref, modifier);
}

std::unordered_set<value_reference>& slave_simulator::get_modified_real_references() const
std::unordered_set<value_reference>& slave_simulator::get_modified_real_variables() const
{
return pimpl_->get_modified_real_references();
return pimpl_->get_modified_real_variables();
}

std::unordered_set<value_reference>& slave_simulator::get_modified_integer_references() const
std::unordered_set<value_reference>& slave_simulator::get_modified_integer_variables() const
{
return pimpl_->get_modified_integer_references();
return pimpl_->get_modified_integer_variables();
}

std::unordered_set<value_reference>& slave_simulator::get_modified_boolean_references() const
std::unordered_set<value_reference>& slave_simulator::get_modified_boolean_variables() const
{
return pimpl_->get_modified_boolean_references();
return pimpl_->get_modified_boolean_variables();
}

std::unordered_set<value_reference>& slave_simulator::get_modified_string_references() const
std::unordered_set<value_reference>& slave_simulator::get_modified_string_variables() const
{
return pimpl_->get_modified_string_references();
return pimpl_->get_modified_string_variables();
}

boost::fibers::future<void> slave_simulator::setup(
Expand Down

0 comments on commit b4f8e46

Please sign in to comment.