#ifndef UI_BASE_TOUCH_AXIS_H
#define UI_BASE_TOUCH_AXIS_H

#include "base/property_bag.h"

#include <iostream>
#include <limits>
#include <string>

namespace ui {

class Axis {
 public:

  enum Type {
    AXIS_TYPE_X = 0, /**< X coordinate */
    AXIS_TYPE_Y, /**< Y coordinate */
    AXIS_TYPE_TOUCH_MAJOR, /**< Width along major axis of contact area of touch */
    AXIS_TYPE_TOUCH_MINOR, /**< Width along minor axis of contact area of touch */
    AXIS_TYPE_WIDTH_MAJOR, /**< Width along major axis of touch tool */
    AXIS_TYPE_WIDTH_MINOR, /**< Width along minor axis of touch tool */
    AXIS_TYPE_ORIENTATION, /**< Orientation of major axis of contact ellipse */
    AXIS_TYPE_TOOL, /**< Tool type */
    AXIS_TYPE_BLOB_ID, /**< Blob ID of group of touches */
    AXIS_TYPE_TRACKING_ID, /**< Tracking ID */
    AXIS_TYPE_PRESSURE, /**< Pressure */
    AXIS_TYPE_HOVER_DISTANCE, /**< Hover distance */
    AXIS_TYPE_UNKNOWN,
    AXIS_TYPE_LAST
  };

  Axis()
      : id_(-1),
        type_(AXIS_TYPE_UNKNOWN),
        name_("Unknown axis"),
        min_(-std::numeric_limits<float>::max()),
        max_(std::numeric_limits<float>::max()),
        resolution_(0.f),
        value_(0.f),
        payload_(NULL) {
  }

  ~Axis() {
    delete(payload_);
  }
  
  int id() const { return id_; }
  void set_id(int id) { id_ = id; }

  Type type() const { return type_; }
  void set_type(Type type) { type_ = type; }

  const std::string & name() const { return name_; }
  void set_name(const std::string& name) { name_ = name; }

  float min() const { return min_; }
  void set_min(float min) { min_ = min; }

  float max() const { return max_; }
  void set_max(float max) { max_ = max; }

  float resolution() const { return resolution_; }
  void set_resolution(float res) { resolution_ = res; }

  float value() const { return value_; }
  void set_value(float value) { value_ = value; }
  
  base::PropertyBag * payload() {
    if(payload_ == NULL)
      payload_ = new base::PropertyBag();

    return payload_;
  }
  
 private:
  int id_;
  Type type_;
  std::string name_;
  float min_;
  float max_;
  float resolution_;
  float value_;
  base::PropertyBag* payload_;
};

std::ostream & operator<<(std::ostream& out, const Axis& axis);

}

#endif // UI_BASE_TOUCH_AXIS_H
