Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Global Variables in OCL
Global Variables in OCL [message #1060061] Wed, 22 May 2013 18:36 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
I would like to know how to define variables as Global in ECore/OCL.

In my ecore, i have recursive operation calls and it takes a set as input and keep filling this set. I would like to define that Set as global variable so it will becomes accessible through out my ecore/all OCL statements in Ecore.

Do you have any idea?

Cheers.
Re: Global Variables in OCL [message #1060063 is a reply to message #1060061] Wed, 22 May 2013 19:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

How would you solve this in Java? No global variables there either. The
same scope approaches work for OCL.

Regards

Ed Willink




On 22/05/2013 19:36, ModelGeek Mising name wrote:
> I would like to know how to define variables as Global in ECore/OCL.
>
> In my ecore, i have recursive operation calls and it takes a set as
> input and keep filling this set. I would like to define that Set as
> global variable so it will becomes accessible through out my ecore/all
> OCL statements in Ecore.
>
> Do you have any idea?
>
> Cheers.
Re: Global Variables in OCL [message #1060114 is a reply to message #1060063] Thu, 23 May 2013 07:43 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
thanks!

But can i have static attribute/property in Ecore instead?

So i can access them in OCL code like ClassName.propertyName.

Cheers,
Re: Global Variables in OCL [message #1060150 is a reply to message #1060114] Thu, 23 May 2013 10:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

Ecore does not support static properties. UML does.

OCL 2.2 added them, so support is probably patchy.

The Ecore binding of Eclipse OCL parses them but has no distinctive
evaluation support.

The Pivot binding of Eclipse OCL parses them but has poorly tested
evaluation support.

It is much easier to just create a GlobalVariables class (which in Java
you might well use in a
non-static fashion as GlobalVariables.INSTANCE.SOMETHING)

[Truly global variables are a very bad idea because it makes it
needlessly hard to reuse your code as a subsystem of a larger system
that may have more than one instance of your subsystem.]

Regards

Ed Willink


On 23/05/2013 08:43, ModelGeek Mising name wrote:
> thanks!
>
> But can i have static attribute/property in Ecore instead?
> So i can access them in OCL code like ClassName.propertyName.
>
> Cheers,
Re: Global Variables in OCL [message #1060182 is a reply to message #1060150] Thu, 23 May 2013 12:14 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
thanks again.

Actaully, i am creating/instantiating ecore at runtime(programmatically) and evaluating using delegates so GlobalVariables.INSTANCE.SOMETHING seems not applicable for me? Do you have any suggession regaring implementing static properties in above mentioned situation.

Cheers
Re: Global Variables in OCL [message #1060186 is a reply to message #1060182] Thu, 23 May 2013 12:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

You just bmake GlobalVariables navigable

self.........globalVariables.........

Regards

Ed Willink


On 23/05/2013 13:14, ModelGeek Mising name wrote:
> thanks again.
>
> Actaully, i am creating/instantiating ecore at
> runtime(programmatically) and evaluating using delegates so
> GlobalVariables.INSTANCE.SOMETHING seems not applicable for me? Do you
> have any suggession regaring implementing static properties in above
> mentioned situation.
>
> Cheers
Re: Global Variables in OCL [message #1060211 is a reply to message #1060186] Thu, 23 May 2013 14:18 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
if i make static/global variable navigable, then i feel the concept for static property will be gone as for any static property(in Java), we just need ClassName.property.



Cheers,
Previous Topic:[Announce] Eclipse OCL 4.1.0 (Kepler) RC1 is now available.
Next Topic:Load Complete OCL Resource Automatically
Goto Forum:
  


Current Time: Sat Dec 07 08:53:46 GMT 2024

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

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

Back to the top