/* 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_R_FLOAT_HPP
#define _NMM_R_FLOAT_HPP

#include "nmm/nmm_prefix.hpp"

#include "definition.hpp"

namespace NMM {
	
/** This class implements a float range.
*/
  class R_FLOAT 
  {
    
  private:	
    float m_l_value; ///< The lower bound of the range.
    float m_h_value; ///< The upper bound of the range.
    float m_l_weight; ///< The lower weight of the range.
    float m_h_weight; ///< The upper weight of the range.

  public:
    
    /** The default Constructor.
    */
    R_FLOAT() {};
    
    /** Constructor with additional parameters.
     *
     * Constructor with additional parameters wich set directly 
     * the member-variables m_l_value and m_h_value.
     * Additionally the weighting factor can be specified in the
     * parameters l_weight and h_weight.
     *
     * @param lParam the lower bound of the range.
     * @param hParam the upper bound of the range.
     * @param l_weight the lower weight of the range.
     * @param h_weight the upper weight of the range.
    */
    R_FLOAT(float lParam, float hParam, float l_weight = DEFAULT_WEIGHT, float h_weight = DEFAULT_WEIGHT);

    /** The default Destructor
    */
    ~R_FLOAT();
    
    /** Returns the upper bound of the range.
     * @return the upper bound of the range.
     */
    float getHighValue() const;
    
    /**
     *  Returns the lower bound of the range.
     *
     * @return the lower bound of the range.
     */
    float getLowValue() const;
    
    /** Returns the lower weight of the range.
     *
     * @return the lower weight of the range.
     */
    float getLowWeight() const;

    /** Returns the upper weight of the range.
     * @return the upper weight of the range.
     */
    float getHighWeight() const;
    
    /** Sets the upper bound of the range.
     *
     * @param h_param the upper bound of the range.
     */
    void  setHighValue(float h_param);
    
    /** Sets the lower bound of the range.
     *
     * @param l_param the lower bound of the range.
    */
    void  setLowValue(float l_param);
    
    /** Sets the lower weight of the range.
     * @param l_weight the lower weight of the range.
    */
    void setLowWeight(float l_weight);

    /** Sets the upper weight of the range.
     * @param h_weight the upper weight of the range.
     */
    void setHighWeight(float h_weight);
    
    /** Prints out the range. 
     * 
     * Prints out the range - debugging method.
    */
    void showValue();

    /** Returns the standardized weight for the range.
     *        
     * @return the standardized weight.
     */
    float getStandardizedWeight();

    /** Tests if the parameter value is included in the range.
     *
     * @param value the checked value.
     * @return true if the value is included otherwise false.
     */
    bool isValueIncluded(float value);

    /** Tests if the range from lValue to hValue is included in the range.
     *
     * @param lValue the lower bound of the checked range.
     * @param hValue the upper bound of the checked range.
     * @return true if the range is included otherwise false.
     */
    bool isRangeIncluded(float lValue, float hValue);

    /** Tests if the range from lValue to hValue has an intersection with the range.
     *
     * @param lValue the lower bound of the range.
     * @param hValue the upper bound of the range.
     * @return true if the range has an intersection otherwise false.
     */
    bool isRangeMatching(float lValue, float hValue);

    
    /** Tests if the range from lValue to hValue is identical with the current instance.
     *
     * @param lValue the upper bound of the range.
     * @param hValue the lower bound of the range.
     * @return true if identical, otherwise false.
     */
    bool isRangeIdentical(float lValue, float hValue) const;
    
    /** Tests if ranges are identical.
     *
     * @param lhs first R_FLOAT
     * @param rhs second R_FLOAT
     * @return true if ranges are identical, false otherwise
     */
    friend bool operator == (const R_FLOAT & lhs, const R_FLOAT & rhs);

    /** Outputs given R_FLOAT to global debug stream.
     *
     * @param os ostream (not used here)
     * @param reference reference to R_FLOAT 
     */
    friend ostream & operator << (ostream & os, const R_FLOAT & reference);

  };
}
#include "nmm/nmm_suffix.hpp"

#endif

