Skip to content

Remove the class FGPropertyNode#1270

Merged
bcoconni merged 8 commits intoJSBSim-Team:masterfrom
bcoconni:remove_FGPropertyNode
Apr 27, 2025
Merged

Remove the class FGPropertyNode#1270
bcoconni merged 8 commits intoJSBSim-Team:masterfrom
bcoconni:remove_FGPropertyNode

Conversation

@bcoconni
Copy link
Member

As per the issue reported in #834 (comment) and the discussion that followed, this PR removes the class FGPropertyNode from JSBSim.

Direct calls to SGPropertyNode allow to avoid the dubious conversion from SGPropertyNode* to FGPropertyNode* in methods such as the one below:

FGPropertyNode::GetNode (const string &relpath, int index, bool create)
{
SGPropertyNode* node = getNode(relpath.c_str(), index, create);
if (node == 0) {
cerr << "FGPropertyManager::GetNode() No node found for " << relpath
<< "[" << index << "]" << endl;
}
return (FGPropertyNode*)node;
}

Note that this PR does not remove FGPropertyNode from the Python module which keeps its methods unchanged including FGPropertyNode.get_fully_qualified_name(). Not sure if renaming it to SGPropertyNode and making get_fully_qualified_name() a function is a better option ?

@codecov
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 57.62712% with 25 lines in your changes missing coverage. Please review.

Project coverage is 24.77%. Comparing base (6b81abf) to head (7dc4554).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/input_output/FGScript.cpp 0.00% 3 Missing ⚠️
src/input_output/FGInputSocket.cpp 0.00% 2 Missing ⚠️
src/input_output/FGOutputType.cpp 0.00% 2 Missing ⚠️
src/input_output/FGPropertyManager.cpp 83.33% 2 Missing ⚠️
src/models/FGGasCell.cpp 0.00% 2 Missing ⚠️
src/models/flight_control/FGFCSComponent.cpp 0.00% 2 Missing ⚠️
src/FGFDMExec.cpp 66.66% 1 Missing ⚠️
src/input_output/FGPropertyReader.h 0.00% 1 Missing ⚠️
src/input_output/FGUDPInputSocket.cpp 0.00% 1 Missing ⚠️
src/math/FGFunction.cpp 0.00% 1 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1270      +/-   ##
==========================================
- Coverage   24.78%   24.77%   -0.02%     
==========================================
  Files         169      169              
  Lines       19656    19598      -58     
==========================================
- Hits         4872     4855      -17     
+ Misses      14784    14743      -41     

☔ 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.

@gallonmate
Copy link
Contributor

Could you also replace the FGPropertyNode with SGPropertyNode in the Unreal Plugin? Just these two below. The rest of the code should work fine as is. I could submit a PR later but figured it could be included with your PR. Thanks :)

FGPropertyNode* node = PropertyManager->GetNode(TCHAR_TO_UTF8(*Property), false);

FGPropertyNode* node = PropertyManager->GetNode(TCHAR_TO_UTF8(*Property[i]), false);

@seanmcleod70
Copy link
Contributor

I'm not a great fan of using auto a lot. Sure for fairly complicated template based types like this I have no issue.

map<int,list<string>>::iterator i = m.begin();
auto i = m.begin();

But for these sorts of cases when I'm browsing code I'd prefer to see SGPropertyNode* prop than auto prop. If I want to know whether prop is being used appropriately I need to go and take a look at getNode (name in this case sort of gives it away) to see what it's returning, is it a bool or some node pointer, if so which one FGPropertyNode* or SGPropertyNode* etc. I think it just makes it more difficult and means more work for the reader.

    bool HasNode(const std::string& path) const
    {
      std::string newPath = path;
      if (newPath[0] == '-') newPath.erase(0,1);
      auto prop = root->getNode(newPath);
      return prop;
    }

Also would prefer return prop != nullptr again to make it more explicit to the reader compared to the implicit "type-cast" to bool.

@seanmcleod70
Copy link
Contributor

Noticed a couple of other places where the dangerous cast up to a FGPropertyNode* was happening, e.g. FGPropertyNode* operator*(), which you've now fixed. Guessing they weren't code paths that were hit with usban.

@bcoconni bcoconni force-pushed the remove_FGPropertyNode branch from 203be93 to 7dc4554 Compare April 27, 2025 10:51
@bcoconni
Copy link
Member Author

Could you also replace the FGPropertyNode with SGPropertyNode in the Unreal Plugin?

Yep! Done. Thanks for the heads up @gallonmate 👍

I'm not a great fan of using auto a lot. [...] I'd prefer to see SGPropertyNode* prop than auto prop.

Fair enough I've replaced all the new occurrences of auto by explicit type names.

Also would prefer return prop != nullptr again to make it more explicit to the reader compared to the implicit "type-cast" to bool.

Done ! Thanks for the comments @seanmcleod70.

@seanmcleod70
Copy link
Contributor

All looks good.

@bcoconni bcoconni merged commit a222488 into JSBSim-Team:master Apr 27, 2025
29 checks passed
@bcoconni bcoconni deleted the remove_FGPropertyNode branch April 27, 2025 12:46
@bcoconni
Copy link
Member Author

All looks good.

Thanks. PR merged.

bcoconni added a commit to bcoconni/jsbsim that referenced this pull request May 2, 2025
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.

3 participants