-
Notifications
You must be signed in to change notification settings - Fork 42
Clean-up main model: move topology related construction #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+238
−171
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e6728db
move construct topology
nitbharambe 0c065ea
address sonar cloud
nitbharambe df0dcbf
decouple topology related state queries
nitbharambe 3d29f46
shift to component container
nitbharambe 68ebe00
move concepts to container_fwd
nitbharambe dd65f3b
move out container queries
nitbharambe 8597a46
change size retrieval to component query
nitbharambe fbbaa5e
decouple topology from state
nitbharambe 1ab7ee8
homogenize registration
nitbharambe 317c8ed
rename common function to generic name
nitbharambe 423dcd2
resolve todos
nitbharambe 5937456
rename to retrievable type
nitbharambe ca5ae3f
address comments 1
nitbharambe f339e21
move to detail namespace
nitbharambe 0711e10
add to common namespace
nitbharambe 077f892
merge both concepts to one
nitbharambe 79c1da4
workaround compiler bug and address end()
nitbharambe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
power_grid_model_c/power_grid_model/include/power_grid_model/container_fwd.hpp
This file contains hidden or 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,31 @@ | ||
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
#include "common/common.hpp" | ||
|
||
#include <concepts> | ||
|
||
namespace power_grid_model::common { | ||
|
||
namespace detail { | ||
template <typename ContainerType, typename RetrievableType> | ||
concept single_component_container_c = requires(ContainerType const& c, ID id, Idx2D idx2d) { | ||
{ c.template citer<RetrievableType>().begin() } -> std::forward_iterator; | ||
{ c.template citer<RetrievableType>().end() } -> std::forward_iterator; | ||
{ *(c.template citer<RetrievableType>().begin()) } -> std::same_as<RetrievableType const&>; | ||
{ | ||
c.template citer<RetrievableType>().end() | ||
} -> std::same_as<decltype(c.template citer<RetrievableType>().begin())>; | ||
{ c.template get_item<RetrievableType>(id) } -> std::convertible_to<RetrievableType const&>; | ||
{ c.template size<RetrievableType>() } -> std::same_as<Idx>; | ||
{ c.template get_seq<RetrievableType>(idx2d) } -> std::same_as<Idx>; | ||
}; | ||
} // namespace detail | ||
|
||
template <typename ContainerType, typename... RetrievableType> | ||
concept component_container_c = (detail::single_component_container_c<ContainerType, RetrievableType> && ...); | ||
|
||
} // namespace power_grid_model::common |
25 changes: 25 additions & 0 deletions
25
power_grid_model_c/power_grid_model/include/power_grid_model/main_core/container_queries.hpp
This file contains hidden or 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,25 @@ | ||
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
#include "../container.hpp" | ||
|
||
namespace power_grid_model::main_core { | ||
|
||
// TODO Reconfirm if there is duplication with state_queries and if we can remove either one of them | ||
|
||
template <typename ComponentType, class ComponentContainer> | ||
requires common::component_container_c<ComponentContainer, ComponentType> | ||
constexpr auto get_component_size(ComponentContainer const& components) { | ||
return components.template size<ComponentType>(); | ||
} | ||
|
||
template <typename ComponentType, class ComponentContainer> | ||
requires common::component_container_c<ComponentContainer, ComponentType> | ||
inline Idx get_component_sequence_idx(ComponentContainer const& components, auto const& id_or_index) { | ||
return components.template get_seq<ComponentType>(id_or_index); | ||
} | ||
|
||
} // namespace power_grid_model::main_core |
This file contains hidden or 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 hidden or 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
246 changes: 145 additions & 101 deletions
246
power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.