import dds
import ddsutil
import std_msgs/msg/Header_.std_msgs.msg.dds_
import struct

class InertiaStamped___TypeSupport(dds.TypeSupport):

    _typename = 'geometry_msgs::msg::dds_::InertiaStamped_'
    _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><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="geometry_msgs"><Module name="msg"><Module name="dds_"><Struct name="InertiaStamped_"><Member name="header_"><Type name="::std_msgs::msg::dds_::Header_"/></Member><Member name="inertia_"><Type name="Inertia_"/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(InertiaStamped___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(InertiaStamped_()._get_packing_fmt()))

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

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

class InertiaStamped_(ddsutil.TopicDataClass):

    @staticmethod
    def get_type_support():
        ''' Return type support information required for dds.Topic constructor '''
        return InertiaStamped___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 inertia_(self):
        '''
        a DDS geometry_msgs::msg::dds_::Inertia_ value
        @rtype: Inertia_
        '''
        return self._inertia__

    _inertia__checker = ddsutil._class_checker(Inertia_)
    @inertia_.setter
    def inertia_(self, value):
        self._inertia__checker(value)
        self._inertia__ = value

    _member_attributes = ('header_', 'inertia_')

    def __init__(self, **kwargs):
        ''' Create a InertiaStamped_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()
        self.inertia_ = Inertia_()
        # 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 InertiaStamped_._packing_fmt is not None:
            return InertiaStamped_._packing_fmt
        fmt = ''
        fmt += ddsutil._align(fmt, std_msgs/msg/Header_.std_msgs.msg.dds_.Header_._get_packing_fmt())
        fmt += ddsutil._align(fmt, Inertia_._get_packing_fmt())

        InertiaStamped_._packing_fmt = ddsutil._pad_fmt(fmt)
        return InertiaStamped_._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.inertia_ = Inertia_()._deserialize(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(self.inertia_._get_packing_args())
        return args

