Skip to content
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

Bmi_Adapter cleanup, de-template #646

Merged
merged 11 commits into from
Nov 13, 2023

Conversation

PhilMiller
Copy link
Contributor

@PhilMiller PhilMiller commented Sep 21, 2023

Templates that don't actually provide any polymorphic behavior are just a waste of compilation time and binary size. So, get rid of one.

Also, implementation inheritance (the bmi_model member) isn't very favorable in general, and even less so when the base class isn't actually providing anything

Changes

  • Simplify implementation of Bmi_Adapter class to make further refactoring easier
  • Move the single CRTP template-parameter-dependent shared_ptr<T> bmi_model member down to child classes
  • De-template Bmi_Adapter
  • Improve an error message that would have helped with an intermediate bug in my changes
  • Mark copy/move constructors that shouldn't get called = delete;
  • Convert member pointers 'bmi_model' to various backing types from shared_ptr to unique_ptr to clarify that they have strict exclusive ownership

Testing

Ordinary CI test suite

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

@PhilMiller PhilMiller changed the title Bmi adapter cleanup Bmi_Adapter cleanup, de-template Sep 23, 2023
program--

This comment was marked as outdated.

@PhilMiller PhilMiller marked this pull request as ready for review November 8, 2023 00:12
@PhilMiller PhilMiller marked this pull request as draft November 8, 2023 00:42
This avoids giving the impression that there should ever actually be
shared ownership - a model instance is always exclusively held by the
single adapter instance that created it.

Leave the C++ adapter alone for now due to the more complicated
lifetime logic that it implements.

Leave the Python adapted alone because the unit tests do silly things
with reaching in and grabbing the underlying object.
@PhilMiller PhilMiller marked this pull request as ready for review November 8, 2023 22:26
@PhilMiller
Copy link
Contributor Author

I think this is ready for re-review and integration. I'm done poking at the adapters for now. I'm going to try to tackle some of the rampant silly duplication in the Formulation classes next.

@PhilMiller PhilMiller merged commit 7687cfc into NOAA-OWP:master Nov 13, 2023
17 of 19 checks passed
@PhilMiller PhilMiller deleted the bmi-adapter-cleanup branch November 13, 2023 21:33
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.

2 participants