本文整理汇总了Python中pyndn.encoding.wire_format.WireFormat.setDefaultWireFormat方法的典型用法代码示例。如果您正苦于以下问题:Python WireFormat.setDefaultWireFormat方法的具体用法?Python WireFormat.setDefaultWireFormat怎么用?Python WireFormat.setDefaultWireFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.encoding.wire_format.WireFormat
的用法示例。
在下文中一共展示了WireFormat.setDefaultWireFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TlvWireFormat
# 需要导入模块: from pyndn.encoding.wire_format import WireFormat [as 别名]
# 或者: from pyndn.encoding.wire_format.WireFormat import setDefaultWireFormat [as 别名]
from pyndn.encoding.tlv_0_1_1_wire_format import Tlv0_1_1WireFormat
"""
This module defines the TlvWireFormat class which extends WireFormat to override
its methods to implement encoding and decoding using the preferred
implementation of NDN-TLV.
"""
class TlvWireFormat(Tlv0_1_1WireFormat):
_instance = None
@classmethod
def get(self):
"""
Get a singleton instance of a TlvWireFormat. Assuming that the default
wire format was set with
WireFormat.setDefaultWireFormat(TlvWireFormat.get()), you can check if
this is the default wire encoding with
if WireFormat.getDefaultWireFormat() == TlvWireFormat.get().
:return: The singleton instance.
:rtype: TlvWireFormat
"""
if self._instance == None:
self._instance = TlvWireFormat()
return self._instance
# On loading this module, make this the default wire format.
# This module will be loaded because __init__.py loads it.
WireFormat.setDefaultWireFormat(TlvWireFormat.get())