"""autogenerated by genmsg_py from PointCloud.msg. Do not edit."""
import roslib.message
import struct

import test_roscpp_serialization_perf.msg
import roslib.msg

class PointCloud(roslib.message.Message):
  _md5sum = "c47b5cedd2b77d241b27547ed7624840"
  _type = "test_roscpp_serialization_perf/PointCloud"
  _has_header = True #flag to mark the presence of a Header object
  _full_text = """Header header
Point32[] pts
ChannelFloat32[] chan

================================================================================
MSG: roslib/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data 
# in a particular coordinate frame.
# 
# sequence ID: consecutively increasing ID 
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.secs: seconds (stamp_secs) since epoch
# * stamp.nsecs: nanoseconds since stamp_secs
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
# 0: no frame
# 1: global frame
string frame_id

================================================================================
MSG: test_roscpp_serialization_perf/Point32
float32 x
float32 y
float32 z
================================================================================
MSG: test_roscpp_serialization_perf/ChannelFloat32
string name
float32[] vals
"""
  __slots__ = ['header','pts','chan']
  _slot_types = ['Header','test_roscpp_serialization_perf/Point32[]','test_roscpp_serialization_perf/ChannelFloat32[]']

  def __init__(self, *args, **kwds):
    """
    Constructor. Any message fields that are implicitly/explicitly
    set to None will be assigned a default value. The recommend
    use is keyword arguments as this is more robust to future message
    changes.  You cannot mix in-order arguments and keyword arguments.
    
    The available fields are:
       header,pts,chan
    
    @param args: complete set of field values, in .msg order
    @param kwds: use keyword arguments corresponding to message field names
    to set specific fields. 
    """
    if args or kwds:
      super(PointCloud, self).__init__(*args, **kwds)
      #message fields cannot be None, assign default values for those that are
      if self.header is None:
        self.header = roslib.msg._Header.Header()
      if self.pts is None:
        self.pts = []
      if self.chan is None:
        self.chan = []
    else:
      self.header = roslib.msg._Header.Header()
      self.pts = []
      self.chan = []

  def _get_types(self):
    """
    internal API method
    """
    return self._slot_types

  def serialize(self, buff):
    """
    serialize message into buffer
    @param buff: buffer
    @type  buff: StringIO
    """
    try:
      _x = self
      buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
      _x = self.header.frame_id
      length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.pts)
      buff.write(_struct_I.pack(length))
      for val1 in self.pts:
        _x = val1
        buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
      length = len(self.chan)
      buff.write(_struct_I.pack(length))
      for val1 in self.chan:
        _x = val1.name
        length = len(_x)
        buff.write(struct.pack('<I%ss'%length, length, _x))
        length = len(val1.vals)
        buff.write(_struct_I.pack(length))
        pattern = '<%sf'%length
        buff.write(struct.pack(pattern, *val1.vals))
    except struct.error, se: self._check_types(se)
    except TypeError, te: self._check_types(te)

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    @param str: byte array of serialized message
    @type  str: str
    """
    try:
      if self.header is None:
        self.header = roslib.msg._Header.Header()
      end = 0
      _x = self
      start = end
      end += 12
      (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      self.header.frame_id = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.pts = []
      for i in xrange(0, length):
        val1 = test_roscpp_serialization_perf.msg.Point32()
        _x = val1
        start = end
        end += 12
        (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
        self.pts.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.chan = []
      for i in xrange(0, length):
        val1 = test_roscpp_serialization_perf.msg.ChannelFloat32()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1.name = str[start:end]
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        pattern = '<%sf'%length
        start = end
        end += struct.calcsize(pattern)
        val1.vals = struct.unpack(pattern, str[start:end])
        self.chan.append(val1)
      return self
    except struct.error, e:
      raise roslib.message.DeserializationError(e) #most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    @param buff: buffer
    @type  buff: StringIO
    @param numpy: numpy python module
    @type  numpy module
    """
    try:
      _x = self
      buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
      _x = self.header.frame_id
      length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.pts)
      buff.write(_struct_I.pack(length))
      for val1 in self.pts:
        _x = val1
        buff.write(_struct_3f.pack(_x.x, _x.y, _x.z))
      length = len(self.chan)
      buff.write(_struct_I.pack(length))
      for val1 in self.chan:
        _x = val1.name
        length = len(_x)
        buff.write(struct.pack('<I%ss'%length, length, _x))
        length = len(val1.vals)
        buff.write(_struct_I.pack(length))
        pattern = '<%sf'%length
        buff.write(val1.vals.tostring())
    except struct.error, se: self._check_types(se)
    except TypeError, te: self._check_types(te)

  def deserialize_numpy(self, str, numpy):
    """
    unpack serialized message in str into this message instance using numpy for array types
    @param str: byte array of serialized message
    @type  str: str
    @param numpy: numpy python module
    @type  numpy: module
    """
    try:
      if self.header is None:
        self.header = roslib.msg._Header.Header()
      end = 0
      _x = self
      start = end
      end += 12
      (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      self.header.frame_id = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.pts = []
      for i in xrange(0, length):
        val1 = test_roscpp_serialization_perf.msg.Point32()
        _x = val1
        start = end
        end += 12
        (_x.x, _x.y, _x.z,) = _struct_3f.unpack(str[start:end])
        self.pts.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.chan = []
      for i in xrange(0, length):
        val1 = test_roscpp_serialization_perf.msg.ChannelFloat32()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1.name = str[start:end]
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        pattern = '<%sf'%length
        start = end
        end += struct.calcsize(pattern)
        val1.vals = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
        self.chan.append(val1)
      return self
    except struct.error, e:
      raise roslib.message.DeserializationError(e) #most likely buffer underfill

_struct_I = roslib.message.struct_I
_struct_3I = struct.Struct("<3I")
_struct_3f = struct.Struct("<3f")
