// file: $isip/class/math/scalar/Float/Float.h
// version: $Id: Float.h 10636 2007-01-26 22:18:09Z tm334 $
//

// make sure definitions are only made once
//
#ifndef ISIP_FLOAT
#define ISIP_FLOAT

// isip include files
//
#ifndef ISIP_SCALAR
#include <MScalar.h>
#endif

// Float: a class that manages a 32-bit float. this class mainly
// inherits the MScalar template functionality. we only need to add Sof file
// support and memory management
//
class Float : public MScalar<float, float32> {

  //---------------------------------------------------------------------------
  //
  // public constants
  //
  //---------------------------------------------------------------------------
public:

  // define the class name
  //
  static const String CLASS_NAME;

  //----------------------------------------
  //
  // other important constants
  //
  //----------------------------------------
  
  //----------------------------------------
  //
  // default values and arguments
  //
  //----------------------------------------  

  // define the default value(s) of the class data
  //

  // default arguments to methods
  //
  
  //----------------------------------------
  //
  // error codes
  //
  //----------------------------------------  

  static const long ERR = 21000;

  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:

  // static memory manager
  //
  static MemoryManager mgr_d;
  
  //---------------------------------------------------------------------------
  //
  // required public methods
  //
  //---------------------------------------------------------------------------
public:

  // method: name
  //
  static const String& name() {
    return CLASS_NAME;
  }

  // other static methods
  //
  static boolean diagnose(Integral::DEBUG debug_level);

  // debug methods:
  //  the setDebug method is inherited from the MScalar template class
  //
  boolean debug(const unichar* message) const;
  
  // method: destructor
  //
  ~Float() {}
  
  // method: default constructor
  //
  Float(float arg = DEF_VALUE) {
    value_d = arg;
  }

  // method: copy constructor
  //
  Float(const Float& arg) {
    assign(arg.value_d);
  }

  // assign methods:
  //  these methods are inherited from the MScalar template class
  //

  // method: operator=
  //
  Float& operator= (const Float& arg) {
    assign(arg);
    return *this;
  }
    
  // i/o methods:
  //  sofSize, readData and writeData are inherited from the MScalar
  //  template class
  //

  // method: read
  //
  boolean read(Sof& sof, long tag, const String& name = CLASS_NAME) {
    return MScalar<float, float32>::read(sof, tag, name);
  }

  // method: write
  //
  boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const {
    return MScalar<float, float32>::write(sof, tag, name);
  }
  
  // equality methods:
  //  the eq method is inherited from the MScalar template class
  //

  // method: new
  //
  static void* operator new(size_t size) {
    return mgr_d.get();
  }

  // method: new[]
  //
  static void* operator new[](size_t size) {
    return mgr_d.getBlock(size);
  }

  // method: delete
  //
  static void operator delete(void* ptr) {
    mgr_d.release(ptr);
  }

  // method: delete[]
  //
  static void operator delete[](void* ptr) {
    mgr_d.releaseBlock(ptr);
  }

  // method: setGrowSize
  //
  static boolean setGrowSize(long grow_size) {
    return mgr_d.setGrow(grow_size);
  }

  // other memory management methods:
  //  these methods are inherited from the MScalar template class
  //
  
  //-----------------------------------------------------------------------
  //
  // class-specific public methods
  //
  //-----------------------------------------------------------------------

  // method: operator=
  //
  Float& operator= (float arg) {
    value_d = arg;
    return *this;
  }

  // method: fraction
  //
  float fraction(float arg) {
    return (value_d = Integral::fraction(arg));
  }

  float bor(float arg0, float arg1) {
    return (float) 0;
  }
  float band(float arg0, float arg1) {
    return (float) 0;
  }
  float bxor(float arg0, float arg1) {
    return (float) 0;
  }
  float brs(float arg0, float arg1) {
    return (float) 0;
  }
  float bls(float arg0, float arg1) {
    return (float) 0;
  }
  float bcmpl(float arg) {
    return (float) 0;
  }
  float mod(float arg0, float arg1) {
    return (float) 0;
  }
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

/*   // declare bitwise methods as private member functions because they */
/*   // are not defined for floating point operations */
/*   // */
/*   float bor(float, float); */
/*   float band(float, float); */
/*   float bxor(float, float); */
/*   float brs(float, float); */
/*   float bls(float, float); */
/*   float bcmpl(float); */

/*   // declare modulus methods as private member functions because they */
/*   // are not defined for floating point operations */
/*   // */
/*   float mod(float, float); */
/*   float& operator%= (float); */
/*   float operator% (float); */

};

// end of include file
//
#endif
