Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Re: ANSI-C-model and dealing with redundant references
Re: ANSI-C-model and dealing with redundant references [message #640992] Tue, 23 November 2010 14:00 Go to next message
Ed Merks is currently offline Ed Merks
Messages: 25949
Registered: July 2009
Senior Member
Tom,

comments below.


Tom Brandenburg wrote:
> Hello all,
>
> In my current project I want to create some C code out of an UML
> model. For this I want to use the ANSI-C-Model from the ViPER project.
> But I think it's a more general topic apart from that.
>
> Please look at the following extract from the ANSI-C-Model:
>
>
> Here you can see some type of hierarchy where TranslationElement and
> ASTElement are abstract and all children of TranslationElement inherit
> the composition association to itself. Now for complying with the
> ANSI-C-Standard and for better browsability there is also a
> composition between DeclSpecifier and FunctionDefinition. So somehow
> the composition is redundant.
Sounds like UML details best discussed on the UML2 newsgroup...
>
>
> During the model-2-model-transformation a DeclSpecifier is added to
> the FunctionDefinition explicitly as a DeclSpecifier and not as a
> nestedElement. The result is that the reference from a DeclSpecifier
> to a FunctionDefinition is set and not from the nestedElement to the
> nestingElement. The latter evolves to a problem when the model-2-text
> transformation want to browse through the model with the following
> code (found in the ViPER project):
>
> ansic::TranslationUnit getTranslationUnit(ansic::ASTElement element) :
> element.translationUnit != null ? element.translationUnit :
> element.nestingElement.getTranslationUnit()
> ;
>
> It returns null when translationUnit is null and the nestingElement
> reference is missing.
This model-2-model stuff is using what technology?
>
> So my question is, how it might be possible to add a DeclSpecifier to
> a FunctionDefinition and the reference is also added automatically to
> the nestedElements relation (because it is a nested element but also a
> DeclSpecifier for the Function Definition). Otherwise I might have to
> change the code at many location because this problem is not the only
> one of that kind in the ANSI-C-model. On the other hand I wonder why
> it does not work with me, whereas the ViPER project is tested and
> released. Even without the complex m2m and m2t transformations I can
> simulate that behaviour (which is somehow understandable) with the
> small sample above and a dynamic instance of it. But I don't to change
> the implementation of the ViPER plugin.
>
> Btw, the following code adds a DeclSpecifier to a FunctionDefinition:
>
> create ansic::FunctionDefinition d
> createFunctionDefinition(ansic::DeclSpecifier declSpecifier,
> ansic::FunctionDeclarator declarator) :
> //let d = new ansic::FunctionDefinition :
> d.setDeclSpecifier(declSpecifier) ->
> d.setFunctionDeclarator(declarator) ->
> d
>
> Where do the set-Functions come from? Is it a feature of EMF to have
> them automatically as soon as there are references with a
> 1-to-1-association?
Definitely best asked on the UML2 newsgroup. I've added it to the "to"
list of the reply, so no need to repost.
>
> Many thanks in advance and best regards,
> Tom
Re: ANSI-C-model and dealing with redundant references [message #641060 is a reply to message #640992] Wed, 24 November 2010 02:45 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom Brandenburg
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello,

the original thread with the image can be found here: http://www.eclipse.org/forums/index.php?t=msg&th=200737& amp;start=0&S=012149d15862df035dc78a7d106f4104

Thanks and cheers
Tom
Re: ANSI-C-model and dealing with redundant references [message #646158 is a reply to message #640992] Wed, 22 December 2010 07:50 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom Brandenburg
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello everyone,

I still have the problem, which is mentioned above. So that you have it easier I made an example which shows the same.

As mentioned I have an abstract class and some inherited classes. The abstract class contains itself, where there are also special classes which contain other special classes, whereas a similar composition is already realized in the abstract class. But for better browsability and differentiation I need this:

http://fcg.km23412-02.keymachine.de/ftp/upload/test/diagram_1.jpg
http://fcg.km23412-02.keymachine.de/ftp/upload/test/diagram2.jpg

The problem in a dynamic instance of the metamodel is that once you add SpecialClass2 as a nestedElement in SpecialClass1 the reference nestingElement is set. But when SpecialClass2 is added as a specialClassContainment then specialClassContainment is set but not nestingElement.

Is there a way of setting both?

Here you find my testfiles: Files

Thanks in advance and best regards
Tom

[Updated on: Wed, 22 December 2010 07:51]

Report message to a moderator

Re: ANSI-C-model and dealing with redundant references [message #646215 is a reply to message #646158] Wed, 22 December 2010 12:22 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael Chaves
Messages: 161
Registered: July 2009
Senior Member
Tom, sorry to make you bounce like that, but I couldn't think how this is related to UML. I think Ed assumed you were talking about UML metamodel elements, but it seems this is just a vanilla ECore-based meta-model that you created, right?

Suggest you ask your question again over the EMF newsgroup...

Cheers,

Rafael

Re: ANSI-C-model and dealing with redundant references [message #646285 is a reply to message #646215] Thu, 23 December 2010 02:00 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom Brandenburg
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hey Rafael,

yes, it is an ecore based meta model. I posted the same in the EMF newsgroup. Hopefully they don't want to shift me to somewhere else Smile

Bye Tom

[Updated on: Thu, 23 December 2010 02:00]

Report message to a moderator

Re: ANSI-C-model and dealing with redundant references [message #646372 is a reply to message #646285] Thu, 23 December 2010 09:39 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25949
Registered: July 2009
Senior Member
Tom,

It helps to boil your question down to just the relevant details. When
you say things like "I want to create some C code out of an UML model"
it sure sounds like you have a UML model. If you don't, it's a
confusing way to start your question.


Tom Brandenburg wrote:
> Hey Rafael,
>
> I posted the same in the EMF newsgroup. Hopefully they don't want to
> shift me to somewhere else :)
>
> Bye Tom
Previous Topic:[solved] How to modify a profile that is already in use?
Next Topic:Code generation issue
Goto Forum:
  


Current Time: Fri Aug 01 07:51:59 EDT 2014

Powered by FUDForum. Page generated in 0.02643 seconds