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


C++ os::ConnectionWriter类代码示例

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


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

示例1: write

bool Matrix::write(yarp::os::ConnectionWriter& connection) {
    MatrixPortContentHeader header;

    //header.totalLen = sizeof(header)+sizeof(double)*this->size();
    header.outerListTag = BOTTLE_TAG_LIST;
    header.outerListLen = 3;
    header.rowsTag = BOTTLE_TAG_INT;
    header.colsTag = BOTTLE_TAG_INT;
    header.listTag = BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE;
    header.rows=rows();
    header.cols=cols();
    header.listLen = header.rows*header.cols;

    connection.appendBlock((char*)&header, sizeof(header));

    int l=0;
    const double *tmp=data();
    for(l=0;l<header.listLen;l++)
        connection.appendDouble(tmp[l]);

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();

    return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:26,代码来源:Matrix.cpp

示例2: write

bool eventBottle::write(yarp::os::ConnectionWriter& connection) {
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_BLOB + BOTTLE_TAG_INT);
    connection.appendInt(2);        // four elements

    size_t binaryDim;
    size_of_the_bottle  = packet->size();
    size_of_the_packet  = size_of_the_bottle;
    bytes_of_the_packet = size_of_the_packet * 4;
    //packetPointer = (char*) packet->toBinary(&binaryDim);
    //bytes_of_the_packet = binaryDim;
    //size_of_the_packet  = bytes_of_the_packet >> 2;
    connection.appendInt(bytes_of_the_packet);
    //connection.appendInt(size_of_the_packet);
    //bytes_of_the_packet = size_of_the_packet * wordDimension;   // number of 32bit word times 4bytes

    //--------------------------------------------------------------------------------------------
    // -------- serialisation of the bottle ---------------------------
    unsigned char tmpChar;
    char *p = packetPointer;

    for(int i = 0 ; i < size_of_the_packet ; i++) {
        int value = packet->get(i).asInt();

        for (int j = 0 ; j < wordDimension ; j++){
            int tmpInt   = (value & 0x000000FF) ;
            tmpChar      =  (unsigned char) tmpInt;
            //printf("%02x %02x ",tmpInt,tmpChar);
            value = value >> 8;
            *p = tmpChar;
            p++;
        }
    }
    //----------------------------------------------------------------------------------------------


#if VERBOSE
    int word;
    printf("packet %d %d \n %s \n", size_of_the_packet, binaryDim, packet->toString().c_str());
    char* i_data = packetPointer;
    for(int i = 0 ; i < binaryDim ;) {
        word = 0;
        for (int j = 0 ; j < wordDimension ; j++){
            int value = (char) *i_data << (8 * j);
            word = word | value;
            i_data++;
            i++;
        }
        printf(">%08X ", word);
    }
    printf("\n");
#endif

    //-----------------------------------------------------------------------------------------------
    connection.appendBlock(packetPointer,bytes_of_the_packet);   //serializing bottle into char*
    //printf("packet \n %s \n", packet->toString().c_str());
    connection.convertTextMode();   // if connection is text-mode, convert!
    return true;
}
开发者ID:himstien,项目名称:iCubFiles,代码行数:58,代码来源:eventBottle.cpp

示例3: write

bool C_sendingBuffer::write(yarp::os::ConnectionWriter& connection)
{
	connection.appendInt(BOTTLE_TAG_LIST+BOTTLE_TAG_BLOB+BOTTLE_TAG_INT);
	connection.appendInt(2); // four elements
	connection.appendInt(size_of_the_packet);
	connection.appendBlock (packet, SIZE_OF_DATA);
	connection.convertTextMode(); // if connection is text-mode, convert!
	return true;
}
开发者ID:fhaust,项目名称:event-driven,代码行数:9,代码来源:sending_buffer.cpp

示例4: write

bool eventBuffer::write(yarp::os::ConnectionWriter& connection)
{
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_BLOB + BOTTLE_TAG_INT);
    connection.appendInt(2);        // four elements
    connection.appendInt(size_of_the_packet);
    int ceilSizeOfPacket = (size_of_the_packet+7)/8*8;   // the nearest multiple of 8 greater or equal to size_of_the_packet
    connection.appendBlock(packet,ceilSizeOfPacket);
    connection.convertTextMode();   // if connection is text-mode, convert!
    return true;

}
开发者ID:fhaust,项目名称:event-driven,代码行数:11,代码来源:eventBuffer.cpp

示例5: write

bool Vector::write(yarp::os::ConnectionWriter& connection) {
    VectorPortContentHeader header;

    header.listTag = (BOTTLE_TAG_LIST | BOTTLE_TAG_DOUBLE);
    header.listLen = (int)size();

    connection.appendBlock((char*)&header, sizeof(header));

    int k=0;
    for (k=0;k<header.listLen;k++)
        connection.appendDouble((*this)[k]);

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();

    return !connection.isError();
}
开发者ID:jgvictores,项目名称:yarp,代码行数:18,代码来源:Vector.cpp

示例6: write

bool Quaternion::write(yarp::os::ConnectionWriter& connection)
{
    QuaternionPortContentHeader header;

    header.listTag = (BOTTLE_TAG_LIST | BOTTLE_TAG_DOUBLE);
    header.listLen = 4;

    connection.appendBlock((char*)&header, sizeof(header));

    connection.appendDouble(this->internal_data[0]);
    connection.appendDouble(this->internal_data[1]);
    connection.appendDouble(this->internal_data[2]);
    connection.appendDouble(this->internal_data[3]);

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();

    return !connection.isError();
}
开发者ID:jgvictores,项目名称:yarp,代码行数:20,代码来源:Quaternion.cpp

示例7: write

bool Image::write(yarp::os::ConnectionWriter& connection) {
    ImageNetworkHeader header;
    header.setFromImage(*this);
    /*
    header.listTag = BOTTLE_TAG_LIST;
    header.listLen = 4;
    header.paramNameTag = BOTTLE_TAG_VOCAB;
    header.paramName = VOCAB3('m','a','t');
    header.paramIdTag = BOTTLE_TAG_VOCAB;
    header.id = getPixelCode();
    header.paramListTag = BOTTLE_TAG_LIST + BOTTLE_TAG_INT;
    header.paramListLen = 5;
    header.depth = getPixelSize();
    header.imgSize = getRawImageSize();
    header.quantum = getQuantum();
    header.width = width();
    header.height = height();
    header.paramBlobTag = BOTTLE_TAG_BLOB;
    header.paramBlobLen = getRawImageSize();
    */

    connection.appendBlock((char*)&header,sizeof(header));
    unsigned char *mem = getRawImage();
    if (header.width!=0&&header.height!=0) {
        yAssert(mem!=NULL);

        // Note use of external block.
        // Implies care needed about ownership.
        connection.appendExternalBlock((char *)mem,header.imgSize);
    }

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();

    return !connection.isError();
}
开发者ID:giuliavezzani,项目名称:yarp,代码行数:37,代码来源:Image.cpp

示例8: write

bool SystemInfoSerializer::write(yarp::os::ConnectionWriter& connection)
{
    // updating system info
    memory = SystemInfo::getMemoryInfo();
    storage = SystemInfo::getStorageInfo();
    //network = SystemInfo::getNetworkInfo();
    processor = SystemInfo::getProcessorInfo();
    platform = SystemInfo::getPlatformInfo(); 
    load = SystemInfo::getLoadInfo();
    user = SystemInfo::getUserInfo();    

    // serializing memory
    connection.appendInt(memory.totalSpace);
    connection.appendInt(memory.freeSpace);

    // serializing storage
    connection.appendInt(storage.totalSpace);
    connection.appendInt(storage.freeSpace);

    // serializing network
    //connection.appendString(network.mac.c_str());
    //connection.appendString(network.ip4.c_str());
    //connection.appendString(network.ip6.c_str());
    
    // serializing processor
    connection.appendString(processor.architecture.c_str());
    connection.appendString(processor.model.c_str());
    connection.appendString(processor.vendor.c_str());
    connection.appendInt(processor.family);
    connection.appendInt(processor.modelNumber);
    connection.appendInt(processor.cores);
    connection.appendInt(processor.siblings);
    connection.appendDouble(processor.frequency);

    // serializing load
    connection.appendDouble(load.cpuLoad1);
    connection.appendDouble(load.cpuLoad5);
    connection.appendDouble(load.cpuLoad15);
    connection.appendInt(load.cpuLoadInstant);

    // serializing platform
    connection.appendString(platform.name.c_str());
    connection.appendString(platform.distribution.c_str());
    connection.appendString(platform.release.c_str());
    connection.appendString(platform.codename.c_str());
    connection.appendString(platform.kernel.c_str());
    connection.appendString(platform.environmentVars.toString().c_str());

    // serializing user
    connection.appendString(user.userName.c_str());
    connection.appendString(user.realName.c_str());
    connection.appendString(user.homeDir.c_str());
    connection.appendInt(user.userID);

    return !connection.isError();
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:56,代码来源:SystemInfoSerializer.cpp

示例9:

bool MapGrid2D::write(yarp::os::ConnectionWriter& connection)
{
    connection.appendInt(BOTTLE_TAG_LIST);
    connection.appendInt(9);
    connection.appendInt(BOTTLE_TAG_INT);
    connection.appendInt(m_width);
    connection.appendInt(BOTTLE_TAG_INT);
    connection.appendInt(m_height);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_origin.x);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_origin.y);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_origin.theta);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(m_resolution);
    connection.appendInt(BOTTLE_TAG_STRING);
    connection.appendRawString(m_map_name.c_str());

    unsigned char *mem = nullptr;
    int            memsize = 0;
    mem     = m_map_occupancy.getRawImage();
    memsize = m_map_occupancy.getRawImageSize();
    connection.appendInt(BOTTLE_TAG_BLOB);
    connection.appendInt(memsize);
    connection.appendExternalBlock((char*)mem, memsize);
    mem     = m_map_flags.getRawImage();
    memsize = m_map_flags.getRawImageSize();
    connection.appendInt(BOTTLE_TAG_BLOB);
    connection.appendInt(memsize);
    connection.appendExternalBlock((char*)mem, memsize);

    connection.convertTextMode();
    return !connection.isError();
}
开发者ID:jgvictores,项目名称:yarp,代码行数:35,代码来源:MapGrid2D.cpp


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