Skip to content

Cleanup main model: Clean all includes and make some components to be forward declared#1142

Draft
nitbharambe wants to merge 29 commits intomainfrom
feature/component-fwd-cleanup
Draft

Cleanup main model: Clean all includes and make some components to be forward declared#1142
nitbharambe wants to merge 29 commits intomainfrom
feature/component-fwd-cleanup

Conversation

@nitbharambe
Copy link
Member

Idea is to make components forward declared to reduce coupling.

This draft PR is created for gathering thoughts and requirements as of now.

Changes proposed in this PR include:

  • Forward declared all components
  • Removed unecessary exception and logging includes.

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe self-assigned this Sep 29, 2025
@nitbharambe nitbharambe added the improvement Improvement on internal implementation label Sep 29, 2025
@figueroa1395
Copy link
Member

I like the cleanup. Now I wonder, should we move all_components.hpp to the component folder? Also seems intuitive to me to rename component.hpp to all_components_fwd.hpp, or somehow homogenize the two.

In addition, can we also include component_list in this "revolution"? Perhaps it now belongs in component.hpp and we try to keep all component related stuff in one location only.

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@sonarqubecloud
Copy link

nitbharambe and others added 6 commits December 11, 2025 12:47
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe marked this pull request as ready for review January 7, 2026 13:32
Copy link
Member

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional thing is that perhaps #1142 (comment) is still relevant. Also, maybe triggering Copilot for review might be useful since missing things for a human due to the nature of this PR is very easy.

Rest looks good, just minor questions.

nitbharambe and others added 2 commits January 12, 2026 09:26
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Comment on lines 7 to 10
#include "power_grid_model/auxiliary/update.hpp"
#include <power_grid_model/common/common.hpp>
#include <power_grid_model/common/enum.hpp>
#include <power_grid_model/component/component.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency between "" and <>

Comment on lines 7 to 10
#include "power_grid_model/auxiliary/input.hpp"
#include "power_grid_model/auxiliary/output.hpp"
#include "power_grid_model/auxiliary/update.hpp"
#include <power_grid_model/calculation_parameters.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency between "" and <> (please check all files)

Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@nitbharambe nitbharambe marked this pull request as draft January 26, 2026 14:32
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
nitbharambe and others added 7 commits February 2, 2026 17:14
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
Signed-off-by: Nitish Bharambe <nitish.bharambe@alliander.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

@nitbharambe nitbharambe changed the title Cleanup main model: Make components to be forward declared Cleanup main model: Clean all includes and make some components to be forward declared Feb 3, 2026
Copy link
Member

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan of this! I just left a couple remarks.

#include "meta_data.hpp"

#include "../common/common.hpp"
#include "../common/counting_iterator.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed out by the CI, add this via Jinja instead of directly editing here.

Comment on lines 10 to -13

#include "../common/common.hpp"
#include "../common/enum.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem.

Comment on lines +5 to +10
#include "power_grid_model_cpp/basics.hpp"
#include "power_grid_model_cpp/buffer.hpp"
#include "power_grid_model_cpp/dataset.hpp"
#include "power_grid_model_cpp/handle.hpp"
#include "power_grid_model_cpp/model.hpp"
#include "power_grid_model_cpp/serialization.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From "" to <>.


#include <doctest/doctest.h>

// NOLINTBEGIN(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see many of these, probably related to nlohmann/json. Shouldn't we instead exclude it via misc-include-cleaner.IgnoreHeaders as we did with Eigen?

]
}
})json"s;
})json"s; // NOLINT(misc-include-cleaner) https://github.com/llvm/llvm-project/issues/98122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are annoying but I guess there is nothing else to do about them...

auto const& attribute_name = MetaData::attribute_name(attribute_meta);
// TODO need a way for common angle: u angle skipped for now
if (attribute_name == "u_angle"s) {
if (attribute_name == "u_angle"s) { // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed adding github issue name there. Same as others. Its with operator s

auto const& node = meta_map.get_component("node");
auto const& node_attr = node.attributes;
CHECK(node_attr[0].name == "id"s);
CHECK(node_attr[0].name == "id"s); // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these a problem here?

#include <power_grid_model/common/exception.hpp>
#include <power_grid_model/common/grouped_index_vector.hpp>
#include <power_grid_model/common/three_phase_tensor.hpp>
#include <power_grid_model/math_solver/short_circuit_solver.hpp> // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it asking to directly import things called in the short circuit module? Or what's the issue?

// SPDX-License-Identifier: MPL-2.0

#include "test_math_solver_pf.hpp"
#include "test_math_solver_pf.hpp" // NOLINT(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on board with this one and the other similar ones that are used in the template testing.

#2: source: u_ref = 1.10, sym_load_3: -200 kW
*/

// NOLINTBEGIN(misc-include-cleaner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no // NOLINTEND(misc-include-cleaner). Also, shouldn't we also be explicit like with the CPP API here? Why no lint here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I put the end at the bottom. This file is completely ignored as it as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement on internal implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants