本文整理汇总了C++中ndn::Name::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::get方法的具体用法?C++ Name::get怎么用?C++ Name::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ndn::Name
的用法示例。
在下文中一共展示了Name::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSegmentationNumbers
void NdnRtcNamespace::getSegmentationNumbers(const ndn::Name &prefix,
PacketNumber &packetNumber,
SegmentNumber &segmentNumber)
{
int p = -1;
packetNumber = -1;
segmentNumber = -1;
if (isDeltaFramesPrefix(prefix))
{
p = findComponent(prefix, NameComponentStreamFramesDelta);
}
else if (isKeyFramePrefix(prefix))
{
p = findComponent(prefix, NameComponentStreamFramesKey);
}
if (p > 0)
{
if (p+1 < prefix.size())
{
Name::Component packetNoComp = prefix.get(p+1);
packetNumber = NdnRtcUtils::frameNumber(packetNoComp);
}
if (p+3 < prefix.size())
{
Name::Component segmentNoComp = prefix.get(p+3);
segmentNumber = NdnRtcUtils::segmentNumber(segmentNoComp);
}
}
}
示例2: interestName
void
HelloProtocol::processInterest(const ndn::Name& name,
const ndn::Interest& interest)
{
/* interest name: /<neighbor>/NLSR/INFO/<router> */
const ndn::Name interestName = interest.getName();
_LOG_DEBUG("Interest Received for Name: " << interestName);
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
return;
}
ndn::Name neighbor;
neighbor.wireDecode(interestName.get(-1).blockFromValue());
_LOG_DEBUG("Neighbor: " << neighbor);
if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) {
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
data->setName(ndn::Name(interest.getName()).appendVersion());
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
INFO_COMPONENT.size());
m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
_LOG_DEBUG("Sending out data for name: " << interest.getName());
m_nlsr.getNlsrFace().put(*data);
Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor);
if (adjacent->getStatus() == 0) {
if(adjacent->getFaceId() != 0){
/* interest name: /<neighbor>/NLSR/INFO/<router> */
ndn::Name interestName(neighbor);
interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
expressInterest(interestName,
m_nlsr.getConfParameter().getInterestResendTime());
}
else {
registerPrefixes(adjacent->getName(), adjacent->getConnectingFaceUri(),
adjacent->getLinkCost(), ndn::time::milliseconds::max());
}
}
}
}
示例3: findComponent
int NdnRtcNamespace::findComponent(const ndn::Name &prefix,
const std::string &componentString)
{
int pos = -1;
int nComponents = prefix.size();
Name::Component searchComponent((const uint8_t*)componentString.c_str(),
componentString.size());
for (int i = nComponents; i--; i >= 0)
{
Name::Component c = prefix.get(i);
if (c == searchComponent)
{
pos = i;
break;
}
}
return pos;
}
示例4: getSegmentNumber
SegmentNumber NdnRtcNamespace::getSegmentNumber(const ndn::Name &prefix)
{
PacketNumber segmentNo = -1;
int p = -1;
if (isDeltaFramesPrefix(prefix))
{
p = findComponent(prefix, NameComponentStreamFramesDelta);
}
else if (isKeyFramePrefix(prefix))
{
p = findComponent(prefix, NameComponentStreamFramesKey);
}
if (p > 0 &&
p+3 < prefix.size())
{
Name::Component segmentNoComp = prefix.get(p+3);
segmentNo = NdnRtcUtils::segmentNumber(segmentNoComp);
}
return segmentNo;
}