Skip to content

Commit

Permalink
Bmi_*_Adapter: make them non-copyable and non-movable
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller committed Nov 8, 2023
1 parent 9322eb6 commit b1d3014
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
5 changes: 2 additions & 3 deletions include/bmi/Bmi_C_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ namespace models {
// once original object closes the handle for its dynamically loaded lib) it make more sense to remove the
// copy constructor.
// TODO: However, it may make sense to bring it back once it's possible to serialize/deserialize the model.
//Bmi_C_Adapter(Bmi_C_Adapter &adapter);
Bmi_C_Adapter(Bmi_C_Adapter &adapter) = delete;

// Move constructor
Bmi_C_Adapter(Bmi_C_Adapter &&adapter) noexcept = default;
Bmi_C_Adapter(Bmi_C_Adapter &&adapter) noexcept = delete;

/**
* Class destructor.
Expand Down
4 changes: 2 additions & 2 deletions include/bmi/Bmi_Cpp_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ namespace models {
// once original object closes the handle for its dynamically loaded lib) it make more sense to remove the
// copy constructor.
// TODO: However, it may make sense to bring it back once it's possible to serialize/deserialize the model.
//Bmi_Cpp_Adapter(Bmi_Cpp_Adapter &adapter);
Bmi_Cpp_Adapter(Bmi_Cpp_Adapter &adapter) = delete;

// Move constructor
Bmi_Cpp_Adapter(Bmi_Cpp_Adapter &&adapter) noexcept = default;
Bmi_Cpp_Adapter(Bmi_Cpp_Adapter &&adapter) noexcept = delete;

/**
* Class destructor.
Expand Down
3 changes: 3 additions & 0 deletions include/bmi/Bmi_Fortran_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ namespace models {
}
}

Bmi_Fortran_Adapter(Bmi_Fortran_Adapter const&) = delete;
Bmi_Fortran_Adapter(Bmi_Fortran_Adapter&&) = delete;

std::string GetComponentName() override;

/**
Expand Down
3 changes: 3 additions & 0 deletions include/bmi/Bmi_Py_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespace models {
std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
utils::StreamHandler output);

Bmi_Py_Adapter(Bmi_Py_Adapter const&) = delete;
Bmi_Py_Adapter(Bmi_Py_Adapter&&) = delete;

/**
* Copy the given BMI variable's values from the backing numpy array to a C++ array.
*
Expand Down
3 changes: 1 addition & 2 deletions src/realizations/catchment/Bmi_C_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ std::shared_ptr<Bmi_C_Adapter> Bmi_C_Formulation::construct_model(const geojson:
std::string reg_func =
reg_func_itr == properties.end() ? BMI_C_DEFAULT_REGISTRATION_FUNC : reg_func_itr->second.as_string();
return std::make_shared<Bmi_C_Adapter>(
Bmi_C_Adapter(
get_model_type_name(),
lib_file,
get_bmi_init_config(),
(is_bmi_using_forcing_file() ? get_forcing_file_path() : ""),
get_allow_model_exceed_end_time(),
is_bmi_model_time_step_fixed(),
reg_func,
output));
output);
}

std::string Bmi_C_Formulation::get_output_header_line(std::string delimiter) {
Expand Down
3 changes: 1 addition & 2 deletions src/realizations/catchment/Bmi_Cpp_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ std::shared_ptr<Bmi_Cpp_Adapter> Bmi_Cpp_Formulation::construct_model(const geoj
json_prop_itr == properties.end() ? BMI_REALIZATION_CFG_PARAM_OPT__CPP_DESTROY_FUNC_DEFAULT : json_prop_itr->second.as_string();

return std::make_shared<Bmi_Cpp_Adapter>(
Bmi_Cpp_Adapter(
get_model_type_name(),
lib_file,
get_bmi_init_config(),
Expand All @@ -43,7 +42,7 @@ std::shared_ptr<Bmi_Cpp_Adapter> Bmi_Cpp_Formulation::construct_model(const geoj
is_bmi_model_time_step_fixed(),
model_create_fname,
model_destroy_fname,
output));
output);
}

std::string Bmi_Cpp_Formulation::get_output_header_line(std::string delimiter) {
Expand Down
3 changes: 1 addition & 2 deletions src/realizations/catchment/Bmi_Py_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ shared_ptr<Bmi_Py_Adapter> Bmi_Py_Formulation::construct_model(const geojson::Pr
std::string python_type_name = python_type_name_iter->second.as_string();

return std::make_shared<Bmi_Py_Adapter>(
Bmi_Py_Adapter(
get_model_type_name(),
get_bmi_init_config(),
python_type_name,
get_allow_model_exceed_end_time(),
is_bmi_model_time_step_fixed(),
output));
output);
}

time_t realization::Bmi_Py_Formulation::convert_model_time(const double &model_time) {
Expand Down

0 comments on commit b1d3014

Please sign in to comment.