本文整理汇总了C++中SpaceList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ SpaceList::push_back方法的具体用法?C++ SpaceList::push_back怎么用?C++ SpaceList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpaceList
的用法示例。
在下文中一共展示了SpaceList::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activate
bool activate(bool force = false) {
if (force) {
// wipe if forced
clear();
}
// return if namespaces already present
if (spaces.size()!=0) return true;
// read namespace list from config file
NameConfig conf;
if (!conf.fromFile()) {
double now = Time::now();
static double last_shown = now-10;
if (now-last_shown>3) {
last_shown = now;
fprintf(stderr,"warning: YARP name server(s) not configured, ports will be anonymous\n");
fprintf(stderr,"warning: check your namespace and settings with 'yarp detect'\n");
}
return false;
}
Bottle ns = conf.getNamespaces();
// loop through namespaces
for (int i=0; i<ns.size(); i++) {
ConstString n = ns.get(i).asString();
NameConfig conf2;
// read configuration of individual namespace
if (!conf2.fromFile(n.c_str())) {
fprintf(stderr, "Could not find namespace %s\n",
n.c_str());
continue;
}
String mode = conf2.getMode();
Contact address = conf2.getAddress().addName(n);
if (mode=="yarp"||mode=="//") {
// add a yarp namespace
NameSpace *ns = new YarpNameSpace(address);
spaces.push_back(ns);
} else if (mode=="ros") {
// add a ros namespace
NameSpace *ns = new RosNameSpace(address);
spaces.push_back(ns);
} else if (mode=="local") {
NameSpace *ns = new YarpDummyNameSpace;
spaces.push_back(ns);
} else {
// shrug
YARP_SPRINTF1(Logger::get(),error,
"cannot deal with namespace of type %s",
mode.c_str());
return false;
}
}
// cache flags
scan();
return true;
}
示例2: setLocalMode
bool setLocalMode(bool flag) {
clear();
if (flag) {
NameSpace *ns = new YarpDummyNameSpace;
spaces.push_back(ns);
}
scan();
return true;
}
示例3: activate
bool activate(bool force = false) {
if (force) {
clear();
}
if (spaces.size()!=0) return true;
NameConfig conf;
if (!conf.fromFile()) {
return false;
}
Bottle ns = conf.getNamespaces();
for (int i=0; i<ns.size(); i++) {
ConstString n = ns.get(i).asString();
//printf("NAMESPACE %s\n", n.c_str());
NameConfig conf2;
if (!conf2.fromFile(n.c_str())) {
fprintf(stderr, "Could not find namespace %s\n",
n.c_str());
continue;
}
String mode = conf2.getMode();
Contact address = conf2.getAddress().toContact().addName(n);
//printf("ADDRESS %s\n", address.toString().c_str());
if (mode=="yarp"||mode=="//") {
NameSpace *ns = new YarpNameSpace(address);
spaces.push_back(ns);
} else if (mode=="ros") {
NameSpace *ns = new RosNameSpace(address);
spaces.push_back(ns);
} else {
YARP_SPRINTF1(Logger::get(),error,
"cannot deal with namespace of type %s",
mode.c_str());
return false;
}
}
scan();
return true;
}