本文整理汇总了C++中Contactable类的典型用法代码示例。如果您正苦于以下问题:C++ Contactable类的具体用法?C++ Contactable怎么用?C++ Contactable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contactable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear
void clear()
{
if (!mutex.try_lock()) {
return;
}
while (name_cache.begin() != name_cache.end()) {
Contactable *c = name_cache.begin()->first;
if (c) {
mutex.unlock();
c->interrupt();
c->close();
mutex.lock();
// Close will remove the Contactable from the map only the first
// time that a node is found (for example if "/[email protected]/node" and
// "/[email protected]" are registered, only the first time that "/node"
// is found it is removed automatically. The second time it must
// be removed manually.
if (!name_cache.empty() && name_cache.begin()->first == c) {
name_cache.erase(name_cache.begin());
}
}
}
mutex.unlock();
port.interrupt();
}
示例2: shouldInterpretRosMessages
bool XmlRpcCarrier::shouldInterpretRosMessages(ConnectionState& proto) {
// We need to set the interpretRos flag, which controls
// whether ROS-style admin messages are treated as
// admin messages or data messages in YARP.
// In the future, they should always be data messages.
// For now, they should be admin messages for all ports
// except ports tagged as corresponding to ros nodes.
bool nodelike = false;
Contactable *port = proto.getContactable();
Property opt;
if (port) {
Property *pport = port->acquireProperties(true);
if (pport) {
opt = *pport;
}
port->releaseProperties(pport);
}
if (opt.check("node_like")) {
nodelike = true;
}
Name n(proto.getRoute().getCarrierName() + "://test");
ConstString rospass = n.getCarrierModifier("ros");
interpretRos = !nodelike;
if (rospass=="1"||rospass=="on") {
interpretRos = true;
}
if (rospass=="0"||rospass=="off") {
interpretRos = false;
}
return interpretRos;
}
示例3: nc
void yarp::os::Nodes::Private::update(Contactable& contactable)
{
NestedContact nc(contactable.getName());
if (!nc.isNested()) {
return;
}
if (!active) {
return;
}
Node* node = getNode(contactable.getName(), true);
if (node) {
node->update(contactable);
}
}
示例4: update
void Nodes::update(Contactable& contactable) {
NestedContact nc(contactable.getName());
if (!nc.isNested()) return;
HELPER(this).mutex.unlock();
HELPER(this).update(contactable);
HELPER(this).mutex.lock();
}
示例5: getNode
void yarp::os::Nodes::Private::remove(Contactable& contactable)
{
if (!active) {
return;
}
Node* node = getNode(contactable.getName(), false);
if (node) {
node->remove(contactable);
}
}
示例6: waitForOutput
static bool waitForOutput(Contactable& c,double timeout) {
double start = Time::now();
while (Time::now()-start<timeout) {
if (c.getOutputCount()>0) {
return true;
}
Time::delay(0.1);
}
return false;
}
示例7:
void yarp::os::Node::Helper::remove(Contactable& contactable)
{
mutex.lock();
NodeItem item = name_cache[&contactable];
name_cache.erase(&contactable);
std::string nestedName = item.nc.getNestedName();
for (std::multimap<std::string, NodeItem>::iterator it = by_part_name.begin(); it != by_part_name.end(); ++it) {
if (it->first == nestedName && it->second.contactable->where().toString() == contactable.where().toString()) {
by_part_name.erase(it);
break;
}
}
std::string category = item.nc.getCategory();
for (std::multimap<std::string, NodeItem>::iterator it = by_category.begin(); it != by_category.end(); ++it) {
if (it->first == category && it->second.contactable->where().toString() == contactable.where().toString()) {
by_category.erase(it);
break;
}
}
mutex.unlock();
}
示例8: add
void NodeHelper::add(Contactable& contactable) {
NodeItem item;
item.nc.fromString(contactable.getName());
if (name=="") name = item.nc.getNodeName();
if (name!=item.nc.getNodeName()) {
fprintf(stderr,"Node name mismatch, expected [%s] but got [%s]\n",
name.c_str(), item.nc.getNodeName().c_str());
return;
}
prepare(name);
item.contactable = &contactable;
name_cache[&contactable] = item;
by_part_name[item.nc.getNestedName()] = item;
by_category.insert(std::pair<ConstString,NodeItem>(item.nc.getCategory(),item));
}
示例9: remove
void NodesHelper::remove(Contactable& contactable) {
if (!active) return;
Node *node = getNode(contactable.getName(),false);
if (node) node->remove(contactable);
}
示例10: update
void update() {
if (nc.getTypeName()=="") {
if (!contactable) return;
Type typ = contactable->getType();
if (typ.isValid()) {
nc.setTypeName(typ.getName());
}
}
}