Skip to content

Conversation

@jcurtis2
Copy link
Member

Attempting to simplify code by introducing templates for setting and getting of attributes and derived values.

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.21%. Comparing base (f924d65) to head (efdc266).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
+ Coverage   91.04%   91.21%   +0.16%     
==========================================
  Files          55       56       +1     
  Lines        2636     2618      -18     
  Branches      144      144              
==========================================
- Hits         2400     2388      -12     
+ Misses        163      157       -6     
  Partials       73       73              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jcurtis2 jcurtis2 self-assigned this Nov 24, 2025
@Griger5
Copy link
Collaborator

Griger5 commented Nov 24, 2025

Maybe it would be beneficial to "abstract" the templates even more? get_value and set_value look the same in env_state.hpp and aero_particle.hpp. Maybe we could do something like this in a separate header (named getters.hpp ?):

namespace pypartmc { // possible namespace to avoid name conflicts

template <typename T, typename SelfType, typename Func>
inline T get_value(const SelfType &self, Func func) { // inline to keep it header-only
    T value{};
    func(self.ptr.f_arg(), &value);
    return value;
}

template <typename T, typename SelfType, typename Func>
inline void set_value(SelfType &self, Func func, T value) {
    func(self.ptr.f_arg_non_const(), &value);
}

}

And an example call would look like:

static auto get_height(const EnvState &self) {
     return pypartmc::get_value<double>(self, f_env_state_get_height);
}

The same could be considered for get_derived_value and get_derived_value_env_state. I'm not sure if these ones have a lot of uses in other classes, but even if they do not now, they could do in the future!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants