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


C++ Contact::getCarrier方法代码示例

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


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

示例1: botify

Bottle NameServer::botify(const Contact& address) {
    Bottle result;
    if (address.isValid()) {
        Bottle bname;
        bname.addString("name");
        bname.addString(address.getRegName().c_str());
        Bottle bip;
        bip.addString("ip");
        bip.addString(address.getHost().c_str());
        Bottle bnum;
        bnum.addString("port_number");
        bnum.addInt(address.getPort());
        Bottle bcarrier;
        bcarrier.addString("carrier");
        bcarrier.addString(address.getCarrier().c_str());

        result.addString("port");
        result.addList() = bname;
        result.addList() = bip;
        result.addList() = bnum;
        result.addList() = bcarrier;
    } else {
        Bottle bstate;
        bstate.addString("error");
        bstate.addInt(-2);
        bstate.addString("port not known");
        result.addString("port");
        result.addList() = bstate;
    }
    return result;
}
开发者ID:apaikan,项目名称:yarp,代码行数:31,代码来源:NameServer.cpp

示例2: checkSubscription

bool SubscriberOnSql::checkSubscription(const ConstString& src,const ConstString& dest,
                                        const ConstString& srcFull,
                                        const ConstString& destFull,
                                        const ConstString& mode) {
    if (getDelegate()) {
        NestedContact nc(src);
        if (nc.getNestedName().size()>0) {
            NestedContact nc(dest);
            if (nc.getNestedName().size()>0) {
                return false;
            }
        }
    }
    if (verbose) {
        printf("+++ Checking %s %s / %s %s\n",
               src.c_str(), dest.c_str(), srcFull.c_str(), destFull.c_str());
    }
    NameStore *store = getStore();
    if (store!=NULL) {
        Contact csrc = store->query(src);
        Contact cdest = store->query(dest);
        if (csrc.isValid()&&cdest.isValid()) {
            bool srcTopic = (csrc.getCarrier()=="topic");
            bool destTopic = (cdest.getCarrier()=="topic");
            if (!(srcTopic||destTopic)) {
                if (verbose) printf("++> check connection %s %s\n", 
                                    srcFull.c_str(), destFull.c_str());
                connect(srcFull,destFull);
            }
        }
        if (mode!="") {
            ConstString mode_name = mode;
            if (mode_name=="from") {
                if (!csrc.isValid()) {
                    removeSubscription(src,dest);
                }
            } else if (mode_name=="to") {
                if (!cdest.isValid()) {
                    removeSubscription(src,dest);
                }
            }
        }
    }
    return false;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:45,代码来源:SubscriberOnSql.cpp

示例3: needsLookup

static bool needsLookup(const Contact& contact)
{
    if (contact.getHost() != "") {
        return false;
    }
    if (contact.getCarrier() == "topic") {
        return false;
    }
    return true;
}
开发者ID:robotology,项目名称:yarp,代码行数:10,代码来源:Network.cpp

示例4: rosify

Contact RosNameSpace::rosify(const Contact& contact) {
    ConstString carrier = ((contact.getCarrier() == "rosrpc")  ? "rosrpc" : "http");
    ConstString hostname = contact.getHost();
    if (yarp::os::impl::NameConfig::isLocalName(hostname)) {
        char hn[HOST_NAME_MAX];
        yarp::os::gethostname(hn, sizeof(hn));
        hostname = hn;
    }
    return Contact(carrier, hostname, contact.getPort());
}
开发者ID:jgvictores,项目名称:yarp,代码行数:10,代码来源:RosNameSpace.cpp

示例5: textify

ConstString NameServer::textify(const Contact& address) {
    ConstString result = "";
    if (address.isValid()) {
        if (address.getPort()>=0) {
            result = "registration name ";
            result = result + address.getRegName() +
                " ip " + address.getHost() + " port " +
                NetType::toString(address.getPort()) + " type " +
                address.getCarrier() + "\n";
        } else {
            result = "registration name ";
            result = result + address.getRegName() +
                " ip " + "none" + " port " +
                "none" + " type " +
                address.getCarrier() + "\n";
        }
    }
    return result;
}
开发者ID:apaikan,项目名称:yarp,代码行数:19,代码来源:NameServer.cpp

示例6: appendEntry

 void appendEntry(yarp::os::Bottle& reply, const Contact& c) {
   Bottle& info = reply.addList();
   info.addString("registration");
   info.addString("name");
   info.addString(c.getName().c_str());
   info.addString("ip");
   info.addString(c.getHost().c_str());
   info.addString("port");
   info.addInt(c.getPort());
   info.addString("type");
   info.addString(c.getCarrier().c_str());
 }
开发者ID:jgvictores,项目名称:yarp,代码行数:12,代码来源:main.cpp

示例7: write

bool NetworkBase::write(const Contact& contact,
                       PortWriter& cmd,
                       PortReader& reply,
                       bool admin,
                       bool quiet,
                       double timeout) {
    ContactStyle style;
    style.admin = admin;
    style.quiet = quiet;
    style.timeout = timeout;
    style.carrier = contact.getCarrier();
    return write(contact,cmd,reply,style);
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:13,代码来源:Network.cpp

示例8: yarp_link

int yarp_link(const char *from, const char *to) {
    //TODO: will it ever be possible to hard link ports?
    //  If possible, it might be an alias for yarp_simlink, as with YARP 
    //  there isn't a sym/hard linking difference

    //Create the new Contact
    Contact src = Network::queryName(from);

    printf("source [%s] is %s\n", from, src.toString().c_str());

    Contact dest = Contact::byName(to).addSocket(src.getCarrier(),src.getHost(),src.getPort());

    printf("dest [%s] should be %s\n", to, src.toString().c_str());


    return 0;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:17,代码来源:link.cpp

示例9: yarpNameList

bool NetworkProfiler::yarpNameList(ports_name_set &ports, bool complete) {
    ports.clear();

    ContactStyle style;
    style.quiet = true;
    style.timeout = 3.0;
    string nameserver = NetworkBase::getNameServerName();
    Bottle msg, reply;
    msg.addString("bot");
    msg.addString("list");
    if(!NetworkBase::write(Contact(nameserver), msg, reply, style)) {
        yError() << "Cannot write to yarp name server";
        return false;
    }

    if(reply.size() == 0) {
        yError() << "Empty reply from yarp name server";
        return false;
    }

    for (int i=1; i<reply.size(); i++) {
        Bottle *entry = reply.get(i).asList();
        if(entry != nullptr) {
            bool shouldTake = false;
            ConstString portname = entry->check("name", Value("")).asString();
            if(complete)
            {
                shouldTake = portname != "";
            }
            else
            {
                shouldTake = portname != "" && portname != "fallback" && portname != nameserver;
            }
            if (shouldTake) {
                Contact c = Contact::fromConfig(*entry);
                if(c.getCarrier() != "mcast")
                    ports.push_back(*entry);
            }
        }
    }

    return true;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:43,代码来源:NetworkProfiler.cpp

示例10: cmdUnregister

bool NameServiceOnTriples::cmdUnregister(NameTripleState& act) {
    ConstString port = act.cmd.get(1).asString();
    //printf(" - unregister %s\n", port.c_str());
    announce(port,-1);
    lock();
    Contact contact = query(port,act,"",true);
    alloc->freePortResources(contact);
    act.reply.addString("old");
    Triple t;
    t.setNameValue("port",port.c_str());
    int result = act.mem.find(t, YARP_NULLPTR);
    TripleContext context;
    context.setRid(result);
    if (result!=-1) {
        t.setNameValue("owns","*");
        list<Triple> lst = act.mem.query(t,&context);
        unlock();
        for (list<Triple>::iterator it=lst.begin();it!=lst.end();it++) {
            act.cmd.clear();
            act.cmd.addString("unregister");
            act.cmd.addString(it->value.c_str());
            cmdUnregister(act);
        }
        lock();
        t.setNsNameValue("*","*","*");
        act.mem.remove_query(t,&context);

        t.setNameValue("port",port.c_str());
        act.mem.remove_query(t, YARP_NULLPTR);
        // now, query to report that there is nothing there

        if (contact.getCarrier()!="mcast") {
            Bottle& event = act.event.addList();
            event.addVocab(Vocab::encode("del"));
            event.addString(port);
        }
    }

    act.mem.reset();
    unlock();

    return cmdQuery(act);
}
开发者ID:apaikan,项目名称:yarp,代码行数:43,代码来源:NameServiceOnTriples.cpp

示例11: queryName

Contact RosNameSpace::queryName(const ConstString& name) {
    dbg_printf("ROSNameSpace queryName(%s)\n", name.c_str());
    NestedContact nc(name);
    ConstString full = name;
    ConstString node = nc.getNodeName();
    ConstString srv = nc.getNestedName();
    ConstString cat = nc.getCategory();
    bool is_service = false;

    Bottle cmd,reply;
    if (cat.find("-1")==ConstString::npos) {
        cmd.addString("lookupNode");
        cmd.addString("dummy_id");
        cmd.addString(toRosNodeName(node));
        NetworkBase::write(getNameServerContact(),
                           cmd, reply);
    }
    Contact contact;
    if (reply.get(0).asInt()!=1) {
        cmd.clear();
        reply.clear();
        cmd.addString("lookupService");
        cmd.addString("dummy_id");
        cmd.addString(toRosNodeName(node));
        NetworkBase::write(getNameServerContact(),
                           cmd, reply);
        is_service = true;
    }
    contact = Contact::fromString(reply.get(2).asString());
    // unfortunate differences in labeling carriers
    if (contact.getCarrier()=="rosrpc") {
        contact = contact.addCarrier(ConstString("rossrv+service.") + name);
    } else {
        contact = contact.addCarrier("xmlrpc");
    }
    contact = contact.addName(name);

    if (srv == "" || !is_service) return contact;

    return Contact();
}
开发者ID:apprisi,项目名称:yarp,代码行数:41,代码来源:RosNameSpace.cpp

示例12: yarp_rename

int yarp_rename(const char *from, const char *to) {
    //TODO: the current code just renames ports, eg:
    //  /read can become /rd, but /read/rd1 cannot become /rd/rd1
    //  every subport/subdirectory should have to be renamed

    YPath ypath(from);
    if (!ypath.isPort()) { //Check that the path exists? Is it right?
        return -ENOENT;
    }


    //Create the new Contact
    Contact src = Network::queryName(from);
    Network::unregisterContact(src);

    Contact dest(to, src.getCarrier(), src.getHost(), src.getPort());

    Network::registerContact(dest);

    return 0;
}
开发者ID:apaikan,项目名称:yarp,代码行数:21,代码来源:yarpfs.cpp

示例13: rosify

Contact RosNameSpace::rosify(const Contact& contact) {
    if (contact.getCarrier()=="rosrpc") return contact;
    return Contact::bySocket("http",contact.getHost().c_str(),
                             contact.getPort());
}
开发者ID:apprisi,项目名称:yarp,代码行数:5,代码来源:RosNameSpace.cpp

示例14: cmdQuery

bool NameServiceOnTriples::cmdQuery(NameTripleState& act, bool nested) {
    ConstString port = act.cmd.get(1).asString();

    ParseName parser;
    parser.apply(port.c_str());
    port = parser.getPortName();

    /*
    // port names may be prefixed - sort that out
    ConstString base = port;
    ConstString pat = "";
    if (base.find("/net=") == 0 || base.find("/NET=") == 0) {
        int patStart = 5;
        int patEnd = base.find('/',patStart);
        if (patEnd>=patStart) {
            pat = base.substr(patStart,patEnd-patStart);
            base = base.substr(patEnd);
        }
        port = base;
    }
    */

    if (act.reply.size()==0 && !act.bottleMode) {
        act.reply.addString("old");
    }
    Bottle& q=(act.bottleMode&&!act.nestedMode)?
        act.reply :
        act.reply.addList();
    Contact c = query(port, act, parser.getNetworkChoice(), nested);
    ConstString host = c.getHost();
    ConstString carrier = c.getCarrier();
    int sock = c.getPort();
    if (c.isValid()) {
        if (!act.bottleMode) {
            q.addString("registration");
            q.addString("name");
            q.addString(port);
            q.addString("ip");
            q.addString(host);
            q.addString("port");
            q.addInt(sock);
            q.addString("type");
            q.addString(carrier);
        } else {
            Bottle bname;
            bname.addString("name");
            bname.addString(port);
            Bottle bip;
            bip.addString("ip");
            bip.addString(host);
            Bottle bnum;
            bnum.addString("port_number");
            bnum.addInt(sock);
            Bottle bcarrier;
            bcarrier.addString("carrier");
            bcarrier.addString(carrier);
            q.addString("port");
            q.addList() = bname;
            q.addList() = bip;
            q.addList() = bnum;
            q.addList() = bcarrier;
        }
    } else {
        if (act.bottleMode) {
            Bottle bstate;
            bstate.addString("error");
            bstate.addInt(-2);
            bstate.addString("port not known");
            q.addString("port");
            q.addList() = bstate;
        }
    }
    return true;
}
开发者ID:apaikan,项目名称:yarp,代码行数:74,代码来源:NameServiceOnTriples.cpp

示例15: fromString

Contact Contact::fromString(const ConstString& txt) {
    ConstString str(txt);
    Contact c;
    ConstString::size_type start = 0;
    ConstString::size_type base = str.find("://");
    ConstString::size_type offset = 2;
    if (base==ConstString::npos) {
        base = str.find(":/");
        offset = 1;
    }
    if (base==ConstString::npos) {
        if (str.length()>0 && str[0] == '/') {
            base = 0;
            offset = 0;
        }
    }
    if (base!=ConstString::npos) {
        c = Contact::byCarrier(str.substr(0,base));
        start = base+offset;
        // check if we have a direct machine:NNN syntax
        ConstString::size_type colon = ConstString::npos;
        int mode = 0;
        int nums = 0;
        ConstString::size_type i;
        for (i=start+1; i<str.length(); i++) {
            char ch = str[i];
            if (ch==':') {
                if (mode == 0) {
                    colon = i;
                    mode = 1;
                    continue;
                } else {
                    mode = -1;
                    break;
                }
            }
            if (ch=='/') {
                break;
            }
            if (mode==1) {
                if (ch>='0'&&ch<='9') {
                    nums++;
                    continue;
                } else {
                    mode = -1;
                    break;
                }
            }
        }
        if (mode==1 && nums>=1) {
            // yes, machine:nnn
            ConstString machine = str.substr(start+1,colon-start-1);
            ConstString portnum = str.substr(colon+1, nums);
            c = c.addSocket(c.getCarrier()==""?"tcp":c.getCarrier().c_str(),
                            machine,
                            atoi(portnum.c_str()));
            start = i;
        }
    }
    ConstString rname = str.substr(start);
    if (rname!="/") {
        c = c.addName(rname.c_str());
    }
    return c;
}
开发者ID:BRKMYR,项目名称:yarp,代码行数:65,代码来源:Contact.cpp


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