It is currently Thu Feb 09, 2012 1:37 am

All times are UTC



Welcome
Welcome to RHAPSODY4YOU

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, respond to polls, upload and download content, and access many other special features. Registration is fast, simple, and absolutely free, so please, register to join our community today.





 Page 1 of 1 [ 15 posts ] 
Author Message
 Post subject: Multiple inheritance from reactive classes is not supported
PostPosted: Wed Jun 09, 2010 7:24 pm 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
Hi all,

Think of a class, which inherits from two interface classes, each having different event receptions, really nothing in common.

class Interface1 : public OMReactive ( Interface1 has event reception named evEvent1)
class Interface2 : public OMReactive ( Interface2 has event reception named evEvent2)

class MyClass : public Interface1, public Interface2
{
...
}

This gives NO error.

However, when I add an additional layer of classes into the inheritance tree, that is to say , when MyClass is as follows :

class LeftClass : public Interface1

class RightClass : public Interface2

class MyClass : public LeftClass, public RightClass

Rhapsody 7.5.1 Predefined Checker gives the error "Multiple inheritance from reactive classes is not supported", even though I use the "virtual" modifier for both generalization relationships.


What is that I am doing wrong ? How to correct it ?

Thanks in advance.

Özgür Eser Akdemir.


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 8:34 am 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
Better to think of MyClass as being composed of LeftClass and RightClass. Inheritance is an odd concept when you try and think of how it maps onto the real world. It only really applies as a coding concept and it is used by C++ coded models to realise interfaces. Inheritance from concrete classes can always be avoided by using composition.

Coders often regard this as a big change in thinking but it is a concept that drove UML 2.


Attachments:
File comment: Composition v Inheritance
Composition v Inheritance.png
Composition v Inheritance.png [ 15.68 KiB | Viewed 910 times ]
Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 11:55 am 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
Thanks.

However, this explains me how to turn around the problem but does not explain why there is such a problem.
You made LeftClass and RightClass have statecharts but in my case they do not have any statechart and the problem still occurs.

I wonder the point that allows multiple inheritance from interfaces but does not allow multiple inheritance from concrete classes (so, indirectly from interfaces)

Özgür Eser Akdemir


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 2:33 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
I assumed your interfaces carried events as the problem only occurs when OMReactive is involved. Are you sure that the interfaces only have primitive operations?


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 2:44 pm 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
Both interfaces do have only event receptions. I know that any such interface is generated as a class deriving from OMReactive. Confusion comes into the scene when an inheritance layer of concrete classes is involved... And my concrete classes do not have any explicit statecharts...


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 2:48 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
So what do your concrete classes do with the receptions?


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 2:57 pm 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
Concrete classes do not deal with receptions. MyClass deals with receptions.


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Thu Jun 10, 2010 3:40 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
So could MyClass realise the interfaces directly then? If not then there must be bits of the interfaces that your concrete classes do realise. The Liskov Substitution Principle would therefore not hold for your concrete classes.


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Fri Jun 11, 2010 8:15 am 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
You are right in saying concrete classes should realize the interfaces they are inheriting from..

Pease have a look at the real design shown in the figure below.

This design gives the checker error : "Multiple inheritance from reactive classes is not supported". The only way to remove this error is to directly inherit the XDeviceProxyWithMyProtocolBackend from IDeviceProxy (which is a pure interface), not from XDeviceProxy (which is a concrete class)

However, doing so disables me to make such declarations:

XDeviceProxy* pXDevice = new XDeviceProxyWithMyProtocolBackend();
IDeviceProxy* pDevice1 = pXDevice;

which allows me to use different protocol backends with the same device representative.

I hope the problem is now clear.

Özgür Eser Akdemir


Attachments:
hier.GIF
hier.GIF [ 16.04 KiB | Viewed 872 times ]
Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Fri Jun 11, 2010 9:34 am 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
An interesting observation... I created a new Rhapsody project, copied classes into this new project and found no checker error !
It can successfully inherit from both concrete and interface classes.

Was that due to a possible corruption in the previos model or Rhapsody project ? Any idea ?


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Mon Jun 14, 2010 6:01 am 

Joined: Sat Oct 18, 2008 9:32 pm
Posts: 10
Hi,
If you are you trying to build several protocol implementations for one single interface you should probably go for a bridge-pattern solution instead of using multiple inheritance (http://en.wikipedia.org/wiki/Bridge_pattern).


BR//
LGJ


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Mon Jun 14, 2010 8:58 am 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
Adding further interfaces by inheritance is ok but trying to extend two concrete classes that already define behaviour will not work. Your 'real design' didn't match your orginal question.

The bridge pattern is a useful pattern. Is there an extension to the 'real design' that makes it appropriate here? As I understand it, the bridge hides an abstraction away behind another 'extended' interface. The bridge then uses the original interface to request the backend processing. In the 'real design' here there is currently only one type of IDeviceProxy (XDeviceProxy) needed by the 'bridge'.


Attachments:
File comment: Bridge Pattern
brdgepattern.png
brdgepattern.png [ 8.72 KiB | Viewed 838 times ]
Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Mon Jun 14, 2010 9:35 am 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
Thanks Farquad,

It is true that my previous "real design" did not match my original question. This happened after to a change in the design to see if the problem can be solved.. Previously, IMyProtocolReceiver was the base class for MyProtocolBackend. Then I changed it and you detected the difference between the "original problem" and "real design". The problem of "pre-defined checker" was still insisting until I created a new Rhapsody project. This seemed to solve the error of "Multiple inheritance from reactive classes is not supported".
However, I later introduced a new design, which is exactly the same as what Xlarjo said and later you suggested. That is to say, I tried to apply "bridge-pattern" later as you can see the in the attachment.
My design differs from the original bridge-pattern in that I need the DeviceProxy class as a intermediate class which lies between IDeviceProxy and ADeviceProxy ( to allow code-resuability ) and in that DeviceProxy class is in association with a non-interface class (Backend)
This time, I get the errors shown in the second attachment !!!
Compiler, now, complains about the "AMBIGIUITY" that results from the multiple inheritance from many OMReactive classes.

Could you please help me understand what is going on and what I am doing wrong ?

Making the inheritance relations "virtual" does not help, by the way.

Really thanks.
Özgür Eser Akdemir


Attachments:
BuildErrors.PNG
BuildErrors.PNG [ 58.25 KiB | Viewed 829 times ]
ClassDiagram.PNG
ClassDiagram.PNG [ 12.49 KiB | Viewed 829 times ]
Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Mon Jun 14, 2010 10:07 am 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
There's a property you need to set for IBackend1SpecificInterface to stop it bringing in all the unneeded baggage of OMReactive.

CPP_CG::Class::ReactiveInterfaceScheme - make it Thin rather than Full


Offline
 Profile  
 
 Post subject: Re: Multiple inheritance from reactive classes is not supported
PostPosted: Mon Jun 14, 2010 10:17 am 

Joined: Tue Jun 24, 2008 6:18 pm
Posts: 141
Location: Ankara
Thanks,

It now works.

Özgür.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

cron

suspicion-preferred