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


C++ NodeSet::networksUsed方法代码示例

本文整理汇总了C++中NodeSet::networksUsed方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet::networksUsed方法的具体用法?C++ NodeSet::networksUsed怎么用?C++ NodeSet::networksUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeSet的用法示例。


在下文中一共展示了NodeSet::networksUsed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeNetworksSection

void writeNetworksSection(std::ostream& out, NodeSet& ns)
{
    out << "# Networks" << std::endl;
    NetworkSet& nets = ns.networksUsed();
    NetworkSet::iterator it = nets.begin();
    while (it != nets.end())
    {
        Network* n = *it;
        out << "SUBNET " << n->address;
        out << " { ";
        std::set<Node*>::iterator nit = n->nodes.begin();
        double lat = 0.0;
        double lon = 0.0;
        double alt = 0.0;
        while (nit != n->nodes.end())
        {
            out << (*nit)->NodeId << " ";
            lat += (*nit)->entity->worldLocation.lat;
            lon += (*nit)->entity->worldLocation.lon;
            alt += (*nit)->entity->worldLocation.alt;
            nit++;
        }
        lat = lat / (1.0*n->nodes.size());
        lon = lon / (1.0*n->nodes.size());
        alt = alt / (1.0*n->nodes.size());
        out << "} " << lat << " " << lon << " " << alt << std::endl;
        std::stringstream mask;
        ChannelSet::iterator cit = ns.channelsUsed().begin();
        while (cit != ns.channelsUsed().end())
        {
            if (*cit == n->channel)
            {
                mask << "1";
            }
            else
            {
                mask << "0";
            }
            cit++;
        }
        out << "[ " << n->address << "] PHY-LISTENABLE-CHANNEL-MASK "
            << mask.str() << std::endl;
        out << "[ " << n->address << "] PHY-LISTENING-CHANNEL-MASK "
            << mask.str() << std::endl;
        out << std::endl;
        it++;
    }
}
开发者ID:LXiong,项目名称:ccn,代码行数:48,代码来源:configFiles.cpp

示例2: writePhysicalSection

void writePhysicalSection(std::ostream& out, Config& config, NodeSet& ns)
{
    out << "# Physical" << std::endl;
    NetworkSet& nets = ns.networksUsed();

    std::string defaultModel =
                    config.getParameter("VRLINK-DEFAULT-ROUTER-MODEL").value;

    std::set<std::string> models;
    NetworkSet::iterator nit = nets.begin();
    while (nit != nets.end())
    {
        if ((*nit)->models.size() == 0)
        {
            models.insert(defaultModel);
        }
        else
        {
            models.insert((*nit)->models.begin(), (*nit)->models.end());
        }
        nit++;
    }
    if (models.size() == 1)
    {
        ParameterMap* parameters = config.getModelParameterList(*models.begin());
        if (parameters)
        {
            writeParameters(out, "", parameters);
        }
    }
    else if (models.size() > 1)
    {
        nit = nets.begin();
        while (nit != nets.end())
        {
            Network* n = *nit;
            ParameterMap* common = n->getCommonParameters();
            std::stringstream subnet;
            subnet << "[" << n->address << "]";
            writeParameters(out, subnet.str(), common);

            std::set<std::string>::iterator mit = n->models.begin();
            while (mit != n->models.end())
            {
                ParameterMap* parameters = config.getModelParameterList(*mit);
                ParameterMap* specfic = *parameters - *common;
                std::string group = n->getGroup(*mit);
                if (parameters && !group.empty())
                {
                    writeParameters(out, group, specfic);
                }
                delete specfic;
                mit++;
            }
            nit++;
        }
    }

    std::set<std::string>::iterator it = ns.modelsUsed().begin();
    if (it != ns.modelsUsed().end())
    {
        out << config.getParameter("ROUTER-MODEL-CONFIG-FILE") << std::endl;
    }
}
开发者ID:LXiong,项目名称:ccn,代码行数:64,代码来源:configFiles.cpp


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