bulkio_data_helpers.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def getPort(self):
        """
        Returns a Port object of the same type as the one specified as the
        porttype argument during the object instantiation.  It uses the
        classobj from the new module to generate a class on runtime.

        The classobj generates a class using the following arguments:

            name:        The name of the class to generate
            bases:       A tuple containing all the base classes to use
            dct:         A dictionary containing all the attributes such as
                         functions, and class variables

        It is important to notice that the porttype is a BULKIO__POA type and
        not a BULKIO type.  The reason is because it is used to generate a
        Port class that will be returned when the getPort() is invoked.  The
        returned class is the one acting as a server and therefore must be a
        Portable Object Adapter rather and a simple BULKIO object.

        """
        # The classobj generates a class using the following arguments:
        #
        #    name:        The name of the class to generate
        #    bases:       A tuple containing all the base classes to use
        #    dct:         A dictionary containing all the attributes such as
        #                 functions, and class variables
        if self.port_type == BULKIO__POA.dataXML:
            pushPacket = self.pushPacketXML
        else:
            pushPacket = self.pushPacket
        PortClass = classobj('PortClass',
                             (self.port_type,),
                             {'pushPacket':pushPacket,
                              'pushSRI':self.pushSRI})

        # Create a port using the generate Metaclass and return an instance
        port = PortClass()
        return port._this()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号