/* 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_INT_HPP
#define _NMM_R_INT_HPP

#include "nmm/nmm_prefix.hpp"

#include "definition.hpp"

namespace NMM {

/** This class implements an INT32 range.
*/

  class R_INT {

  private:	
    int32_t m_l_value; ///< The lower bound of the range.
    int32_t 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_INT() {};
    
    /** 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_INT(int32_t lParam, int32_t hParam, float l_weight = DEFAULT_WEIGHT, float h_weight = DEFAULT_WEIGHT);
		
    /** The default Destructor.
     */
    ~R_INT();
    
    /** Returns the lower bound of the range.
     *
     *  @return the lower bound of the range.
     */
    int32_t getLowValue() const;
        
    /** Returns the upper bound of the range.
     *
     * @return int32_t: the upper bound of the range.
     */
    int32_t getHighValue() 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 lower bound of the range.
     *
     * @param lParam the lower bound of the range.
     */
    void setLowValue(int32_t lParam);

    /** Sets the upper bound of the range.
     *
     * @param hParam the upper bound of the range.
     */
    void setHighValue(int32_t hParam);
    
    /** Sets the lower weight of the range.
     *
     * @param lWeight the lower weight of the range.
     */
    void setLowWeight(float lWeight);

    /** Sets the upper weight of the range.
     *
     * @param hWeight the upper weight of the range.
     */
    void setHighWeight(float hWeight);

    /** Prints out the values of the range.
     *
     *  Prints out the values of the range - debugging method. 
     */
    void showValue();

    /** Returns the standardized weight for this range.
     *
     * @return the standardized weight.
     */
    float getStandardizedWeight();
    
    /** Returns if the value is included in the range.
     *
     * @param value the checked value.
     * @return true if the value is included otherwise false.
     */
    bool isValueIncluded(int32_t value);

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

    /** Tests if ranges are matching.
     *
     * Returns 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(int32_t lValue, int32_t hValue);

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

    /** Print ranges on debug stream.
     *
     * @param os ostream (not used here)
     * @param reference reference to R_INT
     * @return reference to given ostream
     */
    friend ostream & operator << (ostream & os, const R_INT & reference);
  };
}

#include "nmm/nmm_suffix.hpp"

#endif
