/* 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_CPARAMETER_HPP
#define _NMM_CPARAMETER_HPP

#include "nmm/nmm_prefix.hpp"

#include "Parameter.hpp"
#include "Format.hpp"

namespace NMM 
{
  
  /** Stores only pointers to other Formats.
   *
   * This class stores only pointers to other Formats.
   * With this class you can describe recursive or "compound" formats like MPEG4.
   */
  
  class CParameter : public Parameter 
  {

  protected:
    
    list<Format *> m_value_list; ///< The STL-List of all the recursive included formats.
    mutable format_list::const_iterator m_counter; ///< Private variable for browsing the STL-List Format_List
    
    /** Add format internal.
     *
     * @param format Format to add.
     */
    void addValueInternal(Format* format);
    
  public:
    /** The default Constructor.
     *  
     *  @param parameter_name the name of the parameter.
     */
    CParameter(const string & parameter_name = "");
	
    /** Constructor with a parameter that is directly added to the Format_List.
     *   
     *  @param parameter_name the name of the parameter.
     *  @param format pointer to a format.
     */
    CParameter(const string & parameter_name , Format * format);
	
    /** The default Destructor.
    */  
    virtual ~CParameter();
	 
    /** Add Value.
     * 
     * @param pValue pointer to value
     */
    virtual void addValue(void * pValue);
    
    /** Adds Value.
     * 
     * @param value pointer to format
     */
    virtual void addValue(Format *value);

    /** Print 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
     * @return reference to output_stream 
     */
    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 pointer to format
     * @return true if parameter is included, false otherwise.
     */
    virtual bool isValueIncluded(const Format *value) const;
    
    /** Gets pointer to next value.
     *
     * @return void pointer to next value
     */
    virtual void *nextValue() const;
    
    /** Gets number of values.
     *
     * @return number of values
     */
    virtual uint getNumberOfValues() const;

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

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

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

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

//     virtual CParameter *getIntersectionFormat(const Parameter *reference) const;

    /** Gets Format.
     *
     * @param name name of format
     * @return pointer to format
     */
    virtual Format * getFormat(const string & name) 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 comparison parameter
     * @return true if parameter matches each other, false otherwise.
     */
     virtual bool isParameterMatching(const Parameter * reference) const;

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

    /** Returns list of formats.
     *
     * @return list of formats.
     */
    virtual const format_list & getFPointerValueList() const;

    /** Sets input stream.
     *
     * @param stream input stream to set
     */
    virtual void fromStream(IValueStream& stream);
    
    /** Sets output stream.
     *
     * @param stream output stream to set
     */
    virtual void toStream(OValueStream& stream) const  ;
  };
}


#include "nmm/nmm_suffix.hpp"

#endif
