Skip to content

Commit

Permalink
Bmi_Adapter: Drop constructor arguments for allow_model_exceed_end_time
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller committed Jun 27, 2024
1 parent e5d8e83 commit 303eb81
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 51 deletions.
3 changes: 1 addition & 2 deletions include/bmi/AbstractCLibBmiAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param output The output stream handler.
*/
AbstractCLibBmiAdapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step, std::string registration_func);
bool has_fixed_time_step, std::string registration_func);

/**
* Class destructor.
Expand Down
3 changes: 1 addition & 2 deletions include/bmi/Bmi_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace models {
class Bmi_Adapter : public ::bmi::Bmi {
public:

Bmi_Adapter(std::string model_name, std::string bmi_init_config, bool allow_exceed_end,
bool has_fixed_time_step);
Bmi_Adapter(std::string model_name, std::string bmi_init_config, bool has_fixed_time_step);

Bmi_Adapter(Bmi_Adapter const&) = delete;
Bmi_Adapter(Bmi_Adapter &&) = delete;
Expand Down
9 changes: 3 additions & 6 deletions include/bmi/Bmi_C_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ namespace models {
*
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
*/
explicit Bmi_C_Adapter(const std::string &type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
const std::string& registration_func);

/**
Expand All @@ -45,12 +44,11 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
*/
Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string registration_func);

protected:
Expand All @@ -69,13 +67,12 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param do_initialization Whether initialization should be performed during construction or deferred.
*/
Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string registration_func, bool do_initialization);

public:
Expand Down
9 changes: 3 additions & 6 deletions include/bmi/Bmi_Cpp_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ namespace models {
*
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param creator_func The name for the @see creator_function .
* @param destoryer_func The name for the @see destroyer_function .
*/
explicit Bmi_Cpp_Adapter(const std::string &type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func);

/**
Expand All @@ -49,13 +48,12 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param creator_func The name for the @see creator_function .
* @param destoryer_func The name for the @see destroyer_function .
*/
Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func);

protected:
Expand All @@ -74,14 +72,13 @@ namespace models {
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param creator_func The name for the @see creator_function .
* @param destoryer_func The name for the @see destroyer_function .
* @param do_initialization Whether initialization should be performed during construction or deferred.
*/
Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func,
bool do_initialization);

Expand Down
7 changes: 3 additions & 4 deletions include/bmi/Bmi_Fortran_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ namespace models {
public:

explicit Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
const std::string &registration_func)
: Bmi_Fortran_Adapter(type_name, library_file_path, "", allow_exceed_end,
: Bmi_Fortran_Adapter(type_name, library_file_path, "",
has_fixed_time_step,
registration_func) {}

Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string registration_func) : AbstractCLibBmiAdapter(type_name,
library_file_path,
bmi_init_config,
allow_exceed_end,
has_fixed_time_step,
registration_func
) {
Expand Down
2 changes: 1 addition & 1 deletion include/bmi/Bmi_Py_Adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace models {
public:

Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
bool allow_exceed_end, bool has_fixed_time_step);
bool has_fixed_time_step);

Bmi_Py_Adapter(Bmi_Py_Adapter const&) = delete;
Bmi_Py_Adapter(Bmi_Py_Adapter&&) = delete;
Expand Down
2 changes: 0 additions & 2 deletions src/bmi/AbstractCLibBmiAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ AbstractCLibBmiAdapter::AbstractCLibBmiAdapter(
const std::string& type_name,
std::string library_file_path,
std::string bmi_init_config,
bool allow_exceed_end,
bool has_fixed_time_step,
std::string registration_func
)
: Bmi_Adapter(
type_name,
std::move(bmi_init_config),
allow_exceed_end,
has_fixed_time_step
)
, bmi_lib_file(std::move(library_file_path))
Expand Down
1 change: 0 additions & 1 deletion src/bmi/Bmi_Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace bmi {
Bmi_Adapter::Bmi_Adapter(
std::string model_name,
std::string bmi_init_config,
bool allow_exceed_end,
bool has_fixed_time_step
)
: model_name(std::move(model_name))
Expand Down
16 changes: 6 additions & 10 deletions src/bmi/Bmi_C_Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,29 @@ using namespace models::bmi;
*
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
*/
Bmi_C_Adapter::Bmi_C_Adapter(const std::string &type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
const std::string& registration_func)
: Bmi_C_Adapter(type_name, std::move(library_file_path), "",
allow_exceed_end, has_fixed_time_step, registration_func) { }
has_fixed_time_step, registration_func) { }

/**
* Main public constructor.
*
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
*/
Bmi_C_Adapter::Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string registration_func)
: Bmi_C_Adapter(type_name, std::move(library_file_path), std::move(bmi_init_config),
allow_exceed_end, has_fixed_time_step,
has_fixed_time_step,
std::move(registration_func), true) { }

/**
Expand All @@ -51,15 +49,14 @@ Bmi_C_Adapter::Bmi_C_Adapter(const std::string &type_name, std::string library_f
* @param type_name The name of the backing BMI module/model type.
* @param library_file_path The string path to the shared library file for external module.
* @param bmi_init_config The string path to the BMI initialization config file for the module.
* @param allow_exceed_end Whether the backing model is allowed to execute beyond its advertised end_time.
* @param has_fixed_time_step Whether the model has a fixed time step size.
* @param registration_func The name for the @see bmi_registration_function.
* @param do_initialization Whether initialization should be performed during construction or deferred.
*/
Bmi_C_Adapter::Bmi_C_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string registration_func, bool do_initialization)
: AbstractCLibBmiAdapter(type_name, library_file_path, std::move(bmi_init_config), allow_exceed_end,
: AbstractCLibBmiAdapter(type_name, library_file_path, std::move(bmi_init_config),
has_fixed_time_step, registration_func)
{
if (do_initialization) {
Expand Down Expand Up @@ -98,7 +95,6 @@ Bmi_C_Adapter::Bmi_C_Adapter(const std::string &type_name, std::string library_f
// TODO: However, it may make sense to bring it back once it is possible to serialize and deserialize the model.
/*
Bmi_C_Adapter::Bmi_C_Adapter(Bmi_C_Adapter &adapter) : model_name(adapter.model_name),
allow_model_exceed_end_time(adapter.allow_model_exceed_end_time),
bmi_init_config(adapter.bmi_init_config),
bmi_lib_file(adapter.bmi_lib_file),
bmi_model(adapter.bmi_model),
Expand Down
13 changes: 6 additions & 7 deletions src/bmi/Bmi_Cpp_Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
using namespace models::bmi;

Bmi_Cpp_Adapter::Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func)
: Bmi_Cpp_Adapter(type_name, std::move(library_file_path), "",
allow_exceed_end, has_fixed_time_step, creator_func, destroyer_func) { }
has_fixed_time_step, creator_func, destroyer_func) { }

Bmi_Cpp_Adapter::Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func)
: Bmi_Cpp_Adapter(type_name, std::move(library_file_path), std::move(bmi_init_config),
allow_exceed_end, has_fixed_time_step,
has_fixed_time_step,
std::move(creator_func), std::move(destroyer_func), true) { }

Bmi_Cpp_Adapter::Bmi_Cpp_Adapter(const std::string& type_name, std::string library_file_path, std::string bmi_init_config,
bool allow_exceed_end, bool has_fixed_time_step,
bool has_fixed_time_step,
std::string creator_func, std::string destroyer_func,
bool do_initialization)
: AbstractCLibBmiAdapter(type_name, library_file_path, std::move(bmi_init_config), allow_exceed_end,
: AbstractCLibBmiAdapter(type_name, library_file_path, std::move(bmi_init_config),
has_fixed_time_step, creator_func),
model_create_fname(std::move(creator_func)),
model_destroy_fname(std::move(destroyer_func))
Expand Down Expand Up @@ -57,7 +57,6 @@ Bmi_Cpp_Adapter::Bmi_Cpp_Adapter(const std::string& type_name, std::string libra
// TODO: However, it may make sense to bring it back once it is possible to serialize and deserialize the model.
/*
Bmi_Cpp_Adapter::Bmi_Cpp_Adapter(Bmi_Cpp_Adapter &adapter) :
allow_model_exceed_end_time(adapter.allow_model_exceed_end_time),
bmi_init_config(adapter.bmi_init_config),
bmi_lib_file(adapter.bmi_lib_file),
bmi_model(adapter.bmi_model),
Expand Down
4 changes: 2 additions & 2 deletions src/bmi/Bmi_Py_Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ using namespace models::bmi;
using namespace pybind11::literals; // to bring in the `_a` literal for pybind11 keyword args functionality

Bmi_Py_Adapter::Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
bool allow_exceed_end, bool has_fixed_time_step)
bool has_fixed_time_step)
: Bmi_Adapter(type_name + " (BMI Py)", std::move(bmi_init_config),
allow_exceed_end, has_fixed_time_step),
has_fixed_time_step),
bmi_type_py_full_name(bmi_python_type),
np(utils::ngenPy::InterpreterUtil::getPyModule("numpy")) /* like 'import numpy as np' */
{
Expand Down
1 change: 0 additions & 1 deletion src/realizations/catchment/Bmi_C_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ std::shared_ptr<Bmi_Adapter> Bmi_C_Formulation::construct_model(const geojson::P
get_model_type_name(),
lib_file,
get_bmi_init_config(),
get_allow_model_exceed_end_time(),
is_bmi_model_time_step_fixed(),
reg_func);
}
Expand Down
1 change: 0 additions & 1 deletion src/realizations/catchment/Bmi_Cpp_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ std::shared_ptr<Bmi_Adapter> Bmi_Cpp_Formulation::construct_model(const geojson:
get_model_type_name(),
lib_file,
get_bmi_init_config(),
get_allow_model_exceed_end_time(),
is_bmi_model_time_step_fixed(),
model_create_fname,
model_destroy_fname);
Expand Down
1 change: 0 additions & 1 deletion src/realizations/catchment/Bmi_Fortran_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ std::shared_ptr<Bmi_Adapter> Bmi_Fortran_Formulation::construct_model(const geoj
get_model_type_name(),
lib_file,
get_bmi_init_config(),
get_allow_model_exceed_end_time(),
is_bmi_model_time_step_fixed(),
reg_func);
}
Expand Down
1 change: 0 additions & 1 deletion src/realizations/catchment/Bmi_Py_Formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ std::shared_ptr<Bmi_Adapter> Bmi_Py_Formulation::construct_model(const geojson::
get_model_type_name(),
get_bmi_init_config(),
python_type_name,
get_allow_model_exceed_end_time(),
is_bmi_model_time_step_fixed());
}

Expand Down
2 changes: 1 addition & 1 deletion test/bmi/Bmi_C_Adapter_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void Bmi_C_Adapter_Test::SetUp() {
lib_file_name_0 = file_search(lib_dir_opts, BMI_TEST_C_LOCAL_LIB_NAME);
bmi_module_type_name_0 = "test_bmi_c";
adapter = std::make_unique<Bmi_C_Adapter>(bmi_module_type_name_0, lib_file_name_0, config_file_name_0,
false, true, REGISTRATION_FUNC);
true, REGISTRATION_FUNC);
}

void Bmi_C_Adapter_Test::TearDown() {
Expand Down
Loading

0 comments on commit 303eb81

Please sign in to comment.