Contents > 8 Defining Custom Design Metrics and Rules > 8.1 Definition of Metrics > 8.1.1 Projection > 8.1.1.10 Summary of Projection Attributes

#### 8.1.1.10 Summary of Projection Attributes

The admissible attributes for a projection definition are
• relation: operate on elements of 'incoming' relations
• relset: operate on elements of 'outgoing' relations or pre-calculated sets
• target: element type(s) of related elements
• element: for indirect relationships, relation link to follow
• eltype: for indirect relationships, type(s) of related element
• condition and targetcondition: discard elements which do not fulfill the specified expression
• scope discard elements which do not fulfill the scope condition
• sum: expression to evaluate and add up for each related element
• stat: specify "min" or "max" to obtain the minimum or maximum value of all "sum" metric expressions evaluated.
• recurse: calculate and add up same metric for compatible elements (default false)
• nesting: calculate nesting level for specified relation (default false)
The algorithm to evaluate a projection is presented here in pseudo-code.
```function projection(modelelement me) is:
// init result value
result := 0
// retrieve elements specified by attribute "relation"
if(relation specified) rel := all elements in relation with me
else rel := result of set expression applied to me
while(still elements in rel):
el := next element in rel
// filter "target" attribute and condition
if(target specified and el is not one of the types) goto invalid
if(targetcondition specified and el does not fulfill it) goto invalid
// handle indirect relations (attributes "element" and "eltype")
if(element specified)
el := el.element
if(eltype specified and el is not one of the types) goto invalid
endif
// filter "condition" attribute
if(condition specified and el does not fulfill it) goto invalid
// filter "scope" attribute
if(scope specified and el does not fulfill scope) goto invalid
if(nesting)
if(el is compatible with me)
result:=max(result, projection(el)+1)
continue // next iteration of the while loop
else
if(sum specified)
if(stat="max")
result:=max(result,sum(el))
else if(stat="min")
result:=min(result,sum(el))
else
result:=result+sum(el)  // default no attribute "stat"
else
result:=result+1
invalid:
if(recurse)
if(el is compatible with me)
result:=result+projection(el)
endwhile
return result
endfunction
```