Search in sources :

Example 1 with DecrementMetric

use of org.batfish.datamodel.routing_policy.expr.DecrementMetric in project batfish by batfish.

the class TransferBDD method applyLongExprModification.

/*
   * Apply the effect of modifying a long value (e.g., to set the metric)
   */
private BDDInteger applyLongExprModification(TransferParam<BDDRoute> p, BDDInteger x, LongExpr e) {
    if (e instanceof LiteralLong) {
        LiteralLong z = (LiteralLong) e;
        p.debug("LiteralLong: " + z.getValue());
        return BDDInteger.makeFromValue(x.getFactory(), 32, z.getValue());
    }
    if (e instanceof DecrementMetric) {
        DecrementMetric z = (DecrementMetric) e;
        p.debug("Decrement: " + z.getSubtrahend());
        return x.sub(BDDInteger.makeFromValue(x.getFactory(), 32, z.getSubtrahend()));
    }
    if (e instanceof IncrementMetric) {
        IncrementMetric z = (IncrementMetric) e;
        p.debug("Increment: " + z.getAddend());
        return x.add(BDDInteger.makeFromValue(x.getFactory(), 32, z.getAddend()));
    }
    throw new BatfishException("int expr transfer function: " + e);
}
Also used : BatfishException(org.batfish.common.BatfishException) LiteralLong(org.batfish.datamodel.routing_policy.expr.LiteralLong) IncrementMetric(org.batfish.datamodel.routing_policy.expr.IncrementMetric) DecrementMetric(org.batfish.datamodel.routing_policy.expr.DecrementMetric)

Aggregations

BatfishException (org.batfish.common.BatfishException)1 DecrementMetric (org.batfish.datamodel.routing_policy.expr.DecrementMetric)1 IncrementMetric (org.batfish.datamodel.routing_policy.expr.IncrementMetric)1 LiteralLong (org.batfish.datamodel.routing_policy.expr.LiteralLong)1