001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2006-2011 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.calc.impl;
011
012import mondrian.calc.*;
013import mondrian.olap.Evaluator;
014import mondrian.olap.Exp;
015import mondrian.olap.type.SetType;
016
017/**
018 * Abstract implementation of the {@link mondrian.calc.IterCalc} interface.
019 *
020 * <p>The derived class must
021 * implement the {@link #evaluateIterable(mondrian.olap.Evaluator)} method,
022 * and the {@link #evaluate(mondrian.olap.Evaluator)} method will call it.
023 *
024 * @see mondrian.calc.impl.AbstractListCalc
025 *
026 * @author jhyde
027 * @since Oct 24, 2008
028 */
029public abstract class AbstractIterCalc
030    extends AbstractCalc
031    implements IterCalc
032{
033    /**
034     * Creates an abstract implementation of a compiled expression which returns
035     * a {@link TupleIterable}.
036     *
037     * @param exp Expression which was compiled
038     * @param calcs List of child compiled expressions (for dependency
039     *   analysis)
040     */
041    protected AbstractIterCalc(Exp exp, Calc[] calcs) {
042        super(exp, calcs);
043    }
044
045    public SetType getType() {
046        return (SetType) super.getType();
047    }
048
049    public final Object evaluate(Evaluator evaluator) {
050        return evaluateIterable(evaluator);
051    }
052
053    public ResultStyle getResultStyle() {
054        return ResultStyle.ITERABLE;
055    }
056
057    public String toString() {
058        return "AbstractIterCalc object";
059    }
060}
061
062// End AbstractIterCalc.java