/* 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_IPARAMETER_HPP
#define _NMM_IPARAMETER_HPP

#include "nmm/nmm_prefix.hpp"

#include "Parameter.hpp"

namespace NMM 
{

  class OValueStream;
  class IValueStream;
  /**
   * The class IParameter is derived from the parameter-class and stores 
   * 32-Bit Integer-Values.
  */

  class IParameter : public Parameter 
  {

  private:
    map <int32_t, float> m_value_list; ///< The STL-List wich stores the INT32-values.
    
    /* Iterator for this datatyp. */
    mutable map<int32_t,float>::const_iterator m_value_counter;
    mutable map<int32_t,float>::const_iterator m_pair_counter;
    
    int32_t m_default_value; ///< The default value
    
  public:
    /** The constructur of the class.
     *
     * @param pName the name of the parameter.
    **/
    
    IParameter(const string & pName = "");
    
    /** The constructor adds directly pValue to the Value(-List).
     *
     * @param pName the name of the parameter.
     * @param pValue a value.
     * @param pWeight a weighting factor
    **/
    IParameter(string pName, int32_t pValue, float pWeight = DEFAULT_WEIGHT);
    
    /** The default destructor.
    **/
    virtual ~IParameter();
    
    /** Adds Value.
     *
     * @param pValue pointer to value
     */
    virtual void addValue(void * pValue);
    
    /** Adds Value.
     *
     * @param pValue pointer to value
     * @param pWeight weith of value
     */
    virtual void addValue(void * pValue, float pWeight = DEFAULT_WEIGHT);
    
    /** Adds Value.
     *
     * @param pValue int32_t value
     * @param weight weigth of value
     */
    virtual void addValue(int32_t pValue, 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 inte32_t value
     * @return True if parameter is included, false otherwise.
     */
    virtual bool isValueIncluded(int32_t value) const;

    /** Returns pointer to next value.
     *
     * @return pointer to next value
     */
    virtual void * nextValue() const;
    
    /** Returns iterator to next pair.
     *
     * Returns interator toe next pair which consists of 
     * an int32_t and a float, representing the value
     * and the weight.
     * @return INT32_Iterator: the next pair.
    **/
    virtual map<int32_t,float>::const_iterator nextPair() const;
    
    /** Duplicates parameter.
     *
     * @return poitner to parameter
     */
    virtual Parameter *duplicate() const;
    
    /** Returns weight of parameter.
     *
     * @param pValue pointer to parameter
     * @return weigth of parameter
     */
    virtual float getWeight(void *pValue) const;
    
    /** Checks if parameter is included.
     *
     * @param param pointer to parameter
     * @return true if parameter is included, false otherwise.
     */
    virtual bool isParameterIdentical(const Parameter *param) const;

    /** Checks if parameters match.
     *
     * @param param pointer to parameter
     * @return true if parameter matches each other, false otherwise.
     */
     virtual bool isParameterMatching(const Parameter *param) const;
    
    /** Gets number of values.
     *
     * @return number of values
     */
    virtual uint getNumberOfValues() const;
    
    /** Gets 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;

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

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

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

    /** Return default value.
     *
     * @return default int32_t value
     */
    virtual int32_t getDefaultValue() const;

    /** Return lowest value.
     *
     * @return lowest int32_t value
     */
    virtual int32_t getLowestValue() const;

    /** Return highest value.
     *
     * @return highest int32_t value
     */
    virtual int32_t getHighestValue() const;

    /** Return list of int32_t values.
     *
     * @return list of int32_t values.
     */
    virtual const int32_t_list getIntValueList() const;

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

#endif
