It is currently Thu Feb 09, 2012 12:40 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 [ 6 posts ] 
Author Message
 Post subject: Multiple default constructors specified
PostPosted: Fri Jan 30, 2009 7:45 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
I accidentally round tripped one of my classes, and now its parent class will not compile. First, it seems to have read in all the member functions the code generator created and are normally obscured from my view. I knew they were there, but they were just generated by the code generated and new viewable in the browser. Now, they're all visible in the browser. So, my 5 functions exploded to about 30 functions.

Second, when I compile, I get two errors. I'll omit the second error in case its related to the first. Class names are renamed here.

"C4520: 'Class_A' : multiple default constructors specified"
"C2248: 'Class_A::Class_B::Class_B' : cannot access private member declared in class 'Class_A::Class_B'"

I did specify one default constructor, but only 1. When I look at the .h file it generated, I see it created a Class_A() default constructor, and a Class_A(IOxfActive* theActiveContext = 0) constructor. The implementation that I wrote for the default constructor, actually appears in the non-default Class_A(IOxfActive* theActiveContext = 0) constructor. The actual default constructor has no implementation. Why is it saying I have multiple, and why did this happen after I roundtripped?


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2009 7:47 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
When I remove the constructor for testing purposes, it compiles again, though I run into new errors. Parts of code that have worked for weeks now break the compiler. I've not been able to compile since it round tripped. Its almost as if the code generator is just disabled. Its like round tripping threw a bowling ball through my code.


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2009 10:50 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
The compiler can't distinguish between Class_A() and Class_A(IOxfActive* theActiveContext = 0) because of the = 0 bit.

What constructor gets called when
Class_A* myClass_A = new Class_A;

Roundtripping can have bad consequences but that depends on settings as well. I would recommend never roundtripping anything other than implementation detail unless you have been shown how 'code respect' works. Rhapsody is very powerful at reverse engineering but you need to know what to do and that'll be dependent on what you're trying to achieve. It usually ends up as a set of different approaches dependent on the category of code.

If your class has a statechart then it has to know its ActiveContext so Class_A() is not going to be of any use. It's important to understand the mechanism that supports the execution of your model. Here's a few pointers. A class that receives events (asynchonous messages) is said to be Reactive and must know where to queue events, known as its ActiveContext. An Active Context is a thread. ActiveContext 0 is the main thread and all classes use this by default. If you make a class active then it, and any parts it creates, will use the thread it creates. So, for example, an active class with a statechart will use itself to queue the events it receives. Try making a class active and see the difference in implementation of the constructors.

Take a look at the OXF directory in the installation. Below that there is a model directory and you can look at that model by opening it in Rhapsody. The Object eXecution Framework is generated from that model. Look for the OMReactive class and work outwards from that. This is the sort of stuff the training will point you at and explain.

BTW there may be files under your component now. Removing those will tidy things up. There may also be other files hanging around local to the class that will be adding code you don't want. You should be able to just delete the files in the browser.


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2009 2:43 am 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
I completely forgot about default parameters, so of course, that makes perfect sense. But I still don't know what happened that caused this.

Can I not write my own default constructor for a Reactive class? It appears that I cannot. If not, can I suppress the code generator from writing it and write it myself to include the OMReactive specific code?


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Jan 31, 2009 5:23 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
You can create as many constructors as you like for any class, including reactive. All that happens is that the ActiveContext parameter is added to each one in the case of a reactive class.

Create the constructors via Rhapsody rather than directly in code though.


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 10:13 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
After having an .sbs file completely corrupted, I've learned never to edit the source directly. So far, if I can't do what I want to do using the tool, I'm doing something wrong anyway.

The problem was that I copied somebody elses prp files into my folder, not looking to see what they override. When I tried writing a default constructor in the tool, it created the constructor I requested, but the code generator also creates a default constructor rather than merging my code with the code generated code. Once I reverted back to my prp files, it went back to normal and merged my default constructor with the code generated default constructor.


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


suspicion-preferred