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

class FluidPressure___TypeSupport(dds.TypeSupport):

    _typename = 'sensor_msgs::msg::dds_::FluidPressure_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><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="sensor_msgs"><Module name="msg"><Module name="dds_"><Struct name="FluidPressure_"><Member name="header_"><Type name="::std_msgs::msg::dds_::Header_"/></Member><Member name="fluid_pressure_"><Double/></Member><Member name="variance_"><Double/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(FluidPressure___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(FluidPressure_()._get_packing_fmt()))

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

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

class FluidPressure_(ddsutil.TopicDataClass):

    @staticmethod
    def get_type_support():
        ''' Return type support information required for dds.Topic constructor '''
        return FluidPressure___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 fluid_pressure_(self):
        '''
        a DDS double value
        @rtype: float
        '''
        return self._fluid_pressure__

    _fluid_pressure__checker = ddsutil._float_checker
    @fluid_pressure_.setter
    def fluid_pressure_(self, value):
        self._fluid_pressure__checker(value)
        self._fluid_pressure__ = value

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

    _variance__checker = ddsutil._float_checker
    @variance_.setter
    def variance_(self, value):
        self._variance__checker(value)
        self._variance__ = value

    _member_attributes = ('header_', 'fluid_pressure_', 'variance_')

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

        FluidPressure_._packing_fmt = ddsutil._pad_fmt(fmt)
        return FluidPressure_._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.fluid_pressure_ = data.pop(0)
        self.variance_ = data.pop(0)
        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.append(self.fluid_pressure_)
        args.append(self.variance_)
        return args

