Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » OAW xpt and counters
OAW xpt and counters [message #383897] Mon, 23 June 2008 16:44 Go to next message
Jim is currently offline Jim
Messages: 15
Registered: July 2009
Junior Member
Hello ... I am porting a code generator to OAW from XSLT ...

Is there a way i can store the number of times something meeting some
foreach condition ?

I kinda wanna do something like this below half baked pseudo code:

int count = 0;
«FOREACH //get some list ...
//satisfy some condition
count +=1;
«ENDFOREACH»


Reason being ... is that i need to create an array of objects:

objects * myarray = new objects()[/*num of special objects in model*/]

Cheers,

Jim
Re: OAW xpt and counters [message #383898 is a reply to message #383897] Tue, 24 June 2008 09:45 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

Jim,

I suppose you are searching for the select function. Either you only
iterate over the list of elements meeting that condition or you do your
initialization seperately.

int count=0;
«FOREACH getSomeListOfElements.select(e|condition-with-e)»
count +=1;
«ENDFOREACH»

objects * myarray = new
objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]

~Karsten

Jim schrieb:
> Hello ... I am porting a code generator to OAW from XSLT ...
>
> Is there a way i can store the number of times something meeting some
> foreach condition ?
>
> I kinda wanna do something like this below half baked pseudo code:
>
> int count = 0;
> «FOREACH //get some list ...
> //satisfy some condition
> count +=1;
> «ENDFOREACH»
>
>
> Reason being ... is that i need to create an array of objects:
>
> objects * myarray = new objects()[/*num of special objects in model*/]
>
> Cheers,
>
> Jim


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: OAW xpt and counters [message #383903 is a reply to message #383898] Wed, 25 June 2008 14:24 Go to previous messageGo to next message
Jim is currently offline Jim
Messages: 15
Registered: July 2009
Junior Member
Thanks ... but not quite i "fixed" it to do what i was looking for by
doing the below ... i am sure its a sin of some kind ... but it really
shorted my code down ....

Cheers,
Jim

«CreateCounter("ProcEntry_ContainerCounter")»
«FOREACH ... AS a»
«CounterIncrement("ProcEntry_ContainerCounter")»
«ENDFOREACH»

«IF IsCounterGreaterThan("ProcEntry_ContainerCounter","0")== "true" »
....
....

Karsten Thoms wrote:
> Jim,
>
> I suppose you are searching for the select function. Either you only
> iterate over the list of elements meeting that condition or you do your
> initialization seperately.
>
> int count=0;
> «FOREACH getSomeListOfElements.select(e|condition-with-e)»
> count +=1;
> «ENDFOREACH»
>
> objects * myarray = new
> objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]
>
> ~Karsten
>
> Jim schrieb:
>> Hello ... I am porting a code generator to OAW from XSLT ...
>>
>> Is there a way i can store the number of times something meeting some
>> foreach condition ?
>>
>> I kinda wanna do something like this below half baked pseudo code:
>>
>> int count = 0;
>> «FOREACH //get some list ...
>> //satisfy some condition
>> count +=1;
>> «ENDFOREACH»
>>
>>
>> Reason being ... is that i need to create an array of objects:
>>
>> objects * myarray = new objects()[/*num of special objects in model*/]
>>
>> Cheers,
>>
>> Jim
Re: OAW xpt and counters [message #383921 is a reply to message #383903] Tue, 01 July 2008 07:46 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

Are you aware of the counter extensions in oAW's stdlib feature? There
are already means to create, increment and query counters.

«EXTENSION org::openarchitectureware::util::stdlib::counter»

«FOREACH ... AS a»
«counterInc("ProcEntry_ContainerCounter")»
«ENDFOREACH»

«IF counterGet("ProcEntry_ContainerCounter")>0»

Looks smarter I think.

~Karsten


Jim schrieb:
> Thanks ... but not quite i "fixed" it to do what i was looking for by
> doing the below ... i am sure its a sin of some kind ... but it really
> shorted my code down ....
>
> Cheers,
> Jim
>
> «CreateCounter("ProcEntry_ContainerCounter")»
> «FOREACH ... AS a»
> «CounterIncrement("ProcEntry_ContainerCounter")»
> «ENDFOREACH»
>
> «IF IsCounterGreaterThan("ProcEntry_ContainerCounter","0")== "true" »
> ....
> ....
>
> Karsten Thoms wrote:
>> Jim,
>>
>> I suppose you are searching for the select function. Either you only
>> iterate over the list of elements meeting that condition or you do
>> your initialization seperately.
>>
>> int count=0;
>> «FOREACH getSomeListOfElements.select(e|condition-with-e)»
>> count +=1;
>> «ENDFOREACH»
>>
>> objects * myarray = new
>> objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]
>>
>> ~Karsten
>>
>> Jim schrieb:
>>> Hello ... I am porting a code generator to OAW from XSLT ...
>>>
>>> Is there a way i can store the number of times something meeting some
>>> foreach condition ?
>>>
>>> I kinda wanna do something like this below half baked pseudo code:
>>>
>>> int count = 0;
>>> «FOREACH //get some list ...
>>> //satisfy some condition
>>> count +=1;
>>> «ENDFOREACH»
>>>
>>>
>>> Reason being ... is that i need to create an array of objects:
>>>
>>> objects * myarray = new objects()[/*num of special objects in model*/]
>>>
>>> Cheers,
>>>
>>> Jim


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: OAW xpt and counters [message #384380 is a reply to message #383903] Tue, 29 July 2008 06:12 Go to previous message
Sven Efftinge is currently offline Sven Efftinge
Messages: 1762
Registered: July 2009
Senior Member
Hi Jim,

just as an addition:
the FOREACH statement also supports some kind of iterator:

<<FOREACH foo AS bar ITERATOR i>>
<<i.counter0>>
<<i.counter1>>
<<ENDFOREACH>>

where (i.counter0+1)==i.counter1

hope that helps,
Sven

Jim schrieb:
> Thanks ... but not quite i "fixed" it to do what i was looking for by
> doing the below ... i am sure its a sin of some kind ... but it really
> shorted my code down ....
>
> Cheers,
> Jim
>
> «CreateCounter("ProcEntry_ContainerCounter")»
> «FOREACH ... AS a»
> «CounterIncrement("ProcEntry_ContainerCounter")»
> «ENDFOREACH»
>
> «IF IsCounterGreaterThan("ProcEntry_ContainerCounter","0")== "true" »
> ...
> ...
>
> Karsten Thoms wrote:
>> Jim,
>>
>> I suppose you are searching for the select function. Either you only
>> iterate over the list of elements meeting that condition or you do
>> your initialization seperately.
>>
>> int count=0;
>> «FOREACH getSomeListOfElements.select(e|condition-with-e)»
>> count +=1;
>> «ENDFOREACH»
>>
>> objects * myarray = new
>> objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]
>>
>> ~Karsten
>>
>> Jim schrieb:
>>> Hello ... I am porting a code generator to OAW from XSLT ...
>>>
>>> Is there a way i can store the number of times something meeting some
>>> foreach condition ?
>>>
>>> I kinda wanna do something like this below half baked pseudo code:
>>>
>>> int count = 0;
>>> «FOREACH //get some list ...
>>> //satisfy some condition
>>> count +=1;
>>> «ENDFOREACH»
>>>
>>>
>>> Reason being ... is that i need to create an array of objects:
>>>
>>> objects * myarray = new objects()[/*num of special objects in model*/]
>>>
>>> Cheers,
>>>
>>> Jim


--
Need professional support on Xtext or Xtend?
Mail to: xtext (at) itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: OAW xpt and counters [message #618085 is a reply to message #383897] Tue, 24 June 2008 09:45 Go to previous message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

Jim,

I suppose you are searching for the select function. Either you only
iterate over the list of elements meeting that condition or you do your
initialization seperately.

int count=0;
«FOREACH getSomeListOfElements.select(e|condition-with-e)»
count +=1;
«ENDFOREACH»

objects * myarray = new
objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]

~Karsten

Jim schrieb:
> Hello ... I am porting a code generator to OAW from XSLT ...
>
> Is there a way i can store the number of times something meeting some
> foreach condition ?
>
> I kinda wanna do something like this below half baked pseudo code:
>
> int count = 0;
> «FOREACH //get some list ...
> //satisfy some condition
> count +=1;
> «ENDFOREACH»
>
>
> Reason being ... is that i need to create an array of objects:
>
> objects * myarray = new objects()[/*num of special objects in model*/]
>
> Cheers,
>
> Jim


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: OAW xpt and counters [message #618095 is a reply to message #383898] Wed, 25 June 2008 14:24 Go to previous message
Jim is currently offline Jim
Messages: 15
Registered: July 2009
Junior Member
Thanks ... but not quite i "fixed" it to do what i was looking for by
doing the below ... i am sure its a sin of some kind ... but it really
shorted my code down ....

Cheers,
Jim

«CreateCounter("ProcEntry_ContainerCounter")»
«FOREACH ... AS a»
«CounterIncrement("ProcEntry_ContainerCounter")»
«ENDFOREACH»

«IF IsCounterGreaterThan("ProcEntry_ContainerCounter","0")== "true" »
....
....

Karsten Thoms wrote:
> Jim,
>
> I suppose you are searching for the select function. Either you only
> iterate over the list of elements meeting that condition or you do your
> initialization seperately.
>
> int count=0;
> «FOREACH getSomeListOfElements.select(e|condition-with-e)»
> count +=1;
> «ENDFOREACH»
>
> objects * myarray = new
> objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]
>
> ~Karsten
>
> Jim schrieb:
>> Hello ... I am porting a code generator to OAW from XSLT ...
>>
>> Is there a way i can store the number of times something meeting some
>> foreach condition ?
>>
>> I kinda wanna do something like this below half baked pseudo code:
>>
>> int count = 0;
>> «FOREACH //get some list ...
>> //satisfy some condition
>> count +=1;
>> «ENDFOREACH»
>>
>>
>> Reason being ... is that i need to create an array of objects:
>>
>> objects * myarray = new objects()[/*num of special objects in model*/]
>>
>> Cheers,
>>
>> Jim
Re: OAW xpt and counters [message #618108 is a reply to message #383903] Tue, 01 July 2008 07:46 Go to previous message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

Are you aware of the counter extensions in oAW's stdlib feature? There
are already means to create, increment and query counters.

«EXTENSION org::openarchitectureware::util::stdlib::counter»

«FOREACH ... AS a»
«counterInc("ProcEntry_ContainerCounter")»
«ENDFOREACH»

«IF counterGet("ProcEntry_ContainerCounter")>0»

Looks smarter I think.

~Karsten


Jim schrieb:
> Thanks ... but not quite i "fixed" it to do what i was looking for by
> doing the below ... i am sure its a sin of some kind ... but it really
> shorted my code down ....
>
> Cheers,
> Jim
>
> «CreateCounter("ProcEntry_ContainerCounter")»
> «FOREACH ... AS a»
> «CounterIncrement("ProcEntry_ContainerCounter")»
> «ENDFOREACH»
>
> «IF IsCounterGreaterThan("ProcEntry_ContainerCounter","0")== "true" »
> ....
> ....
>
> Karsten Thoms wrote:
>> Jim,
>>
>> I suppose you are searching for the select function. Either you only
>> iterate over the list of elements meeting that condition or you do
>> your initialization seperately.
>>
>> int count=0;
>> «FOREACH getSomeListOfElements.select(e|condition-with-e)»
>> count +=1;
>> «ENDFOREACH»
>>
>> objects * myarray = new
>> objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]
>>
>> ~Karsten
>>
>> Jim schrieb:
>>> Hello ... I am porting a code generator to OAW from XSLT ...
>>>
>>> Is there a way i can store the number of times something meeting some
>>> foreach condition ?
>>>
>>> I kinda wanna do something like this below half baked pseudo code:
>>>
>>> int count = 0;
>>> «FOREACH //get some list ...
>>> //satisfy some condition
>>> count +=1;
>>> «ENDFOREACH»
>>>
>>>
>>> Reason being ... is that i need to create an array of objects:
>>>
>>> objects * myarray = new objects()[/*num of special objects in model*/]
>>>
>>> Cheers,
>>>
>>> Jim


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: OAW xpt and counters [message #618620 is a reply to message #383903] Tue, 29 July 2008 06:12 Go to previous message
Sven Efftinge is currently offline Sven Efftinge
Messages: 1762
Registered: July 2009
Senior Member
Hi Jim,

just as an addition:
the FOREACH statement also supports some kind of iterator:

<<FOREACH foo AS bar ITERATOR i>>
<<i.counter0>>
<<i.counter1>>
<<ENDFOREACH>>

where (i.counter0+1)==i.counter1

hope that helps,
Sven

Jim schrieb:
> Thanks ... but not quite i "fixed" it to do what i was looking for by
> doing the below ... i am sure its a sin of some kind ... but it really
> shorted my code down ....
>
> Cheers,
> Jim
>
> «CreateCounter("ProcEntry_ContainerCounter")»
> «FOREACH ... AS a»
> «CounterIncrement("ProcEntry_ContainerCounter")»
> «ENDFOREACH»
>
> «IF IsCounterGreaterThan("ProcEntry_ContainerCounter","0")== "true" »
> ...
> ...
>
> Karsten Thoms wrote:
>> Jim,
>>
>> I suppose you are searching for the select function. Either you only
>> iterate over the list of elements meeting that condition or you do
>> your initialization seperately.
>>
>> int count=0;
>> «FOREACH getSomeListOfElements.select(e|condition-with-e)»
>> count +=1;
>> «ENDFOREACH»
>>
>> objects * myarray = new
>> objects()[«getSomeListOfElements.select(e|condition-with-e) .size»]
>>
>> ~Karsten
>>
>> Jim schrieb:
>>> Hello ... I am porting a code generator to OAW from XSLT ...
>>>
>>> Is there a way i can store the number of times something meeting some
>>> foreach condition ?
>>>
>>> I kinda wanna do something like this below half baked pseudo code:
>>>
>>> int count = 0;
>>> «FOREACH //get some list ...
>>> //satisfy some condition
>>> count +=1;
>>> «ENDFOREACH»
>>>
>>>
>>> Reason being ... is that i need to create an array of objects:
>>>
>>> objects * myarray = new objects()[/*num of special objects in model*/]
>>>
>>> Cheers,
>>>
>>> Jim


--
Need professional support on Xtext or Xtend?
Mail to: xtext (at) itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:[Epsilon] Launch EVL validations programmatically
Next Topic:OAW - Type Casting with XTend
Goto Forum:
  


Current Time: Tue Sep 16 13:38:06 GMT 2014

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

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