RISCSoftware / cpacs_tigl_gen

Generates CPACS schema based classes for TiGL
Apache License 2.0
5 stars 5 forks source link

Return XPath #45

Closed MarAlder closed 8 months ago

MarAlder commented 2 years ago

Hi,

I propose to add a method which returns the current XPath. Something like:

CPLIB_EXPORT virtual const std::string& GetXPath() const;
const std::string& aeroMapType::GetXPath() const
    {
        return m_xPath;
    }

m_xPath could be set in ReadCPACS.

This could be useful information, e.g. to make aeroMaps selectable in a GUI: grafik

What do you think? I could try to implement a first draft.

MarAlder commented 2 years ago

So a solution might look like dac589e. It's working in my own test cases, but I have not touched the generator test cases yet.

bernhardmgruber commented 2 years ago

I understand your use case, but unfortunately your implementation will break if you mutate the CPAS tree at runtime (e.g. removing an aeroMap and then asking for the xpath. To allow for mutation, you would constantly need to update xpaths. I think it's better to avoid this duplication of structure information and always build the xpath form the actual tree in memory.