Grouping C++ Typedefs, Globals into Single File

General discussions about code engineering

Moderator: Moderators

Grouping C++ Typedefs, Globals into Single File

Postby gSawyer » Wed Sep 18, 2013 7:58 pm

I have not been able to determine how to group multiple C++ typedefs and/or global variable declarations into a single file so that I do not have to #include a lot of separate files. Can anyone provide some guidance in this area or is this a limitation of the MagicDraw C++ code generation capability?
Forum Beginner
Forum Beginner
Posts: 37
Posts Rating:0
Joined: Tue Jun 26, 2012 9:08 am

Re: Grouping C++ Typedefs, Globals into Single File

Postby bhoomchai » Thu Sep 19, 2013 1:56 am

You can do this by manipulating the Realization from a Component in FileView package.
To understand how this can be done, you need to understand how MagicDraw code generation works.

For a simple case,if you add a class, let call it ClassA, to code engineering set, MagicDraw will automatically create a Component, "ClassA.h" in FileView package with a Realization from the component (ClassA.h) to the class (ClassA).
(Please note that, the Component, ClassA.h, represents the file to be generated.)

Now, instead of doing so, you can start from creating your own Component in FileView package and create a Realization from the component to the model that you want to be generated and then add the Component to code engineering set.

This sample model shows how to create a model that will generate the following content in a single file, GlobalDefinition.h.

Code: Select all
typedef int UNIT32;
typedef int* INT_PTR;
int i;
double s;


I've attached the sample file, CppSample.mdzip. Hope this can help.

Best regards,
No Magic Customer Support
You do not have the required permissions to view the files attached to this post.
Customer Support
Customer Support
Posts: 36
Posts Rating:5
Joined: Thu Jan 21, 2010 12:38 am

Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests