本文整理汇总了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++;
}
}
示例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;
}
}