/*
 * class ImageVector
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef IMAGE_VECTOR_HH__
#define IMAGE_VECTOR_HH__

#include "WImage/miscdefs.h"
#include "WImage/ImageArray.hh"
#include "WImage/ReferenceVector.hh"

/**
 * @addtogroup WImage
 * @{ */

/**
 * Pseudo-vector (abstract) for use with two-dimensional objects, like
 * images. Provide a two-dimensional array's rows and columns as
 * vectors with array addressing.
 */
/*abstract*/
class
ImageVector : public ReferenceVector
{
public:

  /** Constructor. Sets the array reference. */
  ImageVector (ImageArray<coeff> *ar);
  /** Destructor. Does nothing. */
  virtual ~ImageVector (void) {};

  /** Checks integrity. If the array's dimensions have been changed
   * (resize operation) {\em false} will be returned. */
  virtual bool sanity (void);
  /** Updates the vector's settings. This is necessary each time after
   * the array has been resized. */
  virtual void update (void);

  /** Set new root. Depending of what concrete instance is the current
   * row or col will be set.
   * @exception invalid_argument
   * a negative value was given for the new root
   * @param root
   * the new root */
  virtual void go (int root);

  /** Return a value (abstract). The value is taken from the vector's
   * position {\em pos}.
   * @param pos
   * the position
   * @return
   * the value at that position */
  virtual coeff at (int pos) = 0;

  /** Assign a value (abstract). A new value {\em val} is assigned to
   * the vector's position {\em pos}.
   * @param pos
   * the position
   * @param val
   * the new value */
  virtual void to (int pos, coeff val) = 0;
  /** Return the vector's size (abstract). Depending on the concrete
   * instance we will get the associated array's number of rows or cols.
   * @return
   * the vector's size */
  virtual int size (void) = 0;
  /**
   * Return the sum of the vector's absolute values
   * @return the sum of the vector's absolute values
   */
  coeff weight(void);

protected:
  /** A reference to encapsuled array. Rows and cols will be taken from
   * this array. */
  ImageArray<coeff> *m_array;
  /** The encapsulated array's cols. */
  int m_xsize;
  /** The encapsulated array's rows . */
  int m_ysize;

}; /* class ImageVector */

/** @} */

#endif /* IMAGE_VECTOR_HH__ */

