import dds
import ddsutil
import struct

class NavSatStatus___TypeSupport(dds.TypeSupport):

    _typename = 'sensor_msgs::msg::dds_::NavSatStatus_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><Module name="sensor_msgs"><Module name="msg"><Module name="dds_"><Struct name="NavSatStatus_"><Member name="status_"><Octet/></Member><Member name="service_"><UShort/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(NavSatStatus___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(NavSatStatus_()._get_packing_fmt()))

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

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

class NavSatStatus_(ddsutil.TopicDataClass):

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

    @property
    def status_(self):
        '''
        a DDS octet value
        @rtype: int
        '''
        return self._status__

    _status__checker = ddsutil._octet_checker
    @status_.setter
    def status_(self, value):
        self._status__checker(value)
        self._status__ = value

    @property
    def service_(self):
        '''
        a DDS unsigned short value
        @rtype: int
        '''
        return self._service__

    _service__checker = ddsutil._ushort_checker
    @service_.setter
    def service_(self, value):
        self._service__checker(value)
        self._service__ = value

    _member_attributes = ('status_', 'service_')

    def __init__(self, **kwargs):
        ''' Create a NavSatStatus_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.status_ = 0
        self.service_ = 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 NavSatStatus_._packing_fmt is not None:
            return NavSatStatus_._packing_fmt
        fmt = ''
        fmt += 'B'
        fmt += 'H'

        NavSatStatus_._packing_fmt = ddsutil._pad_fmt(fmt)
        return NavSatStatus_._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.status_ = data.pop(0)
        self.service_ = data.pop(0)
        return self;

    def _get_packing_args(self):
        ''' Return an list of data suitable for struct.pack '''
        args = []
        args.append(self.status_)
        args.append(self.service_)
        return args

