Book a Demo

Author Topic: C++ Code Generation  (Read 10830 times)

TeddyBear

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
C++ Code Generation
« on: March 04, 2010, 09:25:00 am »
I'm new to this application can cannot generate c++ code. I have opened the example project and was able to generate C# source code but the model transformation does not list C++. I cannot find any information on how to go about this. The options do list the ability to configure C++ parameters(and even disable it).

I simply want to use the uml to generate simple state pattern like C++ source(nothing advanced at this point).

What am I doing wrong?

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #1 on: March 05, 2010, 11:14:45 pm »
Did you set the Language attributes of the classes, you want to gen. code from, to C++?

HTH
Günther

TeddyBear

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #2 on: March 05, 2010, 11:43:09 pm »
Yes. It seems that generate code and model transformation are two different things. You can generate code to C or C++ but not transform to them.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #3 on: March 06, 2010, 03:51:05 am »
Yes, of course that's a completely different kettle of fish. Model Transformation transforms from one UML model to another one  (usually a so called PIM  platform independent model to a PSM platform specific model), but still has not intrinsically sth.  to do with the programming language used to realize the transformed model.
Code generation generates code.

I've been wondering already why you mentioned MT in your question at all.
UML doesn't know about programming languages like C, C++, C#, a.s.o at all. A model transformation could be used though, e.g. to create a C++ PSM, using STL container classes  to realize 1:n associations occuring in the PIM. After doing that you may generate the code from the PSM.

WBR
Günther

TeddyBear

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #4 on: March 06, 2010, 11:01:46 am »
I've been playing around with the EAexample but can't figure it out. It has the abstract class model which is essentially the code model. It has the PSM which is the specific transformation to various languages. No where is there anything about C/C++. I used 'generate code' on the C# PSM model and got several .cs files but one .h and .cpp. I used 'generate code' on the PIM and only got two cpp classes(stockitem and orderstatus).

The main thing I want to be able to do is simply create a statemachine and export it to C or C++.  What I don't understand is why C# is under a model transform but C++ is not or vice versa. i.e., why the distinction between C/C++ and C# since they are all languages and really not that much different syntax wise.

Essentially I am trying to learn UML for code execution since I want a clean way and systematic way to represent state machines for both C and C++. Of course I would like to learn the full power of UML and EA but at this point I want something simple. I can create as simple C++ model of classes using the class model and 'generate code'.

I can't seem to find simple tutorial for EA though. I'm sure it's all just my inexperience and probably not understanding the basics.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #5 on: March 08, 2010, 09:58:25 pm »
Oh man, you're confusing a lot of things here. Of course you won't get C++ code for the C# classes (despite the one that you might accidentally have set to C++ language).

Do you have experience with any other UML tool and code generation, are you familiar with the UML modeling concepts?

Hard to try getting started with the advanced stuff (code generation from state machine).

Leave me your mail as proposed in the other thread and let's see what I can do for you to sort things and steps out (I'm pretty busy currently, but anyway ...).

WBR,
Günther

PS.: To get into a more efficient communication, would please be so kind to send me a short description of your professional experience and skills or student degree, what you want to achieve with your state machine and in which application field you want to use it. Just that I know what I can roughly rely on in my responses.
« Last Edit: March 08, 2010, 10:10:22 pm by Makulik »

TeddyBear

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #6 on: March 08, 2010, 10:40:53 pm »
Can you simply create a simple state machine that you can create code from and upload it and then I can download and see if I can create the code(using code generation). My problem is not creating the classes or the state machine but somehow getting the code for the state machine in the class. I have used the "add state machine" to the class diagram but it does nothing.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #7 on: March 09, 2010, 03:11:07 am »
No, I'm neither willing to create a new example, nor can I upload it here somewhere. If you like to get further with this topic, follow my instructions please. I won't use your eMail address for anything else, and if you wish I'll immediately discard it after I've send you the questionable stuff (ask others here, if they think I'm trustworthy). Take it or leave it, I've told you my time is limited and my patience starts to become limited too now.

g.

TeddyBear

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #8 on: March 09, 2010, 03:24:52 am »
I was able to generate code in Visual paradigm in under 10 mins of never using the program.  I do not like there method as it is more of an abstract state machine and has a lot of extra code that I do not need for embedded work.

As far as your patience, if you have such problems then it's best you just stop replying. I don't work well with type A+ personalities.  I'll just do it straight in C++ like I have always done rather than deal with people like you.


Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #9 on: March 09, 2010, 03:39:38 am »
So it's your choice.

Good luck,
g.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ Code Generation
« Reply #10 on: March 09, 2010, 08:24:32 am »
You don't need the transformations at all.  They are if you need to work independently of language, usually so that multiple targets can be generated from one model.

In the example model look at Project Models.Systems Engineering Model.Implementation Model.Software.C++.

Also see http://www.sparxsystems.com/uml_tool_guide/code_engineering/code_generation___state_machin.html

Roddy

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: C++ Code Generation
« Reply #11 on: March 09, 2010, 11:34:09 am »
Hey Gunther

In my book, you are the best. Well done for offering to help, you went at least two extra miles for that guy. It is no wonder he's having problems, and I expect he'll have a lot more now because no-one else will be inclined to help.

TeddyBear? Sounds more like grizzly bear. Oh - my apologies to all Grizzly Bears, you're a whole lot nicer.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C++ Code Generation
« Reply #12 on: March 09, 2010, 05:47:15 pm »
I agree, in general this forum has been free from the usual flamewars, trolls and other insulting or hateful posts you find on forums on the internet.
Lets keep it this way please.

So to Mr TeddyBear: If you can't say anything nice, then don't say anything at all :P

Geert