Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inheritance with Remote Objects
Forum Updated to NodeBB v4.3 + New Features

Inheritance with Remote Objects

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moohasha
    wrote on 10 Apr 2018, 13:40 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 10 Apr 2018, 13:53 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Moohasha
        wrote on 10 Apr 2018, 14:29 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 10 Apr 2018, 14:47 last edited by mrjj 4 Oct 2018, 14:47
          #4

          @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)

          M 1 Reply Last reply 10 Apr 2018, 17:24
          0
          • M mrjj
            10 Apr 2018, 14:47

            @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)

            M Offline
            M Offline
            Moohasha
            wrote on 10 Apr 2018, 17:24 last edited by
            #5

            @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.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 10 Apr 2018, 17:34 last edited by
              #6

              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.

              1 Reply Last reply
              0

              1/6

              10 Apr 2018, 13:40

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved