Source: range.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                      RTP Audio Server Project                    ####
// ####                    ============================                  ####
// ####                                                                  ####
// #### Range Template                                                   ####
// ####                                                                  ####
// #### Version 1.00  --  February 23, 2001                              ####
// ####                                                                  ####
// #### Copyright (C) 1999  Thomas Dreibholz                             ####
// ####               2000  Universität Bonn, Abt. IV                    ####
// ####               2001  EMail: Dreibholz@bigfoot.com                 ####
// ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
// ####                                                                  ####
// ##########################################################################


#ifndef RANGE_H
#define RANGE_H


#include "system.h"


/**
  * This class implements the Range datatype template. It manages a value which
  * has to be in the range from Min to Max. The only allowed exception is the
  * value 0, which is available even if it is outside of the given range.
  *
  * @short   Range
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
template<class T> class Range
{
   // ====== Constructors ===================================================
   public:
   /**
     * Default constructor.
     */
   Range();   

   /**
     * Create new range with given parameters.
     *
     * @param min Minimum.
     * @param max Maximum.
     * @param value Value between Minimum and Maximum.
     */
   Range(const T min, const T max, const T value);

   
   // ====== Initialization =================================================
   /**
     * Initialize range with given parameters.
     *
     * @param min Minimum.
     * @param max Maximum.
     * @param value Value between Minimum and Maximum.
     */
   void init(const T min, const T max, const T value);

      
   // ====== Range functions ================================================
   /**
     * Get minimum.
     *
     * @return Minimum.
     */     
   inline T getMin()   const;

   /**
     * Get maximum.
     *
     * @return Maximum.
     */     
   inline T getMax()   const;

   /**
     * Get value.
     *
     * @return Value.
     */     
   inline T getValue() const;

   /**
     * Set limits.
     *
     * @param min Minimum.
     * @param max Maximum.
     */
   inline void setLimits(const T min, const T max);

   /**
     * Set value.
     *
     * @param value Value.
     */
   inline void setValue(const T value);   


   // ====== "="-operator ===================================================   
   /**
     * Implementation of = operator
     */
   Range<T>& operator=(const Range<T>& range);


   // ====== Comparision operators ==========================================
   /**
     * == operator.
     */
   inline int operator==(const Range<T>& ti) const;

   /**
     * != operator.
     */
   inline int operator!=(const Range<T>& ti) const;


   // ====== Private data ===================================================
   public:  // Public because of byte order translation!
   T Min;
   T Max;
   T Value;
};


/**
  * << operator.
  */
template<class T> ostream& operator<<(ostream& os, const Range<T>& range);


#include "range.icc"
#include "range.cc"


#endif

Generated by: viper@odin on Fri Feb 23 12:41:26 2001, using kdoc 2.0a36.