Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » C/C++ code generator(Tips & suggestions)
icon5.gif  C/C++ code generator [message #1384819] Mon, 02 June 2014 10:38 Go to next message
Philippe Kalitine is currently offline Philippe KalitineFriend
Messages: 7
Registered: June 2014
Junior Member
Hello,

I'm working on a C/C++ & Qt application. Our team are working now on UML and we would like to be able to generate a C/C++ code from our UML diagramms. We are using

->Eclipse IDE for C/C++ Developers (Kepler Service Release 2)
->UML Designer 3.0.0
->Acceleo 3.4.1
(Everything are the last versions by the time I'm writing this topic)

I made a research on the Internet and found out that the only solution (when using UML Designer) to generate C/C++ code is using Acceleo. But the information on C/C++ code generation I've found was obsolete and actually I didn't find a lot on this topic.

As I'm new to Acceleo I decided to write this topic in case if someone had any progress on this problem. In order to begin I've followed the tutorial which explains how to generate Java beans from a UML model and it works fine for me.

I'm also using Acceleo 3.1.0 User Guide on the obeonetwork web site as reference.

I appreciate any suggestions, links, tutorials and any other resources here. Thank you.

Philippe
Re: C/C++ code generator [message #1384988 is a reply to message #1384819] Tue, 03 June 2014 13:36 Go to previous messageGo to next message
Philippe Kalitine is currently offline Philippe KalitineFriend
Messages: 7
Registered: June 2014
Junior Member
Here is my excerpt of code to generate C++
        [for (p: Property | cls.attribute)]
		[if (p.visibility.toString() = 'private')]
 			[hasPrivateMembers = true/]
		[/if]
	[/for]
	
        [if (hasPrivateMembers)]
	
	private:
	[for (p: Property | cls.attribute) separator('\n')]
		[if (p.visibility.toString() = 'private')]
		/*!
		 * @brief TODO
		 */
		[p.type.name/] [p.name/];
		[/if]
	[/for]
	[/if]


I am trying here to generate private members of a C++ class only if they exist. But it turns out that it does not work properly because of "hasPrivateMembers" variable. I initialized this variable in the file like this:
[template public classCreator(cls : Class){
hasPrivateMembers : Boolean = false;
}]


But how to assign a value to this variable in Acceleo? Is there any documentation which describes this internal Acceleo language?
Re: C/C++ code generator [message #1384993 is a reply to message #1384988] Tue, 03 June 2014 13:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7649
Registered: July 2009
Senior Member
Hi

Acceleo supports parameters for external input.

For internal deduction exploit the caching of previously computed
results so make hasPrivateMembers a query over wht matters rto you. It
will only be executed once.

Regards

Ed Willink


On 03/06/2014 14:36, Philippe Kalitine wrote:
> Here is my excerpt of code to generate C++
>
> [for (p: Property | cls.attribute)]
> [if (p.visibility.toString() = 'private')]
> [hasPrivateMembers = true/]
> [/if]
> [/for]
>
> [if (hasPrivateMembers)]
>
> private:
> [for (p: Property | cls.attribute) separator('\n')]
> [if (p.visibility.toString() = 'private')]
> /*!
> * @brief TODO
> */
> [p.type.name/] [p.name/];
> [/if]
> [/for]
> [/if]
>
>
> I am trying here to generate private members of a C++ class only if
> they exist. But it turns out that it does not work properly because of
> "hasPrivateMembers" variable. I initialized this variable in the file
> like this:
>
> [template public classCreator(cls : Class){
> hasPrivateMembers : Boolean = false;
> }]
>
>
> But how to assign a value to this variable in Acceleo? Is there any
> documentation which describes this internal Acceleo language?
Re: C/C++ code generator [message #1384995 is a reply to message #1384993] Tue, 03 June 2014 14:08 Go to previous messageGo to next message
Philippe Kalitine is currently offline Philippe KalitineFriend
Messages: 7
Registered: June 2014
Junior Member
Hello Ed Willink,

Thank you for the response. What I understood is that I should use query in this case, right?

Do you have any code examples for this or any other examples, because on the "Acceleo 3.1.0 User Guide" there are very few information about query.
Frankly in order to learn how to generate code with Acceleo I mostly use [Ctrl] + [Space] shortcut in Eclipse to explore all available attributes and methods and I'm trying to understand what they do by use/try technique =).
Re: C/C++ code generator [message #1384998 is a reply to message #1384995] Tue, 03 June 2014 14:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7649
Registered: July 2009
Senior Member
Hi

You really should start by reading the Acceleo documentation and then
perhaps the Wiki

Regards

Ed Willink

On 03/06/2014 15:08, Philippe Kalitine wrote:
> Hello Ed Willink,
>
> Thank you for the response. What I understood is that I should use
> query in this case, right?
>
> Do you have any code examples for this or any other examples, because
> on the "Acceleo 3.1.0 User Guide" there are very few information about
> query.
> Frankly in order to learn how to generate code with Acceleo I mostly
> use [Ctrl] + [Space] shortcut in Eclipse to explore all available
> attributes and methods and I'm trying to understand what they do by
> use/try technique =).
>
Re: C/C++ code generator [message #1385650 is a reply to message #1384998] Tue, 10 June 2014 08:51 Go to previous messageGo to next message
Philippe Kalitine is currently offline Philippe KalitineFriend
Messages: 7
Registered: June 2014
Junior Member
Hello,

I started by reading the documentation then also saw the wiki. But still there are little information on how to right the Acceleo module.

So I appreciate any Acceleo code (template/query) examples. What ever purpose and generation language the code will be written for, I would like very much to see it. Please do not hesitate to share it here. Thanks in advance.

Good day,
Philippe
Re: C/C++ code generator [message #1385668 is a reply to message #1385650] Tue, 10 June 2014 11:34 Go to previous message
Philippe Kalitine is currently offline Philippe KalitineFriend
Messages: 7
Registered: June 2014
Junior Member
Hello again,

My bad. When I was talking about documentation, I meant the one on ObeoNetwork (Acceleo User Guide) and now I've also discovered the doc in Eclipse which is more informative. For those how did find it too, I list here all the sources of information on Acceleo I've found on the Internet:

- Acceleo Obeo Network community (You may find there: Acceleo user Guide, Acceleo Best practices, Eclipse wiki). It is good point to start
- One you've installed Acceleo Eclipse plugin, I recommend you to look at Eclipse Acceleo documentation. Very important source of information.

Best regards,
Philippe

[Updated on: Tue, 10 June 2014 11:35]

Report message to a moderator

Previous Topic:"Generation Fail" --> problème de méta model
Next Topic: [Acceleo] How to get types for xcore meta-model
Goto Forum:
  


Current Time: Fri Mar 01 14:16:30 GMT 2024

Powered by FUDForum. Page generated in 0.02631 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top