-
Notifications
You must be signed in to change notification settings - Fork 66
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
Refactor the abstract class CreateConnectedElementI #1047
Conversation
…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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ng the right type
Was stored as pointer before. This change solves potentially dangling pointers after object goes out-of-scope.
There was a problem hiding this 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
- This is untested GUI code anyway, so no need to look at the coverage report
- Waiting for CI to be fixed and then having to merge main back into this would be a little bit annoying.
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