| -- @atlcompiler atl2006 | |
| -- ****************************************************************************** | |
| -- Copyright (c) 2006 INRIA. | |
| -- All rights reserved. This program and the accompanying materials | |
| -- are made available under the terms of the Eclipse Public License v1.0 | |
| -- which accompanies this distribution, and is available at | |
| -- http://www.eclipse.org/legal/epl-v10.html | |
| -- | |
| -- Contributors: | |
| -- INRIA - Initial implementation | |
| -- | |
| -- ****************************************************************************** | |
| --@author Hugo Bruneliere (Hugo.Bruneliere <at> gmail.com) | |
| module Metrics2Table; | |
| create OUT : Table from IN : Metrics; | |
| ------------------------------------------------------------------------------- | |
| -- HELPERS -------------------------------------------------------------------- | |
| ------------------------------------------------------------------------------- | |
| -- no helpers | |
| ------------------------------------------------------------------------------- | |
| -- RULES ---------------------------------------------------------------------- | |
| ------------------------------------------------------------------------------- | |
| entrypoint rule TablesBuilding() { | |
| do { | |
| Metrics!Metric.allInstances() | |
| ->sortedBy(m | m.name) | |
| ->collect(m | thisModule.Metric2Table(m)); | |
| } | |
| } | |
| -- Rule 'Metric2Table' | |
| -- This rule generates a table for each different metric. | |
| lazy rule Metric2Table { | |
| from | |
| m : Metrics!Metric | |
| to | |
| ta : Table!Table ( | |
| rows <- Sequence{titleRow, m.values->collect(mv | thisModule.MetricValue2Row(mv))}->flatten() | |
| ), | |
| titleRow : Table!Row ( | |
| cells <-Sequence{titleRowCell1, titleRowCell2} | |
| ), | |
| titleRowCell1 : Table!Cell ( | |
| content <- '' | |
| ), | |
| titleRowCell2 : Table!Cell ( | |
| content <- m.name | |
| ) | |
| } | |
| -- Rule 'MetricValue2Row' | |
| -- This rule generates a row for each different metric value. | |
| lazy rule MetricValue2Row { | |
| from | |
| mv : Metrics!MetricValue | |
| to | |
| valueRow : Table!Row ( | |
| cells <- Sequence{valueCell1, valueCell2} | |
| ), | |
| valueCell1 : Table!Cell ( | |
| content <- mv.tag | |
| ), | |
| valueCell2 : Table!Cell ( | |
| content <- mv.value.toString() | |
| ) | |
| } |