"""
Autogenerated python message buffer code.
Source: clad/types/salientPointTypes.clad
Full command line: victor-clad/tools/message-buffers/emitters/Python_emitter.py -I coretech/vision/clad_src coretech/common/clad_src -o generated/cladPython clad/types/salientPointTypes.clad
"""

from __future__ import absolute_import
from __future__ import print_function

def _modify_path():
  import inspect, os, sys
  search_paths = [
    '../..',
    '../../../../victor-clad/tools/message-buffers/support/python',
  ]
  currentpath = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())))
  for search_path in search_paths:
    search_path = os.path.normpath(os.path.abspath(os.path.realpath(os.path.join(currentpath, search_path))))
    if search_path not in sys.path:
      sys.path.insert(0, search_path)
_modify_path()

import msgbuffers

Anki = msgbuffers.Namespace()
Anki.Vision = msgbuffers.Namespace()

from clad.types.cladPoint import Anki as _Anki
Anki.update(_Anki.deep_clone())

class SalientPointType(object):
  "Automatically-generated uint_8 enumeration."
  BrightColors     = 0
  Cat              = 1
  Dog              = 2
  Face             = 3
  Hand             = 4
  Object           = 5
  Person           = 6
  SceneDescription = 7
  Text             = 8
  Unknown          = 9

Anki.Vision.SalientPointType = SalientPointType
del SalientPointType


class SalientPoint(object):
  "Generated message-passing structure."

  __slots__ = (
    '_timestamp',     # uint_32
    '_x_img',         # float_32
    '_y_img',         # float_32
    '_score',         # float_32
    '_area_fraction', # float_32
    '_salientType',   # Anki.Vision.SalientPointType
    '_description',   # string[uint_8]
    '_shape',         # CladPoint2d[uint_8]
    '_color_rgba',    # uint_32
  )

  @property
  def timestamp(self):
    "uint_32 timestamp struct property."
    return self._timestamp

  @timestamp.setter
  def timestamp(self, value):
    self._timestamp = msgbuffers.validate_integer(
      'SalientPoint.timestamp', value, 0, 4294967295)

  @property
  def x_img(self):
    "float_32 x_img struct property."
    return self._x_img

  @x_img.setter
  def x_img(self, value):
    self._x_img = msgbuffers.validate_float(
      'SalientPoint.x_img', value, 'f')

  @property
  def y_img(self):
    "float_32 y_img struct property."
    return self._y_img

  @y_img.setter
  def y_img(self, value):
    self._y_img = msgbuffers.validate_float(
      'SalientPoint.y_img', value, 'f')

  @property
  def score(self):
    "float_32 score struct property."
    return self._score

  @score.setter
  def score(self, value):
    self._score = msgbuffers.validate_float(
      'SalientPoint.score', value, 'f')

  @property
  def area_fraction(self):
    "float_32 area_fraction struct property."
    return self._area_fraction

  @area_fraction.setter
  def area_fraction(self, value):
    self._area_fraction = msgbuffers.validate_float(
      'SalientPoint.area_fraction', value, 'f')

  @property
  def salientType(self):
    "Anki.Vision.SalientPointType salientType struct property."
    return self._salientType

  @salientType.setter
  def salientType(self, value):
    self._salientType = msgbuffers.validate_integer(
      'SalientPoint.salientType', value, 0, 255)

  @property
  def description(self):
    "string[uint_8] description struct property."
    return self._description

  @description.setter
  def description(self, value):
    self._description = msgbuffers.validate_string(
      'SalientPoint.description', value, 255)

  @property
  def shape(self):
    "CladPoint2d[uint_8] shape struct property."
    return self._shape

  @shape.setter
  def shape(self, value):
    self._shape = msgbuffers.validate_varray(
      'SalientPoint.shape', value, 255,
      lambda name, value_inner: msgbuffers.validate_object(
        name, value_inner, Anki.CladPoint2d))

  @property
  def color_rgba(self):
    "uint_32 color_rgba struct property."
    return self._color_rgba

  @color_rgba.setter
  def color_rgba(self, value):
    self._color_rgba = msgbuffers.validate_integer(
      'SalientPoint.color_rgba', value, 0, 4294967295)

  def __init__(self, timestamp=0, x_img=0.0, y_img=0.0, score=0.0, area_fraction=0.0, salientType=Anki.Vision.SalientPointType.BrightColors, description='', shape=(), color_rgba=0):
    self.timestamp = timestamp
    self.x_img = x_img
    self.y_img = y_img
    self.score = score
    self.area_fraction = area_fraction
    self.salientType = salientType
    self.description = description
    self.shape = shape
    self.color_rgba = color_rgba

  @classmethod
  def unpack(cls, buffer):
    "Reads a new SalientPoint from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('SalientPoint.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new SalientPoint from the given BinaryReader."
    _timestamp = reader.read('I')
    _x_img = reader.read('f')
    _y_img = reader.read('f')
    _score = reader.read('f')
    _area_fraction = reader.read('f')
    _salientType = reader.read('B')
    _description = reader.read_string('B')
    _shape = reader.read_object_varray(Anki.CladPoint2d.unpack_from, 'B')
    _color_rgba = reader.read('I')
    return cls(_timestamp, _x_img, _y_img, _score, _area_fraction, _salientType, _description, _shape, _color_rgba)

  def pack(self):
    "Writes the current SalientPoint, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current SalientPoint to the given BinaryWriter."
    writer.write(self._timestamp, 'I')
    writer.write(self._x_img, 'f')
    writer.write(self._y_img, 'f')
    writer.write(self._score, 'f')
    writer.write(self._area_fraction, 'f')
    writer.write(self._salientType, 'B')
    writer.write_string(self._description, 'B')
    writer.write_object_varray(self._shape, 'B')
    writer.write(self._color_rgba, 'I')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._timestamp == other._timestamp and
        self._x_img == other._x_img and
        self._y_img == other._y_img and
        self._score == other._score and
        self._area_fraction == other._area_fraction and
        self._salientType == other._salientType and
        self._description == other._description and
        self._shape == other._shape and
        self._color_rgba == other._color_rgba)
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return (msgbuffers.size(self._timestamp, 'I') +
      msgbuffers.size(self._x_img, 'f') +
      msgbuffers.size(self._y_img, 'f') +
      msgbuffers.size(self._score, 'f') +
      msgbuffers.size(self._area_fraction, 'f') +
      msgbuffers.size(self._salientType, 'B') +
      msgbuffers.size_string(self._description, 'B') +
      msgbuffers.size_object_varray(self._shape, 'B') +
      msgbuffers.size(self._color_rgba, 'I'))

  def __str__(self):
    return '{type}(timestamp={timestamp}, x_img={x_img}, y_img={y_img}, score={score}, area_fraction={area_fraction}, salientType={salientType}, description={description}, shape={shape}, color_rgba={color_rgba})'.format(
      type=type(self).__name__,
      timestamp=self._timestamp,
      x_img=self._x_img,
      y_img=self._y_img,
      score=self._score,
      area_fraction=self._area_fraction,
      salientType=self._salientType,
      description=msgbuffers.shorten_string(self._description),
      shape=msgbuffers.shorten_sequence(self._shape),
      color_rgba=self._color_rgba)

  def __repr__(self):
    return '{type}(timestamp={timestamp}, x_img={x_img}, y_img={y_img}, score={score}, area_fraction={area_fraction}, salientType={salientType}, description={description}, shape={shape}, color_rgba={color_rgba})'.format(
      type=type(self).__name__,
      timestamp=repr(self._timestamp),
      x_img=repr(self._x_img),
      y_img=repr(self._y_img),
      score=repr(self._score),
      area_fraction=repr(self._area_fraction),
      salientType=repr(self._salientType),
      description=repr(self._description),
      shape=repr(self._shape),
      color_rgba=repr(self._color_rgba))

Anki.Vision.SalientPoint = SalientPoint
del SalientPoint


