00001 """autogenerated by genmsg_py from ArrayOfVariableLength.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import test_roscpp_serialization.msg
00006
00007 class ArrayOfVariableLength(roslib.message.Message):
00008 _md5sum = "e7404d454a50b82c426a3a2c76fbcefd"
00009 _type = "test_roscpp_serialization/ArrayOfVariableLength"
00010 _has_header = False
00011 _full_text = """VariableLength[4] a
00012 ================================================================================
00013 MSG: test_roscpp_serialization/VariableLength
00014 uint32[] a
00015
00016 """
00017 __slots__ = ['a']
00018 _slot_types = ['test_roscpp_serialization/VariableLength[4]']
00019
00020 def __init__(self, *args, **kwds):
00021 """
00022 Constructor. Any message fields that are implicitly/explicitly
00023 set to None will be assigned a default value. The recommend
00024 use is keyword arguments as this is more robust to future message
00025 changes. You cannot mix in-order arguments and keyword arguments.
00026
00027 The available fields are:
00028 a
00029
00030 @param args: complete set of field values, in .msg order
00031 @param kwds: use keyword arguments corresponding to message field names
00032 to set specific fields.
00033 """
00034 if args or kwds:
00035 super(ArrayOfVariableLength, self).__init__(*args, **kwds)
00036
00037 if self.a is None:
00038 self.a = [test_roscpp_serialization.msg.VariableLength(),test_roscpp_serialization.msg.VariableLength(),test_roscpp_serialization.msg.VariableLength(),test_roscpp_serialization.msg.VariableLength()]
00039 else:
00040 self.a = [test_roscpp_serialization.msg.VariableLength(),test_roscpp_serialization.msg.VariableLength(),test_roscpp_serialization.msg.VariableLength(),test_roscpp_serialization.msg.VariableLength()]
00041
00042 def _get_types(self):
00043 """
00044 internal API method
00045 """
00046 return self._slot_types
00047
00048 def serialize(self, buff):
00049 """
00050 serialize message into buffer
00051 @param buff: buffer
00052 @type buff: StringIO
00053 """
00054 try:
00055 for val1 in self.a:
00056 length = len(val1.a)
00057 buff.write(_struct_I.pack(length))
00058 pattern = '<%sI'%length
00059 buff.write(struct.pack(pattern, *val1.a))
00060 except struct.error, se: self._check_types(se)
00061 except TypeError, te: self._check_types(te)
00062
00063 def deserialize(self, str):
00064 """
00065 unpack serialized message in str into this message instance
00066 @param str: byte array of serialized message
00067 @type str: str
00068 """
00069 try:
00070 end = 0
00071 self.a = []
00072 for i in xrange(0, 4):
00073 val1 = test_roscpp_serialization.msg.VariableLength()
00074 start = end
00075 end += 4
00076 (length,) = _struct_I.unpack(str[start:end])
00077 pattern = '<%sI'%length
00078 start = end
00079 end += struct.calcsize(pattern)
00080 val1.a = struct.unpack(pattern, str[start:end])
00081 self.a.append(val1)
00082 return self
00083 except struct.error, e:
00084 raise roslib.message.DeserializationError(e)
00085
00086
00087 def serialize_numpy(self, buff, numpy):
00088 """
00089 serialize message with numpy array types into buffer
00090 @param buff: buffer
00091 @type buff: StringIO
00092 @param numpy: numpy python module
00093 @type numpy module
00094 """
00095 try:
00096 for val1 in self.a:
00097 length = len(val1.a)
00098 buff.write(_struct_I.pack(length))
00099 pattern = '<%sI'%length
00100 buff.write(val1.a.tostring())
00101 except struct.error, se: self._check_types(se)
00102 except TypeError, te: self._check_types(te)
00103
00104 def deserialize_numpy(self, str, numpy):
00105 """
00106 unpack serialized message in str into this message instance using numpy for array types
00107 @param str: byte array of serialized message
00108 @type str: str
00109 @param numpy: numpy python module
00110 @type numpy: module
00111 """
00112 try:
00113 end = 0
00114 self.a = []
00115 for i in xrange(0, 4):
00116 val1 = test_roscpp_serialization.msg.VariableLength()
00117 start = end
00118 end += 4
00119 (length,) = _struct_I.unpack(str[start:end])
00120 pattern = '<%sI'%length
00121 start = end
00122 end += struct.calcsize(pattern)
00123 val1.a = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
00124 self.a.append(val1)
00125 return self
00126 except struct.error, e:
00127 raise roslib.message.DeserializationError(e)
00128
00129 _struct_I = roslib.message.struct_I