-
Notifications
You must be signed in to change notification settings - Fork 3
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
Object inheritance and ocpp.hpp.j2 declare_record macro #19
Comments
You've found a big hole. Inheritance for Inheritance doesn't have a conceptual counterpart in JSON Schema so it can not be applied for validation. What does it even mean if one JSON object "inherits" from another? It's an undefined thing with multiple possible interpretations. I've always been suspicious of even adding "support" for it in moo schema and did so under some slight duress. I'd be happy to remove it. Any use for inheritance that I can come up in this context can just as well be accomplished by composition. HaveA instead of IsA. So, if we really must push on whatever "inheritance" might mean in this context, let's come up with some use cases. Note, there is a sort of inheritance that exists now in that a record is serialized as a "bag of attributes". This was already discussed elsewhere which I can dig up or repeat if needed. |
Ah-ha! The request for some use cases is very reasonable, but I'm afraid I don't have one ready yet. I think the suggestion for object inheritance came from @glemanmiotto so we should bring her in this conversation, maybe |
Okay. I'll leave this ticket open. If people have input, please give it. And we can also discuss elsewhere. |
@glehmannmiotto was missing a few characters and thus wasn't notified. ;-) |
Sorry about that! GitHub is horrible when it comes to find users... |
Hi @glehmannmiotto @alessandrothea I feel we must think of data structure "inheritance" somewhat differently than we do class inheritance because there is no behavior involved (no methods, no C++
The bases pattern most closely matches our notion of C++ If C++ BTW, this deserialization-based inheritance pattern can also be used to remove the need for the |
Hi again,
Playing around I tried to create a C++ struct using the schema inheritance that moo provides, but with no luck.
The base class doesn't seem to end up in the generated
Struct.hpp
file.A look into
ocpp.hpp.j2
'sdeclare_record
makes me suspect that the issue that the macro doesn't yet take into account inheritance.Is that the case or is there some other trick to make handle inheritance correctly when rendering the C++ structs?
Thanks!
Alessandro
P.S.: I meant to check the nlohmann json functions generation, but haven't managed yet.
The text was updated successfully, but these errors were encountered: