Closed MarAlder closed 2 years ago
Hi,
The problem is that the variable model
is of type std::unique_ptr<CPACSAircraftModel>
, so a copy of the unique_ptr would be generated in the following line due to the assignment, which is not possible (would not be unique any more):
auto model = m_cpacsTree->GetVehicles()->GetAircraft()->GetModels().at(0);
Instead of copying the unique_ptr you could take a reference to it by changing the code to:
auto& model = m_cpacsTree->GetVehicles()->GetAircraft()->GetModels().at(0);
The uID manager is not relevant in this case.
Ok, this makes sense. Thanks!
And then, how to I finally get the reference node? I can see from the debugger that all the member variables are initialized in my model
, but calling the getter functions like below is obviously wrong:
m_cpacsTree->GetVehicles()->GetAircraft()->GetModels().at(0)->GetReference();
Getting the reference-node via the GetReference
function should be fine. The reference node is optional, thus the function returns a reference to the boost::optional type:
CPLIB_EXPORT virtual boost::optional<CPACSReference>& GetReference();
So accessing it could be written for example:
const auto& reference = m_cpacsTree->GetVehicles()->GetAircraft()->GetModels().at(0)->GetReference();
if (reference) {
const auto& point = reference->GetPoint();
}
Edit: I'll delete what I just wrote as I forgot an include of CPACSAircraftModel.h
in my test file... :flushed:
Thanks for your help, R.!!
Being happy about the answer and therefore closing the issue :)
Hi,
I'm generating classes for
cpacs/header/...
andcpacs/vehicles/aircraft/model/reference/...
to use it for my cpacsLibrary project.The first one is working fine in my test cases, e.g.:
However, I can't access the reference node. Is this the intended way to get an aircraft model?:
I guess the
unique_ptr
usage is not yet clear to me, as my (MinGW) compiler complains:Until now my cpacsLibrary only has a dummy uID manager (just the function declarations, no content yet). But this should not be used at this point anyway, should it?
generated.zip