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

Refactor the abstract class CreateConnectedElementI #1047

Merged

Conversation

svengoldberg
Copy link
Contributor

@svengoldberg svengoldberg commented Dec 19, 2024

Description

In the current implementation of the CPACS Creator, the Wing and Fuselage class are inherited from an abstract class (cf. #1042). We want to avoid this behaviour and fix the code style by removing this class and adding a new std::variant type instead. In the actual code, it is then decided whether the current object is of type Wing or Fuselage and the respective member function is called.
Later on, the variant type can be extended by any other class (such as Duct, Pylon, Tank, ...), if the CPACS Creator should be able to add CPACS elements/sections within the according object.

The general procedure (and whether this is the best way) of course still can be discussed. Nonetheless, @joergbrech and I had a disscussion about it and agreed that using std::variant seems to be a good way to solve this code style issue.

Fix #1042

EDIT:

After some discussion, we agreed on discarding the std::variant way. Instead, a new (somehow) interface class is introduced which gets along without inheritance and therefore does not add some artifical structure layer.
In the class, the constructor has a template parameter to 'decide' the type of the incomming object

Task Finished Reviewer Approved
At least one test for the new functionality was added.
  • yes
  • does not apply
  • OK
New classes have been added to the Python interface.
  • yes
  • does not apply
  • OK
The code is properly documented with doxygen docstrings
  • yes
  • does not apply
  • OK
Changes are documented at the top of ChangeLog.md
  • yes
  • does not apply
  • OK

…riant

In the current implementation of the CPACS Creator, the Wing and Fuselage class are inherited from an abstract class. We want to avoid this behaviour and fix the code style by removing this class and adding a new std::variant type instead. In the actual code, it is then decided whether the current object is of type Wing or Fuselage and the respective member function is called.
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.40%. Comparing base (2466e1d) to head (6b8166b).
Report is 11 commits behind head on cpacs_creator_dev_merge.

Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                    @@
##           cpacs_creator_dev_merge    #1047   +/-   ##
========================================================
  Coverage                    71.40%   71.40%           
========================================================
  Files                          312      312           
  Lines                        28978    28976    -2     
========================================================
  Hits                         20691    20691           
+ Misses                        8287     8285    -2     
Flag Coverage Δ
unittests 71.40% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/fuselage/CCPACSFuselage.h 100.00% <ø> (ø)
src/wing/CCPACSWing.h 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

TIGLViewer/src/modificators/ModificatorSectionsWidget.cpp Outdated Show resolved Hide resolved
TIGLViewer/src/modificators/ModificatorSectionsWidget.cpp Outdated Show resolved Hide resolved
TIGLViewer/src/modificators/ModificatorSectionsWidget.cpp Outdated Show resolved Hide resolved
TIGLViewer/src/ModificatorManager.cpp Outdated Show resolved Hide resolved
Was stored as pointer before. This change solves potentially dangling pointers after object goes out-of-scope.
Copy link
Contributor

@joergbrech joergbrech left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks! I was gonna wait until CI works again with the merge, but

  1. This is untested GUI code anyway, so no need to look at the coverage report
  2. Waiting for CI to be fixed and then having to merge main back into this would be a little bit annoying.

@joergbrech joergbrech merged commit eb3184e into cpacs_creator_dev_merge Jan 22, 2025
14 of 15 checks passed
@joergbrech joergbrech deleted the 1042_cpacs_creator_refactor_interface branch January 22, 2025 22:48
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