Static attributes in C++

General discussions about code engineering

Moderator: Moderators

Static attributes in C++

Postby medvedm@zin-tech.com » Wed Jun 16, 2010 1:40 pm

Hi - I've got a directed association in a class that I want to be static. It generates the element correctly in the .h file, but it doesn't put it in the .cpp file as must happen with statically declared attributes. What am I missing?

M
medvedm@zin-tech.com
Forum Newbie
Forum Newbie
 
Posts: 9
Posts Rating:0
Joined: Tue Dec 29, 2009 2:45 pm

Re: Static attributes in C++

Postby bhoomchai » Thu Jun 17, 2010 1:21 am

Try to put a default value to your attribute in the model and generate code again.
The static attribute will be generated in .cpp only if it has default value.
bhoomchai
Customer Support
Customer Support
 
Posts: 36
Posts Rating:5
Joined: Thu Jan 21, 2010 12:38 am

Re: Static attributes in C++

Postby medvedm@zin-tech.com » Thu Jun 17, 2010 6:57 am

Thanks!
M
medvedm@zin-tech.com
Forum Newbie
Forum Newbie
 
Posts: 9
Posts Rating:0
Joined: Tue Dec 29, 2009 2:45 pm

Re: Static attributes in C++

Postby medvedm@zin-tech.com » Fri Jun 18, 2010 10:08 am

So when I start generating static members, it messes my code generation up, bad.

The first time I generate the code it comes out ok, like this:
//@(#) AcmeApplication.cpp


#include "AcmeApplication.h"
#include <iostream>
/**
* Prepare an ES telemetry packet.
* Called by \ref globalESPrepare to allow this telemetry handler to
* make changes or additions to an ES telemetry packet.
*
* \param telemetry pointer of telemtry packet to prepare.
* \return OK, or ERROR if there was a problem manipulating telemetry.
*/
STATUS AcmeApplication::prepareESTelemetry( MTPacket * telemetry )
{

}


AcmeApplication * AcmeApplication::pInstance = 0;


But then if I regenerate it, without changing anything, it looks like this:

AcmeApplication * AcmeApplication::pInstance = 0#include "AcmeApplication.h"#include <iostream>/**
* Prepare an ES telemetry packet.
* Called by \ref globalESPrepare to allow this telemetry handler to
* make changes or additions to an ES telemetry packet.
*
* \param telemetry pointer of telemtry packet to prepare.
* \return OK, or ERROR if there was a problem manipulating telemetry.
*/
STATUS AcmeApplication::prepareESTelemetry( MTPacket * telemetry )


I think you guys might need to look into how your tool handles static stuff. I have another post out there that I think is related. See:

viewtopic.php?f=28&t=1526

M
medvedm@zin-tech.com
Forum Newbie
Forum Newbie
 
Posts: 9
Posts Rating:0
Joined: Tue Dec 29, 2009 2:45 pm

Re: Static attributes in C++

Postby bhoomchai » Wed Jun 23, 2010 2:48 am

Seem like the problem that you faced might not come from the static thing.
Try to check that your working directory is the same place as where you generate the code.
You need this if you need to regenerate the code to the same place. MagicDraw will try to merge the updated model to your code in working directory.
bhoomchai
Customer Support
Customer Support
 
Posts: 36
Posts Rating:5
Joined: Thu Jan 21, 2010 12:38 am

Re: Static attributes in C++

Postby medvedm@zin-tech.com » Thu Jul 01, 2010 7:13 am

It seems like the working directory is the same as where the code is generated - it looks to me like tool has put a bunch of .bak and .tmp files in the same directory. I'm pretty sure it actually has to do with the static stuff, because it seems to work just fine if I don't use a static member.
medvedm@zin-tech.com
Forum Newbie
Forum Newbie
 
Posts: 9
Posts Rating:0
Joined: Tue Dec 29, 2009 2:45 pm


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests