Unsolved Inheritance with Remote Objects
-
When defining a class in a .rep file, is it possible to define a base class, whether that be another remote object type or just some other custom class? Basically I want to be able to do something like.
// DerivedClass.rep class DerivedClass : public BaseClass { PROP(bool someProp=false); SLOT(some_slot(bool prop)); };
But when I do that, I get an error from the remote object compiler.
-
Hi
Maybe show the actual error from repc ?
But i doubt its possible as its not a real compiler as such and inheritance is
pretty complex. -
Thanks for the prompt reply.
The error from repc is simply "Unknown token encountered" on the class declaration line.
I understand that repc is not a real compiler, and like moc it really just generates new code for you. I was just hoping there was some syntax that repc recognized that tells it "this class inherits from another remote object class".
If that's not possible, I suppose we could write the child class code by hand and not use repc, but that seems like a burden and not sustainable.
-
@Moohasha said in Inheritance with Remote Objects:
, I suppose we could write the child class code by hand and not use repc, but that seems like a burden and not sustainable.
Yes, i also thought about that but (bases from rep file) and child objects in
code. But i agree. its not optimal maintenance wise.I have not looked at repc code but im wondering how hard it would be to add this feature.
If you not plan on deep inheritance, you basically just want to add any PROPs from base to the child object So that the final generated class contains both. ( i assume) -
@mrjj said in Inheritance with Remote Objects:
If you not plan on deep inheritance, you basically just want to add any PROPs from base to the child object So that the final generated class contains both. ( i assume)
No, I mean actual inheritance where class A inherits class B, not class A and class B are both remote objects and class A includes all of class B's properties.
Perhaps this is a problem I need to solve in my own application. One of the things I don't like about the QtRO module is that the Source and Replica classes are different types, so I can't write code that is common in both the server and client software that takes some type defined by a remote object. I've worked around this by using the remote object internally and wrapping them in my own interfaces, much of which are direct pass through code to either the Source or Replica.
I suppose I could carry that same pattern further. If my class A inherits from class B, I could have class A RO and a class B RO that contain the properties unique to class A and class B and simply serve as the back end to each.
-
Hi
Ok so you want true inheritance also in the generated objects. I assume this
would require substantial changes to the generator.I would ask the devs if they know a good workaround / suggestions.
http://lists.qt-project.org/mailman/listinfo/development
The module is pretty new and i have not seen many posts from users.I agree that using an interface design might be the way to go but on the other hand
specifying it directly in the .rep file would be far more optimal.