import dds
import ddsutil
import struct

class Wrench___TypeSupport(dds.TypeSupport):

    _typename = 'geometry_msgs::msg::dds_::Wrench_'
    _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="Wrench_"><Member name="force_"><Type name="Vector3_"/></Member><Member name="torque_"><Type name="Vector3_"/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(Wrench___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(Wrench_()._get_packing_fmt()))

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

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

class Wrench_(ddsutil.TopicDataClass):

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

    @property
    def force_(self):
        '''
        a DDS geometry_msgs::msg::dds_::Vector3_ value
        @rtype: Vector3_
        '''
        return self._force__

    _force__checker = ddsutil._class_checker(Vector3_)
    @force_.setter
    def force_(self, value):
        self._force__checker(value)
        self._force__ = value

    @property
    def torque_(self):
        '''
        a DDS geometry_msgs::msg::dds_::Vector3_ value
        @rtype: Vector3_
        '''
        return self._torque__

    _torque__checker = ddsutil._class_checker(Vector3_)
    @torque_.setter
    def torque_(self, value):
        self._torque__checker(value)
        self._torque__ = value

    _member_attributes = ('force_', 'torque_')

    def __init__(self, **kwargs):
        ''' Create a Wrench_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.force_ = Vector3_()
        self.torque_ = Vector3_()
        # 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 Wrench_._packing_fmt is not None:
            return Wrench_._packing_fmt
        fmt = ''
        fmt += ddsutil._align(fmt, Vector3_._get_packing_fmt())
        fmt += ddsutil._align(fmt, Vector3_._get_packing_fmt())

        Wrench_._packing_fmt = ddsutil._pad_fmt(fmt)
        return Wrench_._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.force_ = Vector3_()._deserialize(data)
        self.torque_ = Vector3_()._deserialize(data)
        return self;

    def _get_packing_args(self):
        ''' Return an list of data suitable for struct.pack '''
        args = []
        args.extend(self.force_._get_packing_args())
        args.extend(self.torque_._get_packing_args())
        return args

