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


C++ ConnectionReader类代码示例

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


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

示例1: readRaw

bool StoreBlob::readRaw(ConnectionReader& reader) {
    int len = reader.expectInt();
    String buf(YARP_STRINIT(len));
    reader.expectBlock((const char *)buf.c_str(),len);
    x = buf;
    return true;
}
开发者ID:holgerfriedrich,项目名称:yarp,代码行数:7,代码来源:BottleImpl.cpp

示例2: readRaw

bool StoreBlob::readRaw(ConnectionReader& reader)
{
    std::int32_t len = reader.expectInt32();
    x.resize(len);
    reader.expectBlock(const_cast<char*>(x.data()), len);
    return true;
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:7,代码来源:Storable.cpp

示例3: read

bool DeviceResponder::read(ConnectionReader& connection) {
    Bottle cmd, response;
    if (!cmd.read(connection)) { return false; }
    //printf("command received: %s\n", cmd.toString().c_str());
    respond(cmd,response);
    if (response.size()>=1) {
        ConnectionWriter *writer = connection.getWriter();
        if (writer!=NULL) {
            if (response.get(0).toString()=="many"&&writer->isTextMode()) {
                for (int i=1; i<response.size(); i++) {
                    Value& v = response.get(i);
                    if (v.isList()) {
                        v.asList()->write(*writer);
                    } else {
                        Bottle b;
                        b.add(v);
                        b.write(*writer);
                    }
                }
            } else {
                response.write(*writer);
            }

            //printf("response sent: %s\n", response.toString().c_str());
        }
    } else {
        ConnectionWriter *writer = connection.getWriter();
        if (writer!=NULL) {
            response.clear();
            response.addVocab(Vocab::encode("nak"));
            response.write(*writer);
        }
    }
    return true;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:35,代码来源:DeviceDriver.cpp

示例4: read

    virtual bool read(ConnectionReader& connection)
    {
        unsigned int incoming;
        bool ok = connection.expectBlock((char*)&datum, sizeof(double));
        ok=ok&&connection.expectBlock((char*)&incoming, sizeof(int));

        //this resize only if needed
        resize(incoming);

        if (payloadSize>0)
            ok=ok&&connection.expectBlock((char *)payload, payloadSize);

        return ok;
    }
开发者ID:BRKMYR,项目名称:yarp,代码行数:14,代码来源:port_latency.cpp

示例5: getBusStats

bool yarp::os::Node::Helper::read(ConnectionReader& reader)
{
    if (!reader.isValid()) {
        return false;
    }
    NodeArgs na;
    na.request.read(reader);
    //printf("NODE API for %s received %s\n",
    //name.c_str(),
    //na.request.toString().c_str());
    std::string key = na.request.get(0).asString();
    na.args = na.request.tail().tail();
    if (key=="getBusStats") {
        getBusStats(na);
    } else if (key=="getBusInfo") {
        getBusInfo(na);
    } else if (key=="getMasterUri") {
        getMasterUri(na);
    } else if (key=="shutdown") {
        shutdown(na);
    } else if (key=="getPid") {
        getPid(na);
    } else if (key=="getSubscriptions") {
        getSubscriptions(na);
    } else if (key=="getPublications") {
        getPublications(na);
    } else if (key=="paramUpdate") {
        paramUpdate(na);
    } else if (key=="publisherUpdate") {
        publisherUpdate(na);
    } else if (key=="requestTopic") {
        requestTopic(na);
    } else {
        na.error("I have no idea what you are talking about");
    }
    if (na.should_drop) {
        reader.requestDrop(); // ROS likes to close down.
    }
    if (reader.getWriter()) {
        Bottle full;
        full.addInt32(na.code);
        full.addString(na.msg);
        full.add(na.reply);
        //printf("NODE %s <<< %s\n",
        //name.c_str(),
        //full.toString().c_str());
        full.write(*reader.getWriter());
    }
    return true;
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:50,代码来源:Node.cpp

示例6: read

bool RFModuleHelper::read(ConnectionReader& connection) {
    Bottle cmd, response;
    if (!cmd.read(connection)) { return false; }
    printf("command received: %s\n", cmd.toString().c_str());

    bool result = owner.safeRespond(cmd,response);
    if (response.size()>=1) {
        ConnectionWriter *writer = connection.getWriter();
        if (writer!=0) {
            if (response.get(0).toString()=="many" && writer->isTextMode()) {
                for (int i=1; i<response.size(); i++) {
                    Value& v = response.get(i);
                    if (v.isList()) {
                        v.asList()->write(*writer);
                    } else {
                        Bottle b;
                        b.add(v);
                        b.write(*writer);
                    }
                }
            } else {
                response.write(*writer);
            }

            //printf("response sent: %s\n", response.toString().c_str());
        }
    }
    return result;
}
开发者ID:johnty,项目名称:libYARP_OS,代码行数:29,代码来源:RFModule.cpp

示例7: read

 virtual bool read(ConnectionReader& connection) {
     Bottle cmd, response;
     cmd.read(connection);
     printf("command received: %s\n", cmd.toString().c_str());
     int code = cmd.get(0).asVocab();
     switch (code) {
     case VOCAB3('s','e','t'):
         printf("set command received\n");
         prop.put(cmd.get(1).asString().c_str(),cmd.get(2));
         break;
     case VOCAB3('g','e','t'):
         printf("get command received\n");
         response.addVocab(VOCAB2('i','s'));
         response.add(cmd.get(1));
         response.add(prop.find(cmd.get(1).asString().c_str()));
         break;
     }
     if (response.size()>=1) {
         ConnectionWriter *writer = connection.getWriter();
         if (writer!=NULL) {
             response.write(*writer);
             printf("response sent: %s\n", response.toString().c_str());
         }
     }
 }
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:25,代码来源:main.cpp

示例8: read

bool Storable::read(ConnectionReader& connection)
{
    std::int32_t x = connection.expectInt32();
    if (x != getCode()) {
        return false;
    }
    return readRaw(connection);
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:8,代码来源:Storable.cpp

示例9: reader

WireReader::WireReader(ConnectionReader& reader) : reader(reader)
{
    reader.convertTextMode();
    state = &baseState;
    flush_if_needed = false;
    get_mode = false;
    support_get_mode = false;
    expecting = false;
}
开发者ID:apaikan,项目名称:yarp,代码行数:9,代码来源:WireReader.cpp

示例10: read

 virtual bool read(ConnectionReader& connection) {
     Bottle receive;
     receive.read(connection);
     receive.addInt(5);
     ConnectionWriter *writer = connection.getWriter();
     if (writer!=NULL) {
         receive.write(*writer);
     }
     return true;
 }
开发者ID:JoErNanO,项目名称:yarp,代码行数:10,代码来源:PortTest.cpp

示例11: fromBytes

bool BottleImpl::fromBytes(ConnectionReader& reader) {
    if (reader.isError()) return false;
    int id = speciality;
    YMSG(("READING, nest flag is %d\n", nested));
    if (id==0) {
        id = reader.expectInt();
        YMSG(("READ subcode %d\n", id));
    } else {
        YMSG(("READ skipped subcode %d\n", speciality));
    }
    Storable *storable = Storable::createByCode(id);
    if (storable==NULL) {
        YARP_SPRINTF1(Logger::get(),error,"BottleImpl reader failed, unrecognized object code %d",id);
        return false;
    }
    storable->readRaw(reader);
    add(storable);
    return true;
}
开发者ID:holgerfriedrich,项目名称:yarp,代码行数:19,代码来源:BottleImpl.cpp

示例12: readFromConnection

/**
* This helper function groups code to avoid duplication. It is not a member function of Image because 
* there are problems with ImageNetworkHeader, anyhow the function is state-less and uses only parameters.
*/
inline bool readFromConnection(Image &dest, ImageNetworkHeader &header, ConnectionReader& connection)
{
    dest.resize(header.width, header.height);
    unsigned char *mem = dest.getRawImage();
    int allocatedBytes = dest.getRawImageSize();
    yAssert(mem != NULL);
    //this check is redundant with assertion, I would remove it
    if (dest.getRawImageSize() != header.imgSize) {
        printf("There is a problem reading an image\n");
        printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
            (int)header.width, (int)header.height,
            (int)header.id,
            (int)header.quantum, (int)header.imgSize);
        printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
            dest.width(), dest.height(), dest.getPixelCode(), dest.getQuantum(), allocatedBytes);
    }
    yAssert(allocatedBytes == header.imgSize);
    bool ok = connection.expectBlock((char *)mem, allocatedBytes);
    return (!connection.isError() && ok);
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:24,代码来源:Image.cpp

示例13: read

 virtual bool read(ConnectionReader& connection) {
     Bottle b,r;
     bool ok = b.read(connection);
     if (!ok) return false;
     stackWrap->onTick();
     r.addString("tack");
     ConnectionWriter *returnToSender = connection.getWriter();
     if (returnToSender != NULL)
         r.write(*returnToSender);
     return true;
 }
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:11,代码来源:main.cpp

示例14: read

bool PortCommand::read(ConnectionReader& reader) {
    //ACE_DEBUG((LM_DEBUG,"PortCommand::readBlock"));
    ch = '\0';
    str = "";
    if (!reader.isTextMode()) {
        bool ok = reader.expectBlock(header.get(),header.length());
        if (!ok) return false;
        char *base = header.get();
        if (base[4] == '~') {
            ch = base[5];
            if (ch=='\0') {
                //str = reader.expectString(reader.getSize());
                str = reader.expectText('\0').c_str();
                if (reader.isError()) return false;
                if (str.length()>0) {
                    ch = str[0];
                }
            }
        } else {
            return false;
        }
    } else {
        str = reader.expectText().c_str();
        if (reader.isError()) return false;
        if (str.length()>0) {
            ch = str[0];
        }
    }
    return true;
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:30,代码来源:PortCommand.cpp

示例15: read

bool Value::read(ConnectionReader& connection) {
    if (proxy) {
        delete proxy;
        proxy = 0;
    }
    int x = connection.expectInt();
    if ((x&0xffff) != x) return false;
    if (!(x&BOTTLE_TAG_LIST)) return false;
    int len = connection.expectInt();
    if (len==0) return true;
    if (len!=1) return false;
    if (x==BOTTLE_TAG_LIST) {
        x = connection.expectInt();
    } else {
        x &= ~BOTTLE_TAG_LIST;
    }
    if (connection.isError()) return false;
    Storable *s = Storable::createByCode(x);
    setProxy(s);
    if (!proxy) return false;
    return s->readRaw(connection);
}
开发者ID:johnty,项目名称:libYARP_OS,代码行数:22,代码来源:Value.cpp


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