import dds
import ddsutil
import struct

class Empty___TypeSupport(dds.TypeSupport):

    _typename = 'std_msgs::msg::dds_::Empty_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><Module name="std_msgs"><Module name="msg"><Module name="dds_"><Struct name="Empty_"><Member name="structure_needs_at_least_one_member_"><Octet/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(Empty___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(Empty_()._get_packing_fmt()))

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

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

class Empty_(ddsutil.TopicDataClass):

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

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

    _structure_needs_at_least_one_member__checker = ddsutil._octet_checker
    @structure_needs_at_least_one_member_.setter
    def structure_needs_at_least_one_member_(self, value):
        self._structure_needs_at_least_one_member__checker(value)
        self._structure_needs_at_least_one_member__ = value

    _member_attributes = ('structure_needs_at_least_one_member_')

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

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

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

