当前位置: 首页>>代码示例>>C++>>正文


C++ Name::get方法代码示例

本文整理汇总了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);
        }
    }
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:32,代码来源:ndnrtc-namespace.cpp

示例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());
      }
    }
  }
}
开发者ID:signorello,项目名称:NLSR,代码行数:40,代码来源:hello-protocol.cpp

示例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;
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:21,代码来源:ndnrtc-namespace.cpp

示例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;
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:24,代码来源:ndnrtc-namespace.cpp


注:本文中的ndn::Name::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。