It is currently Tue Feb 07, 2012 8:02 pm

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 [ 12 posts ] 
Author Message
 Post subject: Order of attributes in the structure definition
PostPosted: Tue Mar 31, 2009 1:36 pm 

Joined: Tue Mar 31, 2009 1:09 pm
Posts: 6
Hi,

is there any way, how to set the order of Rhapsody's API classes (such as RiCReactive) in the class structure definition? Now they are always placed on the first position.

So I mean, instead of
struct Foo {
    RiCReactive ric_reactive;
    int foo;
};

I would like to have a chance to place ric_reactive elsewhere, e.g.
struct Foo {
    int foo;
    RiCReactive ric_reactive;
};


Thanks.

(I'm using RiC 7.0.)


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Mar 31, 2009 8:25 pm 

Joined: Thu Aug 30, 2007 4:31 pm
Posts: 152
Location: Germany
Hi!
can you tell me one good reason why you would like to do this ?

just curios :-D


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 9:08 am 

Joined: Tue Mar 31, 2009 1:09 pm
Posts: 6
I've been expecting this answer :).
Not sure whether you consider it as a good reason, but ok:

We have our own inheritance in C implemented. Currently it is very similar to the C++ inheritance concept (including multiple inheritance), but writing all the vtbls manually is a real pain in the ass. It is very powerful but also very time consuming. So I would like to introduce another concept of how to achieve inheritance in C -- more similar to Java, C# or Objective-C. It doesn't allow to have multiple inheritance, but is more efficient and primarily much easier to write and maintain.

However, this new concept requires to have certain pointer right at the first position in the structure. So now you should understand... ;)

I was also trying to pass it by somehow, but didn't succeed.

P.S.: And please don't tell me "Why wouldn't you use Rhapsody in C++ instead?"... the answer is pretty simple -- I can't :(.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 9:39 am 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
Using inheritance to extend a class should be fairly rare. Generally aggregation wins.

Realisation of interfaces is what's prevalent in an OO design.

As I understand it more recent versions of Rhapsody provide you with realisation of interfaces in RiC. Realisation of interfaces can, and often is, multiple and that is supported.

I suspect you work for one of these mobile-phone handset companies and you're probably using a C++ compiler to compile your C. Am I right?


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 11:24 am 

Joined: Tue Mar 31, 2009 1:09 pm
Posts: 6
Farquhar wrote:
Using inheritance to extend a class should be fairly rare. Generally aggregation wins.

Realisation of interfaces is what's prevalent in an OO design.

As I understand it more recent versions of Rhapsody provide you with realisation of interfaces in RiC. Realisation of interfaces can, and often is, multiple and that is supported.

Well, I don't want to flood this topic with discussion about OO principles. I know the recent trends in avoiding inheritance and using compositions/aggregations instead. To calm you down ;), I'm not a fan of using inheritance whenever possible. But if there is a "is-a" relationship, it is still much better and easier to use inheritance. Interfaces are suitable for functional-like similarity.

Quote:
I suspect you work for one of these mobile-phone handset companies and you're probably using a C++ compiler to compile your C. Am I right?

:) No, I don't. But we are using gcc and MS VS 2008.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 11:53 am 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
From my own experience the consequences of using inheritance (for extension) rarely make it the best choice but, you're right, there's no need to go down that path of discussion other than to make you aware that Rhapsody, and UML's, view of the best practice is similar to Java's. To that end I mentioned that RiC has been updated to support realisation of interfaces.

It's nearly always best to go with the flow rather than fight it. It seems to me that C++ would be a better fit to what you require. It's inevitable that the C code you produce will be less efficient and maintainable than had it been C++.

Effectively you're being asked to do a C++ compiler writer's job, and you're already using a C++ compiler!

Sounds like some sort of torture.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 12:16 pm 

Joined: Tue Mar 31, 2009 1:09 pm
Posts: 6
Farquhar wrote:
It's inevitable that the C code you produce will be less efficient and maintainable than had it been C++.

Just a note: our form of inheritance in C leads to about 6-7 extra instructions for virtual methods. The new concept should take even less.

Farquhar wrote:
Effectively you're being asked to do a C++ compiler writer's job, and you're already using a C++ compiler!

Sounds like some sort of torture.

:D Yeah, some kind of. You should tell our managers...

Back to my question... suppose no one knows...


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 7:02 pm 

Joined: Thu Aug 30, 2007 4:31 pm
Posts: 152
Location: Germany
puuhh this is pretty difficult. You're using such an "old" version. Rhapsody in C does support a kind of inheritance in C for Interfaces in the meanwhile - called realisation (if I remember well) .. all vtbl are generateded automatically .. so if you ask this question then I assume 7.0 didn't support this... and probably you would like go further then just having Interface inheritance ...

I'm pretty sure that with Rhapsody 7.3 and 7.4 I will be able to do what you need ... what you ask for ... but then I still do not know , if this will be applicable fo 7.0 version ? (I don't have 7.0)
Nevertheless will try to do an example and let you know ...


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 11:20 am 

Joined: Tue Mar 31, 2009 1:09 pm
Posts: 6
Mickey wrote:
I'm pretty sure that with Rhapsody 7.3 and 7.4 I will be able to do what you need ... what you ask for ... but then I still do not know , if this will be applicable fo 7.0 version ? (I don't have 7.0)
Nevertheless will try to do an example and let you know ...

Usually I'm quite quick to understand ;), so you can try me with a simple hint and I will check it. I don't want to take your time for such task... but if you are willing to... I appreciate your effort.
And hey, we are going to be using 7.1 soon :).

Btw. are you the "mickey" from RiC API source code?


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 2:55 pm 

Joined: Thu Aug 30, 2007 4:31 pm
Posts: 152
Location: Germany
the what ? ... at least in this forum i'm the only mickey .. :-D


Offline
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 8:25 am 

Joined: Thu Aug 30, 2007 4:31 pm
Posts: 152
Location: Germany
uncheck C_CG:Framework:ReactiveBaseUsage and define your own ric_reactive element... see attached picture .. at least it generates what you're requesting

please note: startbehavour is not generated also... also other parts are probably missing that you have to add. But even then I'm not sure if it will work. It's possible that the framework also expects ric_reactive to be on the first place ...


Attachments:
foo.jpg
foo.jpg [ 48.2 KiB | Viewed 847 times ]
Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 2:37 pm 

Joined: Tue Mar 31, 2009 1:09 pm
Posts: 6
Thanks, Mickey, I will check it asap (and hopefully provide some other info).


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 12 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