import dds
import ddsutil
import struct

class Inertia___TypeSupport(dds.TypeSupport):

    _typename = 'geometry_msgs::msg::dds_::Inertia_'
    _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="Inertia_"><Member name="m_"><Double/></Member><Member name="com_"><Type name="Vector3_"/></Member><Member name="ixx_"><Double/></Member><Member name="ixy_"><Double/></Member><Member name="ixz_"><Double/></Member><Member name="iyy_"><Double/></Member><Member name="iyz_"><Double/></Member><Member name="izz_"><Double/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(Inertia___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(Inertia_()._get_packing_fmt()))

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

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

class Inertia_(ddsutil.TopicDataClass):

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

    @property
    def m_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._m__

    _m__checker = ddsutil._float_checker
    @m_.setter
    def m_(self, value):
        self._m__checker(value)
        self._m__ = value

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

    _com__checker = ddsutil._class_checker(Vector3_)
    @com_.setter
    def com_(self, value):
        self._com__checker(value)
        self._com__ = value

    @property
    def ixx_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._ixx__

    _ixx__checker = ddsutil._float_checker
    @ixx_.setter
    def ixx_(self, value):
        self._ixx__checker(value)
        self._ixx__ = value

    @property
    def ixy_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._ixy__

    _ixy__checker = ddsutil._float_checker
    @ixy_.setter
    def ixy_(self, value):
        self._ixy__checker(value)
        self._ixy__ = value

    @property
    def ixz_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._ixz__

    _ixz__checker = ddsutil._float_checker
    @ixz_.setter
    def ixz_(self, value):
        self._ixz__checker(value)
        self._ixz__ = value

    @property
    def iyy_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._iyy__

    _iyy__checker = ddsutil._float_checker
    @iyy_.setter
    def iyy_(self, value):
        self._iyy__checker(value)
        self._iyy__ = value

    @property
    def iyz_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._iyz__

    _iyz__checker = ddsutil._float_checker
    @iyz_.setter
    def iyz_(self, value):
        self._iyz__checker(value)
        self._iyz__ = value

    @property
    def izz_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._izz__

    _izz__checker = ddsutil._float_checker
    @izz_.setter
    def izz_(self, value):
        self._izz__checker(value)
        self._izz__ = value

    _member_attributes = ('m_', 'com_', 'ixx_', 'ixy_', 'ixz_', 'iyy_', 'iyz_', 'izz_')

    def __init__(self, **kwargs):
        ''' Create a Inertia_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.m_ = 0.0
        self.com_ = Vector3_()
        self.ixx_ = 0.0
        self.ixy_ = 0.0
        self.ixz_ = 0.0
        self.iyy_ = 0.0
        self.iyz_ = 0.0
        self.izz_ = 0.0
        # 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 Inertia_._packing_fmt is not None:
            return Inertia_._packing_fmt
        fmt = ''
        fmt += 'd'
        fmt += ddsutil._align(fmt, Vector3_._get_packing_fmt())
        fmt += 'd'
        fmt += 'd'
        fmt += 'd'
        fmt += 'd'
        fmt += 'd'
        fmt += 'd'

        Inertia_._packing_fmt = ddsutil._pad_fmt(fmt)
        return Inertia_._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.m_ = data.pop(0)
        self.com_ = Vector3_()._deserialize(data)
        self.ixx_ = data.pop(0)
        self.ixy_ = data.pop(0)
        self.ixz_ = data.pop(0)
        self.iyy_ = data.pop(0)
        self.iyz_ = data.pop(0)
        self.izz_ = data.pop(0)
        return self;

    def _get_packing_args(self):
        ''' Return an list of data suitable for struct.pack '''
        args = []
        args.append(self.m_)
        args.extend(self.com_._get_packing_args())
        args.append(self.ixx_)
        args.append(self.ixy_)
        args.append(self.ixz_)
        args.append(self.iyy_)
        args.append(self.iyz_)
        args.append(self.izz_)
        return args

