/*
Copyright (c) 2007 Matt Williams matt@milliams.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License or (at
your option) version 3 or, at the discretion of KDE e.V. (which shall
act as a proxy as in section 14 of the GPLv3), any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef KQTIMAPPING_H
#define KQTIMAPPING_H

#include <kqti_export.h>

#include <QMap>
#include <QDomElement>

/**
 * \class KQtiMapping
 * A special class used to create a mapping from a source set of any baseType
 * (except file and duration) to a single float. Note that mappings from values
 * of base type float should be avoided due to the difficulty of matching
 * floating point values, see the match operator for more details. When mapping
 * containers the result is the sum of the mapped values from the target set.
 * See mapResponse for details.
 * 
 * http://www.imsglobal.org/question/qtiv2p1pd2/imsqti_infov2p1pd2.html#element10065
 */

class KQTI_EXPORT KQtiMapping /*This is a base class*/
{
    public:
        KQtiMapping(int lower, int upper, int defaultValue=0);
        KQtiMapping(const QDomElement& element);
        ~KQtiMapping();
        
        void setLowerBound(int lowerBound) {mMappingLowerBound = lowerBound;}
        int lowerBound() const {return mMappingLowerBound;}
        void setUpperBound(int upperBound) {mMappingUpperBound = upperBound;}
        int upperBound() const {return mMappingUpperBound;}
        void setDefaultValue(int defaultValue) {mMappingDefaultValue = defaultValue;}
        int defaultValue() const {return mMappingDefaultValue;}
        
        void add(const QString& key, int value);
        QMap<QString,int> mapEntries() const {return mMapEntries;}
        
        /**
         * element
         * @return create and return the DOM element
         */
        QDomElement element() const;

    protected:
        int mMappingLowerBound; //float?
        int mMappingUpperBound; //float?
        int mMappingDefaultValue; //float?
        QMap<QString,int> mMapEntries; //TODO Create KQtiMapEntry class
};

#endif
