00001 """autogenerated by genpy from sharedmem_transport/SharedMemBlock.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007
00008 class SharedMemBlock(genpy.Message):
00009 _md5sum = "56cdbb4565401cc80f0d826e209bbbe5"
00010 _type = "sharedmem_transport/SharedMemBlock"
00011 _has_header = False
00012 _full_text = """uint32 handle
00013 uint32 size
00014 uint32 allocated
00015 string name
00016
00017 """
00018 __slots__ = ['handle','size','allocated','name']
00019 _slot_types = ['uint32','uint32','uint32','string']
00020
00021 def __init__(self, *args, **kwds):
00022 """
00023 Constructor. Any message fields that are implicitly/explicitly
00024 set to None will be assigned a default value. The recommend
00025 use is keyword arguments as this is more robust to future message
00026 changes. You cannot mix in-order arguments and keyword arguments.
00027
00028 The available fields are:
00029 handle,size,allocated,name
00030
00031 :param args: complete set of field values, in .msg order
00032 :param kwds: use keyword arguments corresponding to message field names
00033 to set specific fields.
00034 """
00035 if args or kwds:
00036 super(SharedMemBlock, self).__init__(*args, **kwds)
00037
00038 if self.handle is None:
00039 self.handle = 0
00040 if self.size is None:
00041 self.size = 0
00042 if self.allocated is None:
00043 self.allocated = 0
00044 if self.name is None:
00045 self.name = ''
00046 else:
00047 self.handle = 0
00048 self.size = 0
00049 self.allocated = 0
00050 self.name = ''
00051
00052 def _get_types(self):
00053 """
00054 internal API method
00055 """
00056 return self._slot_types
00057
00058 def serialize(self, buff):
00059 """
00060 serialize message into buffer
00061 :param buff: buffer, ``StringIO``
00062 """
00063 try:
00064 _x = self
00065 buff.write(_struct_3I.pack(_x.handle, _x.size, _x.allocated))
00066 _x = self.name
00067 length = len(_x)
00068 if python3 or type(_x) == unicode:
00069 _x = _x.encode('utf-8')
00070 length = len(_x)
00071 buff.write(struct.pack('<I%ss'%length, length, _x))
00072 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00073 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00074
00075 def deserialize(self, str):
00076 """
00077 unpack serialized message in str into this message instance
00078 :param str: byte array of serialized message, ``str``
00079 """
00080 try:
00081 end = 0
00082 _x = self
00083 start = end
00084 end += 12
00085 (_x.handle, _x.size, _x.allocated,) = _struct_3I.unpack(str[start:end])
00086 start = end
00087 end += 4
00088 (length,) = _struct_I.unpack(str[start:end])
00089 start = end
00090 end += length
00091 if python3:
00092 self.name = str[start:end].decode('utf-8')
00093 else:
00094 self.name = str[start:end]
00095 return self
00096 except struct.error as e:
00097 raise genpy.DeserializationError(e)
00098
00099
00100 def serialize_numpy(self, buff, numpy):
00101 """
00102 serialize message with numpy array types into buffer
00103 :param buff: buffer, ``StringIO``
00104 :param numpy: numpy python module
00105 """
00106 try:
00107 _x = self
00108 buff.write(_struct_3I.pack(_x.handle, _x.size, _x.allocated))
00109 _x = self.name
00110 length = len(_x)
00111 if python3 or type(_x) == unicode:
00112 _x = _x.encode('utf-8')
00113 length = len(_x)
00114 buff.write(struct.pack('<I%ss'%length, length, _x))
00115 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00116 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00117
00118 def deserialize_numpy(self, str, numpy):
00119 """
00120 unpack serialized message in str into this message instance using numpy for array types
00121 :param str: byte array of serialized message, ``str``
00122 :param numpy: numpy python module
00123 """
00124 try:
00125 end = 0
00126 _x = self
00127 start = end
00128 end += 12
00129 (_x.handle, _x.size, _x.allocated,) = _struct_3I.unpack(str[start:end])
00130 start = end
00131 end += 4
00132 (length,) = _struct_I.unpack(str[start:end])
00133 start = end
00134 end += length
00135 if python3:
00136 self.name = str[start:end].decode('utf-8')
00137 else:
00138 self.name = str[start:end]
00139 return self
00140 except struct.error as e:
00141 raise genpy.DeserializationError(e)
00142
00143 _struct_I = genpy.struct_I
00144 _struct_3I = struct.Struct("<3I")