/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM 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; only version 2 of the License.      
 * 
 * NMM 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 NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */


#ifndef _NMM_FPARAMETER_HPP
#define _NMM_FPARAMETER_HPP

#include "nmm/nmm_prefix.hpp"

#include "Parameter.hpp"

namespace NMM {

/**
 *   This class stores float Parameter-Values.
 */

  class FParameter : public Parameter 
  {
    
  protected:
    map<float,float> m_value_list; ///< The STL-List to store the floats
    mutable map<float,float>::const_iterator m_value_counter; ///< Private Variable for browsing the m_value_list
    mutable map<float,float>::const_iterator m_pair_counter;  ///< Private Variable for browsing the pairs of m_value_list

    float m_default_value; ///< The default value
	
  public:
    /**
     * The default Constructor.
     *
     * @param parameter_name the Name of the Parameter.
    */
    FParameter(const string & parameter_name ="");
    
    /**
     * Constructor with a parameter pValue that is directly added to the value list.
     *
     * @param parameter_name the name of the parameter
     * @param pValue the value of the parameter
     * @param pWeight the weight of parameter
     */
    FParameter(const string & parameter_name, float pValue, float pWeight =  DEFAULT_WEIGHT);	
    
    /**
     *  The default destructor.
     */
    ~FParameter() {};
    
    /** Adds Value.
     * 
     * @param pValue pointer to value
     */
    virtual void addValue(void *pValue);

    /** Adds Value.
     * 
     * @param pValue pointer to value
     * @param pWeight weight of value
     */
    virtual void addValue(void *pValue, float pWeight = DEFAULT_WEIGHT);
    
    /** Adds Value.
     * 
     * @param value float value
     * @param weight weight of value
     */
    virtual void addValue(float value, float weight = DEFAULT_WEIGHT);

    /** Prints parameter.
     */
    virtual void showParameter() const;
    
    /** Prints parameter to given output stream.
     *
     * @param output_stream ostream to print parameter to
     * @return reference to given ostream
     */
    virtual ostream& showParameter(ostream& output_stream) const;
    
    /** Prints parameter verbose to given output stream.
     *
     * @param output_stream ostream to print parameter to
     * @return reference to given ostream
     */
    virtual ostream& showParameterVerbose(ostream& output_stream) const;

    /** Tests if given parameter is included.
     *
     * @param pValue pointer to value
     * @return true if parameter is included, false otherwise.
     */
    virtual bool isValueIncluded(void *pValue) const;
    
    /** Tests if given parameter is included.
     *
     * @param value float value
     * @return true if parameter is included, false otherwise.
     */
    virtual bool isValueIncluded(float value) const;

    /** Get pointer to next value.
     *
     * @return void pointer to next value
     */
    virtual void *nextValue() const;

    /** Returns interator to next pair which.
     *
     * Returns interator to the next pair which consists of
     * two floats, the value and the weighting factor 
     * for this value.
     *
     * @return FLOAT_Iterator: the next pair.
    */
    virtual map<float,float>::const_iterator nextPair() const;

    /** Duplicates parameter.
     *
     * @return poitner to parameter duplicate
     */
    virtual Parameter * duplicate() const;

    /** Returns weight of parameter.
     *
     * @param pValue pointer to parameter
     * @return weigth of parameter
     */
    virtual float getWeight(void *pValue) const;

    /** Gets number of values.
     *
     * @return number of values
     */
    virtual uint getNumberOfValues() const;

    /** Checks if parameter is included.
     *
     * @param reference pointer to parameter
     * @return true if parameter is included, false otherwise.
     */
    virtual bool isParameterIdentical(const Parameter *reference) const;

    /** Checks if parameters match.
     *
     * @param reference pointer to parameter
     * @return true if parameter matches each other, false otherwise.
     */
     virtual bool isParameterMatching(const Parameter *reference) const;

    /** Get intersection of this and given parameter.
     *
     * @param reference pointer to second parameter
     * @return intersection of the two parameter
     */
    virtual Parameter * getIntersection(const Parameter *reference) const;

    /** Get Pointer to first value.
     *
     * @return pointer to first value
     */
    virtual void * getFirstValue() const;

    /** Get standardized weight.
     *
     * @return standardized weight
     */
    virtual float getStandardizedWeight() const;

    /** Returns default value.
     *
     * @return default value
     */
    virtual float getDefaultValue() const;

    /** Set default value.
     *
     * @param param default value
     */
    virtual void setDefaultValue(float param);

    /** Get lowest value.
     *
     * @return lowest value
     */
    virtual float getLowestValue() const;

    /** Get highest value.
     *
     * @return highest value
     */
    virtual float getHighestValue() const;

    /** Get list of float values.
     *
     * @return list of float values
     */
    virtual const float_list getFloatValueList() const;

    /** Set input stream.
     *
     * @param stream input stream to set
     */
    virtual void fromStream(IValueStream& stream);
    
    /** Set output stream.
     *
     * @param stream output stream to set
     */
    virtual void toStream(OValueStream& stream) const  ;
  };
}
#include "nmm/nmm_suffix.hpp"

#endif
