Skip to content

Commit dd65f3b

Browse files
committed
move out container queries
Signed-off-by: Nitish Bharambe <[email protected]>
1 parent 68ebe00 commit dd65f3b

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
3+
//
4+
// SPDX-License-Identifier: MPL-2.0
5+
6+
#pragma once
7+
8+
#include "../container.hpp"
9+
10+
namespace power_grid_model::main_core {
11+
12+
// TODO Reconfirm if there is duplication with state_queries and if we can remove either one of them
13+
14+
template <typename ComponentType, class ComponentContainer>
15+
requires extended_component_container_c<ComponentContainer, ComponentType>
16+
constexpr auto get_component_size(ComponentContainer const& components) {
17+
return components.template size<ComponentType>();
18+
}
19+
20+
template <typename ComponentType, class ComponentContainer>
21+
requires extended_component_container_c<ComponentContainer, ComponentType>
22+
inline Idx get_component_sequence_idx(ComponentContainer const& components, auto const& id_or_index) {
23+
return components.template get_seq<ComponentType>(id_or_index);
24+
}
25+
26+
} // namespace power_grid_model::main_core

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/state_queries.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@
1010

1111
namespace power_grid_model::main_core {
1212

13-
// using only components and not state
14-
15-
template <typename ComponentType, class ComponentContainer>
16-
requires extended_component_container_c<ComponentContainer, ComponentType>
17-
constexpr auto get_component_size(ComponentContainer const& components) {
18-
return components.template size<ComponentType>();
19-
}
20-
21-
template <typename ComponentType, class ComponentContainer>
22-
requires extended_component_container_c<ComponentContainer, ComponentType>
23-
inline Idx get_component_sequence_idx(ComponentContainer const& components, auto const& id_or_index) {
24-
return components.template get_seq<ComponentType>(id_or_index);
25-
}
26-
27-
// existing implementation
28-
2913
template <typename ComponentType, class ComponentContainer>
3014
requires model_component_state_c<MainModelState, ComponentContainer, ComponentType>
3115
inline Idx get_component_type_index(MainModelState<ComponentContainer> const& state) {

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#pragma once
66

7+
#include "container_queries.hpp"
78
#include "state.hpp"
8-
#include "state_queries.hpp"
99

1010
#include "../all_components.hpp"
1111

0 commit comments

Comments
 (0)