expose parent class methods in derivated class

Asked by sipiatti

Hi!

Is it possible to expose (ladonize) the methods of a parent class? If it is than how?

I tried the following: http://pastebin.com/KqnpbFDn

TestService3 doesn't have served (ladonized) helloWorld method

Question information

Language:
English Edit question
Status:
Solved
For:
ladon Edit question
Assignee:
No assignee Edit question
Solved by:
sipiatti
Solved:
Last query:
Last reply:
Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#1

Hi Sipiatti.

Sorry about the response time. I'm pretty hung up for at work right now.

Ladon uses the ast (Abstract Syntax Tree) module to parse service methods. This method does not do inheritance parsing, so for Ladon to do what you want, it would be nessecary to extend Ladon with recursive ast parsing.

Still when you inherit a service class from another service class you can use it's methods. And you can do like this:

http://paste.kde.org/482228/

Another thing you should be aware of is, that if you are able to inherit a service class it must meen that the service is already imported and available, and you might not even want to re-expose all it's methods. In the company I work in we use service inheritance too, and it does exactly what we want. For instance we have a SettingsService that has som basic methods that other clients should be able to use. Then we have another more specialized settings service for App1 let's call it App1SettingsService. It inherits SettingsService and thereby uses the methods from SettingsService directly (not via network protocols). App1SettingsService exposes some App1 specific setting methods reusing code from SettingsService. So the situation seen from the client side is:

SettingsService
  + write()
  + read()
  + list_keys()

App1SettingsService
  + saveProfile() - uses SettingsService.write()
  + loadProfile() - uses SettingsService.read()
  + listProfiles() - uses SettingsService.list_keys()

Best Regards
Jakob Simon-Gaarde

Revision history for this message
sipiatti (sipiatti) said :
#2

Hi Jakob,

thanks for your answer, that is what I expected. So it is a sort of a workaround but it works.
With logical planning and structure I can avoid the need of auto expose an inherited method.

Thanks again, regards
sipiatti