import dds
import ddsutil
import geometry_msgs/msg/Transform_.geometry_msgs.msg.dds_
import geometry_msgs/msg/Twist_.geometry_msgs.msg.dds_
import geometry_msgs/msg/Wrench_.geometry_msgs.msg.dds_
import std_msgs/msg/Header_.std_msgs.msg.dds_
import struct

class MultiDOFJointState___TypeSupport(dds.TypeSupport):

    _typename = 'sensor_msgs::msg::dds_::MultiDOFJointState_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><Module name="geometry_msgs"><Module name="msg"><Module name="dds_"><Struct name="Vector3_"><Member name="x_"><Double/></Member><Member name="y_"><Double/></Member><Member name="z_"><Double/></Member></Struct><Struct name="Quaternion_"><Member name="x_"><Double/></Member><Member name="y_"><Double/></Member><Member name="z_"><Double/></Member><Member name="w_"><Double/></Member></Struct><Struct name="Wrench_"><Member name="force_"><Type name="Vector3_"/></Member><Member name="torque_"><Type name="Vector3_"/></Member></Struct><Struct name="Twist_"><Member name="linear_"><Type name="Vector3_"/></Member><Member name="angular_"><Type name="Vector3_"/></Member></Struct><Struct name="Transform_"><Member name="translation_"><Type name="Vector3_"/></Member><Member name="rotation_"><Type name="Quaternion_"/></Member></Struct></Module></Module></Module><Module name="builtin_interfaces"><Module name="msg"><Module name="dds_"><Struct name="Time_"><Member name="sec_"><Long/></Member><Member name="nanosec_"><ULong/></Member></Struct></Module></Module></Module><Module name="std_msgs"><Module name="msg"><Module name="dds_"><Struct name="Header_"><Member name="stamp_"><Type name="::builtin_interfaces::msg::dds_::Time_"/></Member><Member name="frame_id_"><String/></Member></Struct></Module></Module></Module><Module name="sensor_msgs"><Module name="msg"><Module name="dds_"><Struct name="MultiDOFJointState_"><Member name="header_"><Type name="::std_msgs::msg::dds_::Header_"/></Member><Member name="joint_names_"><Sequence><String/></Sequence></Member><Member name="transforms_"><Sequence><Type name="::geometry_msgs::msg::dds_::Transform_"/></Sequence></Member><Member name="twist_"><Sequence><Type name="::geometry_msgs::msg::dds_::Twist_"/></Sequence></Member><Member name="wrench_"><Sequence><Type name="::geometry_msgs::msg::dds_::Wrench_"/></Sequence></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(MultiDOFJointState___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(MultiDOFJointState_()._get_packing_fmt()))

    def _serialize(self, o):
        if not isinstance(o, MultiDOFJointState_):
            raise TypeError('Incorrect data type')
        result = o._serialize()
        return result

    def _deserialize(self, buf):
        result = MultiDOFJointState_()
        data = struct.unpack(result._get_packing_fmt(), buf)
        result._deserialize(list(data))
        return result

class MultiDOFJointState_(ddsutil.TopicDataClass):

    @staticmethod
    def get_type_support():
        ''' Return type support information required for dds.Topic constructor '''
        return MultiDOFJointState___TypeSupport()

    @property
    def header_(self):
        '''
        a DDS std_msgs::msg::dds_::Header_ value
        @rtype: std_msgs/msg/Header_.std_msgs.msg.dds_.Header_
        '''
        return self._header__

    _header__checker = ddsutil._class_checker(std_msgs/msg/Header_.std_msgs.msg.dds_.Header_)
    @header_.setter
    def header_(self, value):
        self._header__checker(value)
        self._header__ = value

    @property
    def joint_names_(self):
        '''
        a DDS sequence<string> value
        @rtype: list
        '''
        return self._joint_names__

    _joint_names__checker = ddsutil._seq_checker(0,ddsutil._str_checker)
    @joint_names_.setter
    def joint_names_(self, value):
        self._joint_names__checker(value)
        self._joint_names__ = value

    @property
    def transforms_(self):
        '''
        a DDS sequence<geometry_msgs::msg::dds_::Transform_> value
        @rtype: list
        '''
        return self._transforms__

    _transforms__checker = ddsutil._seq_checker(0,ddsutil._class_checker(geometry_msgs/msg/Transform_.geometry_msgs.msg.dds_.Transform_))
    @transforms_.setter
    def transforms_(self, value):
        self._transforms__checker(value)
        self._transforms__ = value

    @property
    def twist_(self):
        '''
        a DDS sequence<geometry_msgs::msg::dds_::Twist_> value
        @rtype: list
        '''
        return self._twist__

    _twist__checker = ddsutil._seq_checker(0,ddsutil._class_checker(geometry_msgs/msg/Twist_.geometry_msgs.msg.dds_.Twist_))
    @twist_.setter
    def twist_(self, value):
        self._twist__checker(value)
        self._twist__ = value

    @property
    def wrench_(self):
        '''
        a DDS sequence<geometry_msgs::msg::dds_::Wrench_> value
        @rtype: list
        '''
        return self._wrench__

    _wrench__checker = ddsutil._seq_checker(0,ddsutil._class_checker(geometry_msgs/msg/Wrench_.geometry_msgs.msg.dds_.Wrench_))
    @wrench_.setter
    def wrench_(self, value):
        self._wrench__checker(value)
        self._wrench__ = value

    _member_attributes = ('header_', 'joint_names_', 'transforms_', 'twist_', 'wrench_')

    def __init__(self, **kwargs):
        ''' Create a MultiDOFJointState_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()
        self.joint_names_ = []
        self.transforms_ = []
        self.twist_ = []
        self.wrench_ = []
        # set values for attributes passed in
        for key, value in kwargs.items():
            if key not in self._member_attributes:
                raise TypeError('Invalid argument name : %s' %(key))
            setattr(self, key, value)

    _packing_fmt = None

    @staticmethod
    def _get_packing_fmt():
        ''' Returns packing format of this class data '''
        if MultiDOFJointState_._packing_fmt is not None:
            return MultiDOFJointState_._packing_fmt
        fmt = ''
        fmt += ddsutil._align(fmt, std_msgs/msg/Header_.std_msgs.msg.dds_.Header_._get_packing_fmt())
        fmt += ddsutil._align(fmt, ddsutil._pad_fmt('iiP?'))
        fmt += ddsutil._align(fmt, ddsutil._pad_fmt('iiP?'))
        fmt += ddsutil._align(fmt, ddsutil._pad_fmt('iiP?'))
        fmt += ddsutil._align(fmt, ddsutil._pad_fmt('iiP?'))

        MultiDOFJointState_._packing_fmt = ddsutil._pad_fmt(fmt)
        return MultiDOFJointState_._packing_fmt

    def _serialize(self):
        ''' Serialize data for writing '''
        fmt = self._get_packing_fmt()
        args = self._get_packing_args()
        result = struct.pack(fmt, *args)
        return result

    def _deserialize(self, data):
        ''' Initialize values from data returned by struct.unpack()'''
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()._deserialize(data)
        self.joint_names_ = ddsutil._deserialize_seq(data, 'P', lambda seq_data: ddsutil._ptr_to_bytes(seq_data.pop(0)).decode('ISO-8859-1'))
        self.transforms_ = ddsutil._deserialize_seq(data, geometry_msgs/msg/Transform_.geometry_msgs.msg.dds_.Transform_._get_packing_fmt(), lambda seq_data: geometry_msgs/msg/Transform_.geometry_msgs.msg.dds_.Transform_()._deserialize(seq_data))
        self.twist_ = ddsutil._deserialize_seq(data, geometry_msgs/msg/Twist_.geometry_msgs.msg.dds_.Twist_._get_packing_fmt(), lambda seq_data: geometry_msgs/msg/Twist_.geometry_msgs.msg.dds_.Twist_()._deserialize(seq_data))
        self.wrench_ = ddsutil._deserialize_seq(data, geometry_msgs/msg/Wrench_.geometry_msgs.msg.dds_.Wrench_._get_packing_fmt(), lambda seq_data: geometry_msgs/msg/Wrench_.geometry_msgs.msg.dds_.Wrench_()._deserialize(seq_data))
        return self;

    def _get_packing_args(self):
        ''' Return an list of data suitable for struct.pack '''
        args = []
        args.extend(self.header_._get_packing_args())
        args.extend(ddsutil._serialize_seq(self.joint_names_, 'P', lambda seq_args, v: seq_args.append(ddsutil._bytes_to_ptr(v.encode('ISO-8859-1')))))
        args.extend(ddsutil._serialize_seq(self.transforms_, geometry_msgs/msg/Transform_.geometry_msgs.msg.dds_.Transform_._get_packing_fmt(), lambda seq_args, v: seq_args.extend(v._get_packing_args())))
        args.extend(ddsutil._serialize_seq(self.twist_, geometry_msgs/msg/Twist_.geometry_msgs.msg.dds_.Twist_._get_packing_fmt(), lambda seq_args, v: seq_args.extend(v._get_packing_args())))
        args.extend(ddsutil._serialize_seq(self.wrench_, geometry_msgs/msg/Wrench_.geometry_msgs.msg.dds_.Wrench_._get_packing_fmt(), lambda seq_args, v: seq_args.extend(v._get_packing_args())))
        return args

