本文整理汇总了Python中pyndn.util.change_counter.ChangeCounter.checkChanged方法的典型用法代码示例。如果您正苦于以下问题:Python ChangeCounter.checkChanged方法的具体用法?Python ChangeCounter.checkChanged怎么用?Python ChangeCounter.checkChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.util.change_counter.ChangeCounter
的用法示例。
在下文中一共展示了ChangeCounter.checkChanged方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Data
# 需要导入模块: from pyndn.util.change_counter import ChangeCounter [as 别名]
# 或者: from pyndn.util.change_counter.ChangeCounter import checkChanged [as 别名]
#.........这里部分代码省略.........
# The values have changed, so the default wire encoding is
# invalidated.
self._defaultWireEncoding = SignedBlob()
self._defaultWireEncodingFormat = None
self._getDefaultWireEncodingChangeCount = self.getChangeCount()
return self._defaultWireEncoding
def getDefaultWireEncodingFormat(self):
"""
Get the WireFormat which is used by getDefaultWireEncoding().
:return: The WireFormat, which is only meaningful if the
getDefaultWireEncoding() is not isNull().
:rtype: WireFormat
"""
return self._defaultWireEncodingFormat
def setName(self, name):
"""
Set name to a copy of the given Name.
:param Name name: The Name which is copied.
:return: This Data so that you can chain calls to update values.
:rtype: Data
"""
self._name.set(name if type(name) is Name else Name(name))
self._changeCount += 1
return self
def setMetaInfo(self, metaInfo):
"""
Set metaInfo to a copy of the given MetaInfo.
:param MetaInfo metaInfo: The MetaInfo which is copied.
:return: This Data so that you can chain calls to update values.
:rtype: Data
"""
self._metaInfo.set(MetaInfo() if metaInfo == None
else MetaInfo(metaInfo))
self._changeCount += 1
return self
def setSignature(self, signature):
"""
Set the signature to a copy of the given signature.
:param signature: The signature object which is cloned.
:type signature: a subclass of Signature such as Sha256WithRsaSignature
:return: This Data so that you can chain calls to update values.
:rtype: Data
"""
self._signature.set(Sha256WithRsaSignature() if signature == None
else signature.clone())
self._changeCount += 1
return self
def setContent(self, content):
"""
Set the content to the given value.
:param content: The array with the content bytes. If content is not a
Blob, then create a new Blob to copy the bytes (otherwise
take another pointer to the same Blob).
:type content: A Blob or an array type with int elements
"""
self._content = content if type(content) is Blob else Blob(content)
self._changeCount += 1
def getChangeCount(self):
"""
Get the change count, which is incremented each time this object
(or a child object) is changed.
:return: The change count.
:rtype: int
"""
# Make sure each of the checkChanged is called.
changed = self._name.checkChanged()
changed = self._metaInfo.checkChanged() or changed
changed = self._signature.checkChanged() or changed
if changed:
# A child object has changed, so update the change count.
self._changeCount += 1
return self._changeCount
def _setDefaultWireEncoding(
self, defaultWireEncoding, defaultWireEncodingFormat):
self._defaultWireEncoding = defaultWireEncoding
self._defaultWireEncodingFormat = defaultWireEncodingFormat
# Set _getDefaultWireEncodingChangeCount so that the next call to
# getDefaultWireEncoding() won't clear _defaultWireEncoding.
self._getDefaultWireEncodingChangeCount = self.getChangeCount()
# Create managed properties for read/write properties of the class for more pythonic syntax.
name = property(getName, setName)
metaInfo = property(getMetaInfo, setMetaInfo)
signature = property(getSignature, setSignature)
content = property(getContent, setContent)
示例2: Sha256WithRsaSignature
# 需要导入模块: from pyndn.util.change_counter import ChangeCounter [as 别名]
# 或者: from pyndn.util.change_counter.ChangeCounter import checkChanged [as 别名]
class Sha256WithRsaSignature(Signature):
"""
Create a new Sha256WithRsaSignature object, possibly copying values from
another object.
:param value: (optional) If value is a Sha256WithRsaSignature, copy its
values. If value is omitted, the keyLocator is the default with
unspecified values and the signature is unspecified.
:param value: Sha256WithRsaSignature
"""
def __init__(self, value = None):
if value == None:
self._keyLocator = ChangeCounter(KeyLocator())
self._signature = Blob()
elif type(value) is Sha256WithRsaSignature:
# Copy its values.
self._keyLocator = ChangeCounter(KeyLocator(value.getKeyLocator()))
self._signature = value._signature
else:
raise RuntimeError(
"Unrecognized type for Sha256WithRsaSignature constructor: " +
str(type(value)))
self._changeCount = 0
def clone(self):
"""
Create a new Sha256WithRsaSignature which is a copy of this object.
:return: A new object which is a copy of this object.
:rtype: Sha256WithRsaSignature
"""
return Sha256WithRsaSignature(self)
def getKeyLocator(self):
"""
Get the key locator.
:return: The key locator.
:rtype: KeyLocator
"""
return self._keyLocator.get()
def getSignature(self):
"""
Get the data packet's signature bytes.
:return: The signature bytes as a Blob, which maybe isNull().
:rtype: Blob
"""
return self._signature
def setKeyLocator(self, keyLocator):
"""
Set the key locator to a copy of the given keyLocator.
:param KeyLocator keyLocator: The KeyLocator to copy.
"""
self._keyLocator.set(KeyLocator(keyLocator))
self._changeCount += 1
def setSignature(self, signature):
"""
Set the signature bytes to the given value.
:param signature: The array with the signature bytes. If signature is
not a Blob, then create a new Blob to copy the bytes (otherwise
take another pointer to the same Blob).
:type signature: A Blob or an array type with int elements
"""
self._signature = (signature if type(signature) is Blob
else Blob(signature))
self._changeCount += 1
def clear(self):
self._keyLocator.get().clear()
self._signature = Blob()
self._changeCount += 1
def getChangeCount(self):
"""
Get the change count, which is incremented each time this object
(or a child object) is changed.
:return: The change count.
:rtype: int
"""
# Make sure each of the checkChanged is called.
changed = self._keyLocator.checkChanged()
if changed:
# A child object has changed, so update the change count.
self._changeCount += 1
return self._changeCount
# Create managed properties for read/write properties of the class for more pythonic syntax.
keyLocator = property(getKeyLocator, setKeyLocator)
signature = property(getSignature, setSignature)
示例3: KeyLocator
# 需要导入模块: from pyndn.util.change_counter import ChangeCounter [as 别名]
# 或者: from pyndn.util.change_counter.ChangeCounter import checkChanged [as 别名]
#.........这里部分代码省略.........
self._type = value._type
self._keyName = ChangeCounter(Name(value.getKeyName()))
self._keyData = value._keyData
else:
raise RuntimeError(
"Unrecognized type for KeyLocator constructor: " +
repr(type(value)))
self._changeCount = 0
def getType(self):
"""
Get the key locator type. If KeyLocatorType.KEYNAME, you may also
getKeyName(). If KeyLocatorType.KEY_LOCATOR_DIGEST, you may also
getKeyData() to get the digest.
:return: The key locator type, or None if not specified.
:rtype: an int from KeyLocatorType
"""
return self._type
def getKeyName(self):
"""
Get the key name. This is meaningful if getType() is
KeyLocatorType.KEYNAME.
:return: The key name. If not specified, the Name is empty.
:rtype: Name
"""
return self._keyName.get()
def getKeyData(self):
"""
Get the key data. This is the digest bytes if getType() is
KeyLocatorType.KEY_LOCATOR_DIGEST.
:return: The key data as a Blob, which isNull() if unspecified.
:rtype: Blob
"""
return self._keyData
def setType(self, type):
"""
Set the key locator type. If KeyLocatorType.KEYNAME, you must also
setKeyName(). If KeyLocatorType.KEY_LOCATOR_DIGEST, you must also
setKeyData() to the digest.
:param type: The key locator type. If None, the type is unspecified.
:type type: an int from KeyLocatorType
"""
self._type = None if type == None or type < 0 else type
self._changeCount += 1
def setKeyName(self, keyName):
"""
Set key name to a copy of the given Name. This is the name if
getType() is KeyLocatorType.KEYNAME.
:param Name keyName: The key name which is copied.
"""
self._keyName.set(keyName if type(keyName) is Name else Name(keyName))
self._changeCount += 1
def setKeyData(self, keyData):
"""
Set the key data to the given value. This is the digest bytes if
getType() is KeyLocatorType.KEY_LOCATOR_DIGEST.
:param keyData: The array with the key data bytes. If keyData is not a
Blob, then create a new Blob to copy the bytes (otherwise
take another pointer to the same Blob).
:type keyData: A Blob or an array type with int elements
"""
self._keyData = keyData if type(keyData) is Blob else Blob(keyData)
self._changeCount += 1
def clear(self):
"""
Clear the fields and set the type to None.
"""
self._type = None
self._keyName.get().clear()
self._keyData = Blob()
self._changeCount += 1
def getChangeCount(self):
"""
Get the change count, which is incremented each time this object
(or a child object) is changed.
:return: The change count.
:rtype: int
"""
# Make sure each of the checkChanged is called.
changed = self._keyName.checkChanged()
if changed:
# A child object has changed, so update the change count.
self._changeCount += 1
return self._changeCount
示例4: Interest
# 需要导入模块: from pyndn.util.change_counter import ChangeCounter [as 别名]
# 或者: from pyndn.util.change_counter.ChangeCounter import checkChanged [as 别名]
#.........这里部分代码省略.........
def matchesName(self, name):
"""
Check if this interest's name matches the given name (using Name.match)
and the given name also conforms to the interest selectors.
:param Name name: The name to check.
:return: True if the name and interest selectors match, False otherwise.
:rtype: bool
"""
if not self.getName().match(name):
return False
if (
self._minSuffixComponents != None
and
# Add 1 for the implicit digest.
not (name.size() + 1 - self.getName().size() >= self._minSuffixComponents)
):
return False
if (
self._maxSuffixComponents != None
and
# Add 1 for the implicit digest.
not (name.size() + 1 - self.getName().size() <= self._maxSuffixComponents)
):
return False
if (
self.getExclude().size() > 0
and name.size() > self.getName().size()
and self.getExclude().matches(name[self.getName().size()])
):
return False
return True
def getDefaultWireEncoding(self):
"""
Return the default wire encoding, which was encoded with
getDefaultWireEncodingFormat().
:return: The default wire encoding, whose isNull() may be true if there
is no default wire encoding.
:rtype: SignedBlob
"""
if self._getDefaultWireEncodingChangeCount != self.getChangeCount():
# The values have changed, so the default wire encoding is
# invalidated.
self._defaultWireEncoding = SignedBlob()
self._defaultWireEncodingFormat = None
self._getDefaultWireEncodingChangeCount = self.getChangeCount()
return self._defaultWireEncoding
def getDefaultWireEncodingFormat(self):
"""
Get the WireFormat which is used by getDefaultWireEncoding().
:return: The WireFormat, which is only meaningful if the
getDefaultWireEncoding() is not isNull().
:rtype: WireFormat
"""
return self._defaultWireEncodingFormat
def getChangeCount(self):
"""
Get the change count, which is incremented each time this object
(or a child object) is changed.
:return: The change count.
:rtype: int
"""
# Make sure each of the checkChanged is called.
changed = self._name.checkChanged()
changed = self._keyLocator.checkChanged() or changed
changed = self._exclude.checkChanged() or changed
if changed:
# A child object has changed, so update the change count.
self._changeCount += 1
return self._changeCount
def _setDefaultWireEncoding(self, defaultWireEncoding, defaultWireEncodingFormat):
self._defaultWireEncoding = defaultWireEncoding
self._defaultWireEncodingFormat = defaultWireEncodingFormat
# Set _getDefaultWireEncodingChangeCount so that the next call to
# getDefaultWireEncoding() won't clear _defaultWireEncoding.
self._getDefaultWireEncodingChangeCount = self.getChangeCount()
# Create managed properties for read/write properties of the class for more pythonic syntax.
name = property(getName, setName)
minSuffixComponents = property(getMinSuffixComponents, setMinSuffixComponents)
maxSuffixComponents = property(getMaxSuffixComponents, setMaxSuffixComponents)
keyLocator = property(getKeyLocator, setKeyLocator)
exclude = property(getExclude, setExclude)
childSelector = property(getChildSelector, setChildSelector)
mustBeFresh = property(getMustBeFresh, setMustBeFresh)
nonce = property(getNonce, setNonce)
scope = property(getScope, setScope)
interestLifetimeMilliseconds = property(getInterestLifetimeMilliseconds, setInterestLifetimeMilliseconds)
示例5: KeyLocator
# 需要导入模块: from pyndn.util.change_counter import ChangeCounter [as 别名]
# 或者: from pyndn.util.change_counter.ChangeCounter import checkChanged [as 别名]
#.........这里部分代码省略.........
"""
self._type = None if type == None or type < 0 else type
self._changeCount += 1
def setKeyName(self, keyName):
"""
Set key name to a copy of the given Name. This is the name if
getType() is KeyLocatorType.KEYNAME.
:param Name keyName: The key name which is copied.
"""
self._keyName.set(keyName if type(keyName) is Name else Name(keyName))
self._changeCount += 1
def setKeyData(self, keyData):
"""
Set the key data to the given value. This is the digest bytes if
getType() is KeyLocatorType.KEY_LOCATOR_DIGEST.
:param keyData: The array with the key data bytes. If keyData is not a
Blob, then create a new Blob to copy the bytes (otherwise
take another pointer to the same Blob).
:type keyData: A Blob or an array type with int elements
"""
self._keyData = keyData if type(keyData) is Blob else Blob(keyData)
self._changeCount += 1
def clear(self):
"""
Clear the fields and set the type to None.
"""
self._type = None
self._keyName.get().clear()
self._keyData = Blob()
self._changeCount += 1
@staticmethod
def canGetFromSignature(signature):
"""
If the signature is a type that has a KeyLocator (so that
getFromSignature will succeed), return true.
Note: This is a static method of KeyLocator instead of a method of
Signature so that the Signature base class does not need to be overloaded
with all the different kinds of information that various signature
algorithms may use.
:param Signature signature: An object of a subclass of Signature.
:return: True if the signature is a type that has a KeyLocator,
otherwise False.
:rtype: bool
"""
return type(signature) is Sha256WithRsaSignature
@staticmethod
def getFromSignature(signature):
"""
If the signature is a type that has a KeyLocator, then return it. Otherwise
throw an error.
:param Signature signature: An object of a subclass of Signature.
:return: The signature's KeyLocator. It is an error if signature doesn't
have a KeyLocator.
:rtype: KeyLocator
"""
if type(signature) is Sha256WithRsaSignature:
return signature.getKeyLocator()
else:
raise RuntimeError(
"KeyLocator.getFromSignature: Signature type does not have a KeyLocator")
def getChangeCount(self):
"""
Get the change count, which is incremented each time this object
(or a child object) is changed.
:return: The change count.
:rtype: int
"""
# Make sure each of the checkChanged is called.
changed = self._keyName.checkChanged()
if changed:
# A child object has changed, so update the change count.
self._changeCount += 1
return self._changeCount
# Create managed properties for read/write properties of the class for more pythonic syntax.
type = property(getType, setType)
keyName = property(getKeyName, setKeyName)
keyData = property(getKeyData, setKeyData)
# Support property-based equivalence check
# TODO: Desired syntax?
def equals(self, other):
if self is None and other is None: return True
if other is None: return False
if self._type != other._type: return False
if self._keyName.get() != None and not self._keyName.get().equals(other._keyName.get()): return False
if self._keyData != None and not self._keyData.equals(other._keyData): return False
return True