Skip to content

Commit ce25a1c

Browse files
authored
Merge pull request #1091 from PowerGridModel/feature/rename-job-dispatch-classes
Clean-up main model: Rename job dispatch-related classes
2 parents 070b81b + 9f306fc commit ce25a1c

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/job_adapter.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515

1616
namespace power_grid_model {
1717

18-
template <class MainModel, typename... ComponentType> class JobDispatchAdapter;
18+
template <class MainModel, typename... ComponentType> class JobAdapter;
1919

2020
template <class MainModel, class... ComponentType>
21-
class JobDispatchAdapter<MainModel, ComponentList<ComponentType...>>
22-
: public JobDispatchInterface<JobDispatchAdapter<MainModel, ComponentList<ComponentType...>>> {
21+
class JobAdapter<MainModel, ComponentList<ComponentType...>>
22+
: public JobInterface<JobAdapter<MainModel, ComponentList<ComponentType...>>> {
2323
public:
24-
JobDispatchAdapter(std::reference_wrapper<MainModel> model_reference,
25-
std::reference_wrapper<MainModelOptions const> options)
24+
JobAdapter(std::reference_wrapper<MainModel> model_reference,
25+
std::reference_wrapper<MainModelOptions const> options)
2626
: model_reference_{model_reference}, options_{options} {}
27-
JobDispatchAdapter(JobDispatchAdapter const& other)
27+
JobAdapter(JobAdapter const& other)
2828
: model_copy_{std::make_unique<MainModel>(other.model_reference_.get())},
2929
model_reference_{std::ref(*model_copy_)},
3030
options_{std::ref(other.options_)},
3131
components_to_update_{other.components_to_update_},
3232
update_independence_{other.update_independence_},
3333
independence_flags_{other.independence_flags_},
3434
all_scenarios_sequence_{other.all_scenarios_sequence_} {}
35-
JobDispatchAdapter& operator=(JobDispatchAdapter const& other) {
35+
JobAdapter& operator=(JobAdapter const& other) {
3636
if (this != &other) {
3737
model_copy_ = std::make_unique<MainModel>(other.model_reference_.get());
3838
model_reference_ = std::ref(*model_copy_);
@@ -44,15 +44,15 @@ class JobDispatchAdapter<MainModel, ComponentList<ComponentType...>>
4444
}
4545
return *this;
4646
}
47-
JobDispatchAdapter(JobDispatchAdapter&& other) noexcept
47+
JobAdapter(JobAdapter&& other) noexcept
4848
: model_copy_{std::move(other.model_copy_)},
4949
model_reference_{model_copy_ ? std::ref(*model_copy_) : std::move(other.model_reference_)},
5050
options_{other.options_},
5151
components_to_update_{std::move(other.components_to_update_)},
5252
update_independence_{std::move(other.update_independence_)},
5353
independence_flags_{std::move(other.independence_flags_)},
5454
all_scenarios_sequence_{std::move(other.all_scenarios_sequence_)} {}
55-
JobDispatchAdapter& operator=(JobDispatchAdapter&& other) noexcept {
55+
JobAdapter& operator=(JobAdapter&& other) noexcept {
5656
if (this != &other) {
5757
model_copy_ = std::move(other.model_copy_);
5858
model_reference_ = model_copy_ ? std::ref(*model_copy_) : std::move(other.model_reference_);
@@ -64,13 +64,13 @@ class JobDispatchAdapter<MainModel, ComponentList<ComponentType...>>
6464
}
6565
return *this;
6666
}
67-
~JobDispatchAdapter() { model_copy_.reset(); }
67+
~JobAdapter() { model_copy_.reset(); }
6868

6969
private:
70-
// Grant the CRTP base (JobDispatchInterface<JobDispatchAdapter>) access to
71-
// JobDispatchAdapter's private members. This allows the base class template
70+
// Grant the CRTP base (JobInterface<JobAdapter>) access to
71+
// JobAdapter's private members. This allows the base class template
7272
// to call derived-class implementation details as part of the CRTP pattern.
73-
friend class JobDispatchInterface<JobDispatchAdapter>;
73+
friend class JobInterface<JobAdapter>;
7474

7575
std::unique_ptr<MainModel> model_copy_;
7676
std::reference_wrapper<MainModel> model_reference_;

power_grid_model_c/power_grid_model/include/power_grid_model/job_dispatch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class JobDispatch {
1919

2020
// TODO(figueroa1395): add generic template parameters for update_data and result_data
2121
template <typename Adapter, typename ResultDataset, typename UpdateDataset>
22-
requires std::is_base_of_v<JobDispatchInterface<Adapter>, Adapter>
22+
requires std::is_base_of_v<JobInterface<Adapter>, Adapter>
2323
static BatchParameter batch_calculation(Adapter& adapter, ResultDataset const& result_data,
2424
UpdateDataset const& update_data, Idx threading = sequential) {
2525
if (update_data.empty()) {

power_grid_model_c/power_grid_model/include/power_grid_model/job_interface.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <utility>
1616

1717
namespace power_grid_model {
18-
template <typename Adapter> class JobDispatchInterface {
18+
template <typename Adapter> class JobInterface {
1919
public:
2020
// the multiple NOSONARs are used to avoid the complaints about the unnamed concepts
2121
template <typename ResultDataset>
@@ -79,12 +79,12 @@ template <typename Adapter> class JobDispatchInterface {
7979

8080
protected:
8181
// Protected & defaulted special members — CRTP: only the derived can create/copy/move this base
82-
JobDispatchInterface() = default;
83-
JobDispatchInterface(const JobDispatchInterface& /*other*/) = default;
84-
JobDispatchInterface& operator=(const JobDispatchInterface& /*other*/) = default;
85-
JobDispatchInterface(JobDispatchInterface&& /*other*/) noexcept = default;
86-
JobDispatchInterface& operator=(JobDispatchInterface&& /*other*/) noexcept = default;
87-
~JobDispatchInterface() = default;
82+
JobInterface() = default;
83+
JobInterface(const JobInterface& /*other*/) = default;
84+
JobInterface& operator=(const JobInterface& /*other*/) = default;
85+
JobInterface(JobInterface&& /*other*/) noexcept = default;
86+
JobInterface& operator=(JobInterface&& /*other*/) noexcept = default;
87+
~JobInterface() = default;
8888
};
8989

9090
} // namespace power_grid_model

power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class MainModel {
7878
*/
7979
BatchParameter calculate(Options const& options, MutableDataset const& result_data,
8080
ConstDataset const& update_data) {
81-
JobDispatchAdapter<Impl, AllComponents> adapter{std::ref(impl()), std::ref(options)};
81+
JobAdapter<Impl, AllComponents> adapter{std::ref(impl()), std::ref(options)};
8282
return JobDispatch::batch_calculation(adapter, result_data, update_data, options.threading);
8383
}
8484

0 commit comments

Comments
 (0)