♻️ Refactor FoMaC classes#1849
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
burgholzer
left a comment
There was a problem hiding this comment.
This generally looks good to me and we can happily move forward with this, if you @MatthiasReumann feel confident in the changes.
I have two very small comments and a medium one that we could also tackle after this PR to not stall it for too long.
In any case, this still needs labels and a changelog entry.
We should also backport these changes to the v3.x series so that the changes can go into the next release there.
@denialhaag for awareness.
| } | ||
|
|
||
| /// @returns the underlying QDMI_Device object. | ||
| [[nodiscard]] QDMI_Device getQDMIDevice() const { return device_; } |
There was a problem hiding this comment.
Would getHandle potentially be a better name? one could also generically call these private members handle_ because that's what they essentially are. The above method would/could then also become fromHandle.
There was a problem hiding this comment.
Yes, I like that 👍🏻
Because you mention fromHandle (or fromQDMIDevice): Could you maybe elaborate a bit on what the rationale of the Tokens was? Because as far as I can tell fromQDMIDevice short-circuits these guardrails anyway (only to make the Python bindings work...).
A question that I've asked myself is: Would it be that bad to be able to construct a "Site" class from a site QDMI pointer?
There was a problem hiding this comment.
Interestingly, I just re-googled the definition of "handle". Apparently, a "handle" is the object holding the raw pointer (basically our FoMaC classes!). So ptr_ and fromPointer would probably be semantically even more correct. Analogously to unique_ptr the method get could then return the underlying pointer.
Let me know what you think!
There was a problem hiding this comment.
Yes, I like that 👍🏻
Because you mention
fromHandle(orfromQDMIDevice): Could you maybe elaborate a bit on what the rationale of theTokens was? Because as far as I can tellfromQDMIDeviceshort-circuits these guardrails anyway (only to make the Python bindings work...). A question that I've asked myself is: Would it be that bad to be able to construct a "Site" class from a site QDMI pointer?
I am on that recovering my thoughts about the Tokens. I do remember that I also considered friend classes but deliberately decided against them. Give me some minutes to recover my rationale there.
There was a problem hiding this comment.
I'll answer in the main thread of this PR as I deem it as fundamental for this PR.
|
@MatthiasReumann Continuing the discussion in #1849 (comment): The initial motivation of the To implement the described behavior, I decided to use The AI also mentioned that the Python bindings do not understand friendship. However, I do not recall, how this influenced the decision but maybe a point to check/keep in mind. |
The reason for the token solution was exactly to avoid friend semantics. I am (personally) not the biggest fan of them because it always feels like bad design to me. Regarding the overall abstraction: I think we could allow ourselves some freedom and do not necessarily stick to the C design. However, one has to be careful that most of the opaque pointers (site, operation, job, etc.) are tied to a particular session with a device. |
I think there is only one way to use friendships correctly in C++: A friend class
This is what bugs me about the Python bindings using the |
Yeah. This feels fine 👍🏻
Yeah. There are a couple more things that bother me about certain ergonomics at the moment. Most importantly the way we inject external QDMI device libraries at runtime, which circumvents the QDMI client interface. But it was the only way to pass authentication information to the actual device. |
|
Okay. Maybe let's summarize the discussion and action items up to this point to get this current PR merged.
Sounds good? |
Sounds good to me 👍🏻 |
Description
Proposed FoMaC rewrite:
unique_ptrinstead of custom destructor, copy, and move semantics.std::size_tvssize_t, etc.)Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.