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

Add Getters and Setters for the elements of sequences #59

Open
joergbrech opened this issue Dec 5, 2024 · 0 comments
Open

Add Getters and Setters for the elements of sequences #59

joergbrech opened this issue Dec 5, 2024 · 0 comments

Comments

@joergbrech
Copy link
Contributor

joergbrech commented Dec 5, 2024

In the CPACS schema we have many types that wrap sequences, e.g. Fuselages, Wings, Segments, Positionings. From these the code generator creates classes that have a std::vector<std::unique_ptr<XYZ>> member, where XYZ is Fuselage, Wing, Segment, Positioning, respectively. Each generated class provides getters and setters for this vector.

For the internal python bindings of TiGL, however, we prefer not to expose std::vector and std::unique_ptr to the Python API (at least to a large degree). This means that the output of CCPACSWings.get_wings in Python is not a list, but an opaque SwigPyObject that cannot be subscripted.

For most of these "sequence classes" we have getters for elements in the customized classes. For example in CCPACSWings, which is derived from CPACSWings, we have the following getters:

https://github.com/DLR-SC/tigl/blob/c5ccbb2b3a22a397e5fcb727cec1b1d1647be5cc/src/wing/CCPACSWings.h#L52-L56

    // Returns the total count of wings in a configuration
    TIGL_EXPORT int GetWingCount() const;

    // Returns the wing for a given index.
    TIGL_EXPORT CCPACSWing& GetWing(int index) const;

    // Returns the wing for a given UID.
    TIGL_EXPORT CCPACSWing& GetWing(const std::string& UID) const;

These getters are automatically exposed to Python. They are necessary to traverse the CPACS tree if we don't wrap the std::vector<std::unique_ptr<XYZ>> classes with SWIG.

Therefore, it would be quite convenient if these getters and setters were part of the generated classes. Otherwise they would have to be added manually to any class that is exposed via the Python bindings.

This is related to DLR-SC/tigl#936.

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

No branches or pull requests

1 participant