/* 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_SPARAMETER_HPP
#define _NMM_SPARAMETER_HPP

#include "nmm/nmm_prefix.hpp"

#include "Parameter.hpp"

namespace NMM {

/**    This class stores values for STRING Parameter.
*/

  class SParameter : public Parameter 
  {
    
  private:
    map <string, float> m_value_list; ///< The STL-List to store the STRINGs.
    mutable map<string, float>::const_iterator m_value_counter; ///< for browsing in the STL-List Value_List
    mutable map<string, float>::const_iterator m_pair_counter; ///< for browsing in the STL-List Value_List
    string m_default_value; ///<  The default value
    
  public:
	
    /** The default Constructor.
     *
     * @param parameter_name the name of the parameter.
    */
    SParameter(const string & parameter_name = "");
    
    /** Constructor with a parameter pValue that is directly added to the m_value_list.
     *
     * @param parameter_name the name of the parameter.
     * @param pValue a value.
     * @param pWeight the weight of the value.
    */
    SParameter(const string & parameter_name , string pValue, float pWeight = DEFAULT_WEIGHT);
    
    /** The default Destructor.
    */
    virtual ~SParameter() {};
    
    /** 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 string value
     * @param weight weight of value
     */
    virtual void addValue(const string & 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
     */
    virtual ostream& showParameter(ostream& output_stream) const;
    
     /** Prints parameter verbose to given output stream.
     *
     * @param output_stream ostream to print parameter to
     */
    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 string value
     * @return true if parameter is included, false otherwise.
     */
    virtual bool isValueIncluded(const string & value) const;
    
    /** Returns pointer to next value.
     */
    virtual void * nextValue() const;

     /** Returns next pair.
      *
      * Returns the next pair which consists of
      * string and floats, the value and the weighting factor 
      * for this value.
      *
      * @return the next pair.
      */
    virtual map<string, 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;

    /** Returns 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;

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

    /** Returns 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;

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

    /** Sets default value.
     *
     * @param value default string value
     */
    virtual void setDefaultValue(const string & value);

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

     /** Retunrs list of string values.
     *
     * @return list of string values
     */
    virtual const string_list getStringValueList() 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
