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


C++ ConnectionState::getRoute方法代码示例

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


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

示例1: expectSenderSpecifier

 bool MpiCarrier::expectSenderSpecifier(ConnectionState& proto) {
    // interpret everything that sendHeader wrote
    name = proto.getRoute().getToName();

    #ifdef MPI_DEBUG
    printf("[MpiCarrier @ %s] Waiting for header\n", route.c_str());
    #endif

    other = proto.is().readLine();
    proto.setRoute(proto.getRoute().addFromName(other));
    // Receiver
    route = name + "<-" + other;

    createStream(false);
    if (!MpiControl) return false;
    if (! MpiControl->isRunning())
        return false;

    ConstString other_id = proto.is().readLine();
    bool notLocal = comm->notLocal(other_id);

    port = proto.is().readLine();

    #ifdef MPI_DEBUG
    printf("[MpiCarrier @ %s] Header received\n", route.c_str());
    #endif

    return notLocal && proto.is().isOk();
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:29,代码来源:MpiCarrier.cpp

示例2:

bool yarp::os::impl::LocalCarrier::expectExtraHeader(ConnectionState& proto) {
    portName = proto.getRoute().getToName();
    // switch over to some local structure to communicate
    peerMutex.wait();
    peer = manager.getSender(this);
    //printf("receiver %ld (%s) sees sender %ld (%s)\n",
    //       (long int) this, portName.c_str(),
    //       (long int) peer, peer->portName.c_str());
    proto.setRoute(proto.getRoute().addFromName(peer->portName));
    peerMutex.post();

    return true;
}
开发者ID:apaikan,项目名称:yarp,代码行数:13,代码来源:LocalCarrier.cpp

示例3: sendHeader

 bool MpiCarrier::sendHeader(ConnectionState& proto) {
    // Send the "magic number" for this carrier
    ManagedBytes header(8);
    getHeader(header.bytes());
    proto.os().write(header.bytes());
    if (!proto.os().isOk()) return false;

    // Now we can do whatever we want, as long as somehow
    // we also send the name of the originating port

    name = proto.getRoute().getFromName();
    other = proto.getRoute().getToName();
    Bytes b2((char*)name.c_str(),name.length());
    proto.os().write(b2);
    proto.os().write('\r');
    proto.os().write('\n');

    // Sender
    route = name + "->" + other;

    createStream(true);

    if (!MpiControl) return false;
    if (! MpiControl->isRunning())
        return false;
    comm->openPort();
    char* port = comm->port_name;
    char* uid = comm->unique_id;

    #ifdef MPI_DEBUG
    printf("[MpiCarrier @ %s] setting up MpiPort '%s'\n", route.c_str(), port);
    #endif

    Bytes b4(uid,strlen(uid));
    proto.os().write(b4);
    proto.os().write('\r');
    proto.os().write('\n');

    Bytes b3(port,strlen(port));
    proto.os().write(b3);
    proto.os().write('\r');
    proto.os().write('\n');
    proto.os().flush();


    #ifdef MPI_DEBUG
    printf("[MpiCarrier @ %s] Header sent\n", route.c_str());
    #endif

    return proto.os().isOk();
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:51,代码来源:MpiCarrier.cpp

示例4: expectSenderSpecifier

bool AbstractCarrier::expectSenderSpecifier(ConnectionState& proto)
{
    NetInt32 numberSrc;
    Bytes number((char*)&numberSrc, sizeof(NetInt32));
    int len = 0;
    YARP_SSIZE_T r = proto.is().readFull(number);
    if ((size_t)r!=number.length()) {
        YARP_DEBUG(Logger::get(), "did not get sender name length");
        return false;
    }
    len = NetType::netInt(number);
    if (len>1000) {
        len = 1000;
    }
    if (len<1) {
        len = 1;
    }
    ManagedBytes b(len+1);
    r = proto.is().readFull(Bytes(b.get(), len));
    if ((int)r!=len) {
        YARP_DEBUG(Logger::get(), "did not get sender name");
        return false;
    }
    ConstString s = b.get();
    Route route = proto.getRoute();
    route.setFromName(s);
    proto.setRoute(route);
    return true;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:29,代码来源:AbstractCarrier.cpp

示例5: 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;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:33,代码来源:XmlRpcCarrier.cpp

示例6: expectSenderSpecifier

bool AbstractCarrier::expectSenderSpecifier(ConnectionState& proto) {
    NetInt32 numberSrc;
    Bytes number((char*)&numberSrc,sizeof(NetInt32));
    int len = 0;
    YARP_SSIZE_T r = proto.is().readFull(number);
    if ((size_t)r!=number.length()) {
        YARP_DEBUG(Logger::get(),"did not get sender name length");
        return false;
    }
    len = NetType::netInt(number);
    if (len>1000) len = 1000;
    if (len<1) len = 1;
    // expect a string -- these days null terminated, but not in YARP1
    ManagedBytes b(len+1);
    r = proto.is().readFull(Bytes(b.get(),len));
    if ((int)r!=len) {
        YARP_DEBUG(Logger::get(),"did not get sender name");
        return false;
    }
    // add null termination for YARP1
    b.get()[len] = '\0';
    String s = b.get();
    proto.setRoute(proto.getRoute().addFromName(s));
    return true;
}
开发者ID:BRKMYR,项目名称:yarp,代码行数:25,代码来源:AbstractCarrier.cpp

示例7:

bool yarp::os::impl::TextCarrier::expectSenderSpecifier(ConnectionState& proto)
{
    YARP_SPRINTF0(Logger::get(), debug, "TextCarrier::expectSenderSpecifier");
    Route route = proto.getRoute();
    route.setFromName(proto.is().readLine());
    proto.setRoute(route);
    return true;
}
开发者ID:ale-git,项目名称:yarp,代码行数:8,代码来源:TextCarrier.cpp

示例8: sendHeader

bool XmlRpcCarrier::sendHeader(ConnectionState& proto) {
    shouldInterpretRosMessages(proto);
    ConstString target = "POST /RPC2";
    Name n(proto.getRoute().getCarrierName() + "://test");
    ConstString pathValue = n.getCarrierModifier("path");
    if (pathValue!="") {
        target = "POST /";
        target += pathValue;
        // on the wider web, we should provide real host names
        host = NetworkBase::queryName(proto.getRoute().getToName());
    }
    target += " HTTP/1.1\n";
    http = target;
    Bytes b((char*)target.c_str(),target.length());
    proto.os().write(b);
    return true;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:17,代码来源:XmlRpcCarrier.cpp

示例9: b

bool yarp::os::impl::HttpCarrier::sendHeader(ConnectionState& proto) {
    ConstString target = "GET / HTTP/1.0\r\n";
    ConstString path = proto.getRoute().getToName();
    if (path.size()>=2) {
        target = "GET " + path + " HTTP/1.0\r\n";
    }
    Contact host = proto.getRoute().getToContact();
    if (host.getHost()!="") {
        target += "Host: ";
        target += host.getHost();
        target += "\r\n";
    }
    target += "\r\n";
    Bytes b((char*)target.c_str(),target.length());
    proto.os().write(b);
    return true;

}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:18,代码来源:HttpCarrier.cpp

示例10: DgramTwoWayStream

bool yarp::os::impl::McastCarrier::becomeMcast(ConnectionState& proto, bool sender) {
#ifndef YARP_HAS_ACE
    return false;
#else
    YARP_UNUSED(sender);
    DgramTwoWayStream *stream = new DgramTwoWayStream();
    yAssert(stream!=YARP_NULLPTR);
    Contact remote = proto.getStreams().getRemoteAddress();
    Contact local;
    local = proto.getStreams().getLocalAddress();
    bool test = true;
    //(yarp::NameConfig::getEnv("YARP_MCAST_TEST")!="");
    /*
    if (test) {
        printf("  MULTICAST is being extended; some temporary status messages added\n");
        printf("  Local: %s\n", local.toString().c_str());
        printf("  Remote: %s\n", remote.toString().c_str());
    }
    */
    proto.takeStreams(YARP_NULLPTR); // free up port from tcp

    if (sender) {
        /*
            Multicast behavior seems a bit variable.
            We assume here that if packages need to be broadcast
            to targets via different network interfaces, that
            we'll need to send independently on those two
            interfaces.  This may or may not always be the case,
            the author doesn't know, so is being cautious.
        */
        key = proto.getRoute().getFromName();
        if (test) {
            key += "/net=";
            key += local.getHost();
        }
        YARP_DEBUG(Logger::get(),
                    ConstString("multicast key: ") + key);
        addSender(key);
    }

    bool ok = true;
    if (isElect()||!sender) {
        if (test) {
            ok = stream->join(mcastAddress,sender,local);
        } else {
            ok = stream->join(mcastAddress,sender);
        }
    }

    if (!ok) {
        delete stream;
        return false;
    }
    proto.takeStreams(stream);
    return true;
#endif
}
开发者ID:apaikan,项目名称:yarp,代码行数:57,代码来源:McastCarrier.cpp

示例11: sendHeader

bool MjpegCarrier::sendHeader(ConnectionState& proto) {
    Name n(proto.getRoute().getCarrierName() + "://test");
    ConstString pathValue = n.getCarrierModifier("path");
    ConstString target = "GET /?action=stream\n\n";
    if (pathValue!="") {
        target = "GET /";
        target += pathValue;
    }
    target += " HTTP/1.1\n";
    Contact host = proto.getRoute().getToContact();
    if (host.getHost()!="") {
        target += "Host: ";
        target += host.getHost();
        target += "\r\n";
    }
    target += "\n";
    Bytes b((char*)target.c_str(),target.length());
    proto.os().write(b);
    return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:20,代码来源:MjpegCarrier.cpp

示例12: n

// Now, the initial hand-shaking
bool H264Carrier::prepareSend(ConnectionState& proto)
{
     //get all parameters of this carrier
     Name n(proto.getRoute().getCarrierName() + "://test");

     cfgParams.crop.left = getIntParam(n, "cropLeft");
     cfgParams.crop.right = getIntParam(n, "cropRight");
     cfgParams.crop.top = getIntParam(n, "cropTop");
     cfgParams.crop.bottom = getIntParam(n, "cropBottom");
     cfgParams.fps_max = getIntParam(n, "max_fps");
     cfgParams.verbose = (getIntParam(n, "verbose") >0) ? true: false;

    return true;
}
开发者ID:robotology,项目名称:yarp,代码行数:15,代码来源:H264Carrier.cpp

示例13: defaultSendHeader

bool yarp::os::impl::LocalCarrier::sendHeader(ConnectionState& proto) {
    portName = proto.getRoute().getFromName();

    manager.setSender(this);

    defaultSendHeader(proto);
    // now switch over to some local structure to communicate
    peerMutex.lock();
    peer = manager.getReceiver();
    //printf("sender %ld sees receiver %ld\n", (long int) this,
    //       (long int) peer);
    peerMutex.unlock();

    return true;
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:15,代码来源:LocalCarrier.cpp

示例14: sendHeader

bool HumanCarrier::sendHeader(ConnectionState& proto) {
    // Send the "magic number" for this carrier
    ManagedBytes header(8);
    getHeader(header.bytes());
    proto.os().write(header.bytes());
    if (!proto.os().isOk()) return false;

    // Now we can do whatever we want, as long as somehow
    // we also send the name of the originating port

    // let's just send the port name in plain text terminated with a
    // carriage-return / line-feed
    ConstString from = proto.getRoute().getFromName();
    Bytes b2((char*)from.c_str(),from.length());
    proto.os().write(b2);
    proto.os().write('\r');
    proto.os().write('\n');
    proto.os().flush();
    return proto.os().isOk();
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:20,代码来源:HumanCarrier.cpp

示例15: getRosType

ConstString TcpRosCarrier::getRosType(ConnectionState& proto) {
    ConstString typ = "";
    ConstString rtyp = "";
    if (proto.getContactable()) {
        Type t = proto.getContactable()->getType(); 
        typ = t.getName();
        md5sum = t.readProperties().find("md5sum").asString();
        message_definition = t.readProperties().find("message_definition").asString();
        user_type = typ;
        if (typ=="yarp/image") {
            wire_type = "sensor_msgs/Image";
            rtyp = "";
        } else if (typ=="yarp/bottle") {
            rtyp = proto.getContactable()->getType().getNameOnWire();
            if (rtyp=="yarp/image") rtyp = "sensor_msgs/Image";
            wire_type = rtyp;
        } else if (typ!="") {
            rtyp = typ;
            wire_type = typ;
        }
    }
    Name n(proto.getRoute().getCarrierName() + "://test");
    ConstString mode = "topic";
    ConstString modeValue = n.getCarrierModifier("topic");
    if (modeValue=="") {
        mode = "service";
        modeValue = n.getCarrierModifier("service");
    }
    if (modeValue!="") {
        ConstString package = n.getCarrierModifier("package");
        if (package!="") {
            rtyp = package + "/" + modeValue;
        }
    }

    dbg_printf("USER TYPE %s\n", user_type.c_str());
    dbg_printf("WIRE TYPE %s\n", wire_type.c_str());

    return rtyp;
}
开发者ID:barbalberto,项目名称:yarp,代码行数:40,代码来源:TcpRosCarrier.cpp


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