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

import roslib.rostime
import std_msgs.msg

class ArrayOfMsgs(roslib.message.Message):
  _md5sum = "1f4cf3ffabe2555a0cfe19c974f01a01"
  _type = "test_roslib/ArrayOfMsgs"
  _has_header = False #flag to mark the presence of a Header object
  _full_text = """std_msgs/String[] strings
std_msgs/Time[] times
std_msgs/MultiArrayLayout[] muls
================================================================================
MSG: std_msgs/String
string data

================================================================================
MSG: std_msgs/Time
time data

================================================================================
MSG: std_msgs/MultiArrayLayout
# The multiarray declares a generic multi-dimensional array of a
# particular data type.  Dimensions are ordered from outer most
# to inner most.

MultiArrayDimension[] dim # Array of dimension properties
uint32 data_offset        # padding bytes at front of data

# Accessors should ALWAYS be written in terms of dimension stride
# and specified outer-most dimension first.
# 
# multiarray(i,j,k) = data[data_offset + dim_stride[1]*i + dim_stride[2]*j + k]
#
# A standard, 3-channel 640x480 image with interleaved color channels
# would be specified as:
#
# dim[0].label  = "height"
# dim[0].size   = 480
# dim[0].stride = 3*640*480 = 921600  (note dim[0] stride is just size of image)
# dim[1].label  = "width"
# dim[1].size   = 640
# dim[1].stride = 3*640 = 1920
# dim[2].label  = "channel"
# dim[2].size   = 3
# dim[2].stride = 3
#
# multiarray(i,j,k) refers to the ith row, jth column, and kth channel.
================================================================================
MSG: std_msgs/MultiArrayDimension
string label   # label of given dimension
uint32 size    # size of given dimension (in type units)
uint32 stride  # stride of given dimension
"""
  __slots__ = ['strings','times','muls']
  _slot_types = ['std_msgs/String[]','std_msgs/Time[]','std_msgs/MultiArrayLayout[]']

  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:
       strings,times,muls
    
    @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(ArrayOfMsgs, self).__init__(*args, **kwds)
      #message fields cannot be None, assign default values for those that are
      if self.strings is None:
        self.strings = []
      if self.times is None:
        self.times = []
      if self.muls is None:
        self.muls = []
    else:
      self.strings = []
      self.times = []
      self.muls = []

  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:
      length = len(self.strings)
      buff.write(_struct_I.pack(length))
      for val1 in self.strings:
        _x = val1.data
        length = len(_x)
        buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.times)
      buff.write(_struct_I.pack(length))
      for val1 in self.times:
        _v1 = val1.data
        _x = _v1
        buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
      length = len(self.muls)
      buff.write(_struct_I.pack(length))
      for val1 in self.muls:
        length = len(val1.dim)
        buff.write(_struct_I.pack(length))
        for val2 in val1.dim:
          _x = val2.label
          length = len(_x)
          buff.write(struct.pack('<I%ss'%length, length, _x))
          _x = val2
          buff.write(_struct_2I.pack(_x.size, _x.stride))
        buff.write(_struct_I.pack(val1.data_offset))
    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:
      end = 0
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.strings = []
      for i in xrange(0, length):
        val1 = std_msgs.msg.String()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1.data = str[start:end]
        self.strings.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.times = []
      for i in xrange(0, length):
        val1 = std_msgs.msg.Time()
        _v2 = val1.data
        _x = _v2
        start = end
        end += 8
        (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
        self.times.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.muls = []
      for i in xrange(0, length):
        val1 = std_msgs.msg.MultiArrayLayout()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        val1.dim = []
        for i in xrange(0, length):
          val2 = std_msgs.msg.MultiArrayDimension()
          start = end
          end += 4
          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          val2.label = str[start:end]
          _x = val2
          start = end
          end += 8
          (_x.size, _x.stride,) = _struct_2I.unpack(str[start:end])
          val1.dim.append(val2)
        start = end
        end += 4
        (val1.data_offset,) = _struct_I.unpack(str[start:end])
        self.muls.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:
      length = len(self.strings)
      buff.write(_struct_I.pack(length))
      for val1 in self.strings:
        _x = val1.data
        length = len(_x)
        buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.times)
      buff.write(_struct_I.pack(length))
      for val1 in self.times:
        _v3 = val1.data
        _x = _v3
        buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
      length = len(self.muls)
      buff.write(_struct_I.pack(length))
      for val1 in self.muls:
        length = len(val1.dim)
        buff.write(_struct_I.pack(length))
        for val2 in val1.dim:
          _x = val2.label
          length = len(_x)
          buff.write(struct.pack('<I%ss'%length, length, _x))
          _x = val2
          buff.write(_struct_2I.pack(_x.size, _x.stride))
        buff.write(_struct_I.pack(val1.data_offset))
    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:
      end = 0
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.strings = []
      for i in xrange(0, length):
        val1 = std_msgs.msg.String()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1.data = str[start:end]
        self.strings.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.times = []
      for i in xrange(0, length):
        val1 = std_msgs.msg.Time()
        _v4 = val1.data
        _x = _v4
        start = end
        end += 8
        (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
        self.times.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.muls = []
      for i in xrange(0, length):
        val1 = std_msgs.msg.MultiArrayLayout()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        val1.dim = []
        for i in xrange(0, length):
          val2 = std_msgs.msg.MultiArrayDimension()
          start = end
          end += 4
          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          val2.label = str[start:end]
          _x = val2
          start = end
          end += 8
          (_x.size, _x.stride,) = _struct_2I.unpack(str[start:end])
          val1.dim.append(val2)
        start = end
        end += 4
        (val1.data_offset,) = _struct_I.unpack(str[start:end])
        self.muls.append(val1)
      return self
    except struct.error, e:
      raise roslib.message.DeserializationError(e) #most likely buffer underfill

_struct_I = roslib.message.struct_I
_struct_2I = struct.Struct("<2I")
