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

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

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

// Short: a class that manages a 16-bit signed integer. this class mainly
// inherits the MScalar template functionality. we only need to add Sof file
// support and memory management
//
class Short : public MScalar<short, int16> {

  //---------------------------------------------------------------------------
  //
  // 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 = 20700;

  //---------------------------------------------------------------------------
  //
  // 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
  //
  ~Short() {}

  // method: default constructor
  //
  Short(short arg = DEF_VALUE) {
    value_d = arg;
  }

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

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

  // method: operator=
  //
  Short& operator= (const Short& arg) {
    assign(arg);
    return *this;
  }
    
  // i/o methods:
  //  the 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<short, int16>::read(sof, tag, name);
  }

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

  // equality methods:
  //  these methods are 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:
  //  these methods are inherited from the MScalar template class
  //

  //---------------------------------------------------------------------------
  //
  // class-specific public methods
  //
  //---------------------------------------------------------------------------
public:
  
  // method: operator=
  //
  Short& operator= (short arg) {
    value_d = arg;
    return *this;
  }

  // method: operator %
  //
  short operator% (short arg) const {
    return value_d % arg;
  }

  // method: operator %=
  //
  Short& operator%= (short arg) {
    value_d %= arg;
    return *this;
  }

  // method: mod
  //
  short mod(short arg2) {
    return mod(value_d, arg2);
  }

  // method: mod
  //
  short mod(short arg1, short arg2) {
    return (value_d = arg1 % arg2);
  }

  // method: band
  //
  short band(short arg) {
    return band(value_d, arg);
  }

  // method: band
  //
  short band(short arg1, short arg2) {
    return (value_d = (arg1 & arg2));
  }

  // method: bor
  //
  short bor(short arg) {
    return bor(value_d, arg);
  }

  // method: bor
  //
  short bor(short arg1, short arg2) {
    return (value_d = (arg1 | arg2));
  }

  // method: bxor
  //
  short bxor(short arg) {
    return bxor(value_d, arg);
  }

  // method: bxor
  //
  short bxor(short arg1, short arg2) {
     return (value_d = (arg1 ^ arg2));
  }

  // method: brs
  //
  short brs(short incr) {
    return brs(value_d, incr);
  }

  // method: brs
  //
  short brs(short arg, short incr) {
    return (value_d = (arg >> incr));
  }

  // method: bls
  //
  short bls(short incr) {
    return bls(value_d, incr);
  }

  // method: bls
  //
  short bls(short arg, short incr) {
    return (value_d = (arg << incr));
  }

  // method: bcmpl
  //
  short bcmpl() {
    return bcmpl(value_d);
  }

  // method: bcmpl
  //
  short bcmpl(short arg) {
    return (value_d = (~arg));
  }

  short acos(short arg) {
    return (short) 0;
  }
  short acosh(short arg) {
    return (short) 0;
  }
  short asin(short arg) {
    return (short) 0;
  }
  short asinh(short arg) {
    return (short) 0;
  }
  short atan(short arg) {
    return (short) 0;
  }
  short atanh(short arg) {
    return (short) 0;
  }
  short cos(short arg) {
    return (short) 0;
  }
  short cosh(short arg) {
    return (short) 0;
  }
  short sin(short arg) {
    return (short) 0;
  }
  short sinh(short arg) {
    return (short) 0;
  }
  short tan(short arg) {
    return (short) 0;
  }
  short tanh(short arg) {
    return (short) 0;
  }
  short ceil(short arg) {
    return (short) 0;
  }
  short rceil(short arg) {
    return (short) 0;
  }
  short rfloor(short arg) {
    return (short) 0;
  }
  short round(short arg) {
    return (short) 0;
  }
  short floor(short arg) {
    return (short) 0;
  }
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

/*   //declare trigonometric methods as private because they cannot be */
/*   //defined for Short operations */
/*   // */
/*   short acos(short); */
/*   short acosh(short); */
/*   short asin(short); */
/*   short asinh(short); */
/*   short atan(short); */
/*   short atanh(short); */
/*   short cos(short); */
/*   short cosh(short); */
/*   short sin(short); */
/*   short sinh(short); */
/*   short tan(short); */
/*   short tanh(short); */
  
/*   //declare those methods as private which cannot be defined for */
/*   //integer numbers */
/*   //   */
/*   short ceil(short); */
/*   short rceil(short); */
/*   short rfloor(short); */
/*   short round(short); */
/*   short floor(short); */

};

// end of include file
//
#endif
