-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #828 from PowerGridModel/feature/optional-id-refac…
…tor-part2 Optional ID structural refactor
- Loading branch information
Showing
11 changed files
with
401 additions
and
356 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
power_grid_model_c/power_grid_model/include/power_grid_model/main_core/core_utils.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
#include "../all_components.hpp" | ||
#include "../container.hpp" | ||
|
||
#include <array> | ||
#include <vector> | ||
|
||
namespace power_grid_model::main_core::utils { | ||
|
||
template <class... ComponentTypes> constexpr size_t n_types = sizeof...(ComponentTypes); | ||
template <class CompType, class... ComponentTypes> | ||
constexpr size_t index_of_component = container_impl::get_cls_pos_v<CompType, ComponentTypes...>; | ||
|
||
template <class... ComponentTypes> using SequenceIdx = std::array<std::vector<Idx2D>, n_types<ComponentTypes...>>; | ||
template <class... ComponentTypes> using ComponentFlags = std::array<bool, n_types<ComponentTypes...>>; | ||
|
||
// run functors with all component types | ||
template <class... Types, class Functor> constexpr void run_functor_with_all_types_return_void(Functor functor) { | ||
(functor.template operator()<Types>(), ...); | ||
} | ||
template <class... Types, class Functor> constexpr auto run_functor_with_all_types_return_array(Functor functor) { | ||
return std::array { functor.template operator()<Types>()... }; | ||
} | ||
|
||
} // namespace power_grid_model::main_core::utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.