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 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