/* 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_WPARAMETER_HPP
#define _NMM_WPARAMETER_HPP

#include "nmm/nmm_prefix.hpp"

#include "Parameter.hpp"

namespace NMM {

  /** This class stores the Wildcard-Value.
   * There 's no real storing for values, its just in virtual value.
   * That means a matching with this parameter always returns true.
   */
  
  class WParameter : public Parameter {

  private:
    
    data_value m_value; ///< value of parameter

  public:
    /** The default constructor.
     *
     * @param parameter_name the name of the parameter.
     */
    WParameter(const string & parameter_name = "");
    
    /** The default destructor.
    */
    virtual ~WParameter() {};
    
    /** Adds Value.
     * 
     * @param pValue pointer to value
     */
    virtual void addValue(void *pValue);
    
     /** 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 value is included.
     *
     * @param pValue pointer to value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(void *pValue) const;
    
    /** Tests if given value is included.
     *
     * @param value int32_t value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(int32_t value) const;
    
    /** Tests if given value is included.
     *
     * @param value float value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(float value) const;
    
    /** Tests if given value is included.
     *
     * @param value string value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(const string & value) const;
    
    /** Tests if given value is included.
     *
     * @param format format
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(Format * format) const;
    
    /** Tests if given range is included.
     *s
     * @param lValue pointer to lowest value
     * @param hValue pointer to highest value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(void * lValue, void * hValue) const;

    /** Tests if given range is included.
     *
     * @param lValue lowest float value
     * @param hValue highest float value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(float lValue, float hValue) const;

    /** Tests if given range is included.
     *
     * @param lValue lowest int32_t value
     * @param hValue highest int32_t value
     * @return true if value is included, false otherwise.
     */
    virtual bool isValueIncluded(int32_t lValue, int32_t hValue) const;

     /** Tests if given range is matching
     *
     * @param lValue lowest float value
     * @param hValue highest float value
     * @return true if given range is matching, false otherwise.
     */
    virtual bool isRangeMatching(float lValue , float hValue ) const;

    /** Tests if given range is matching
     *
     * @param lValue lowest int32_t value
     * @param hValue highest int32_t value
     * @return true if given range is matching, false otherwise.
     */
    virtual bool isRangeMatching(int32_t lValue , int32_t hValue ) const;

  
    /** Returns pointer to next value.
     */
    virtual void *nextValue() const;

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

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

    /** Returns Pointer to first value.
     *
     * @return pointer to first value
     */
    virtual void *getFirstValue() 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 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 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;

    /** Returns default value.
     *
     * @return default data_value value
     */
    virtual data_value getDefaultValue() 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  ;

  };

  // IMPLEMENTATION

  inline bool WParameter::isValueIncluded(int32_t) const {return true;}
  inline bool WParameter::isValueIncluded(float) const {return true;}
  inline bool WParameter::isValueIncluded(const string &) const {return true;}
  inline bool WParameter::isValueIncluded(Format *) const {return true;}
  inline bool WParameter::isValueIncluded(float, float) const {return true;}
  inline bool WParameter::isValueIncluded(int32_t, int32_t) const {return true;}
  inline bool WParameter::isRangeMatching(float, float) const {return true;}
  inline bool WParameter::isRangeMatching(int32_t, int32_t) const {return true;}

}

#include "nmm/nmm_suffix.hpp"

#endif
