コード例 #1
0
ファイル: Stamp.cpp プロジェクト: paulfitz/yarp
bool Stamp::write(ConnectionWriter& connection) {
    connection.appendInt(BOTTLE_TAG_LIST); // nested structure
    connection.appendInt(2);               // with two elements
    connection.appendInt(BOTTLE_TAG_INT);
    connection.appendInt(sequenceNumber);
    connection.appendInt(BOTTLE_TAG_DOUBLE);
    connection.appendDouble(timeStamp);
    connection.convertTextMode();
    return !connection.isError();
}
コード例 #2
0
ファイル: Value.cpp プロジェクト: johnty/libYARP_OS
bool Value::write(ConnectionWriter& connection) {
    if (!proxy) {
        connection.appendInt(BOTTLE_TAG_LIST);
        connection.appendInt(0);
        return !connection.isError();
    }
    connection.appendInt(BOTTLE_TAG_LIST);
    connection.appendInt(1);
    return proxy->write(connection);
}
コード例 #3
0
ファイル: BottleImpl.cpp プロジェクト: holgerfriedrich/yarp
bool BottleImpl::write(ConnectionWriter& writer) {
    // could simplify this if knew lengths of blocks up front
    if (writer.isTextMode()) {
        //writer.appendLine(toString());
        writer.appendString(toString().c_str(),'\n');
    } else {
#ifdef USE_YARP1_PREFIX
        if (!nested) {
            String name = "YARP2";
            writer.appendInt(name.length()+1);
            writer.appendString(name.c_str(),'\0');
        }
#endif
        synch();
        /*
          if (!nested) {
          // No byte count any more, to facilitate nesting
          //YMSG(("bottle byte count %d\n",byteCount()));
          //writer.appendInt(byteCount()+sizeof(NetInt32));
          
          writer.appendInt(StoreList::code + speciality);
          }
        */
        //writer.appendBlockCopy(Bytes((char*)getBytes(),byteCount()));
        writer.appendBlock((char*)getBytes(),byteCount());
    }
    return !writer.isError();
}
コード例 #4
0
ファイル: dynContact.cpp プロジェクト: robotology/icub-main
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~
//   SERIALIZATION methods
//~~~~~~~~~~~~~~~~~~~~~~
bool dynContact::write(ConnectionWriter& connection) const{
    // represent a dynContact as a list of 4 elements that are:
    // - a list of 3 int, i.e. contactId, bodyPart, linkNumber
    // - a list of 3 double, i.e. the CoP
    // - a list of 3 double, i.e. the force
    // - a list of 3 double, i.e. the moment

    connection.appendInt(BOTTLE_TAG_LIST);
    connection.appendInt(4);
    // list of 3 int, i.e. contactId, bodyPart, linkNumber
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_INT);
    connection.appendInt(3);
    connection.appendInt(contactId);
    connection.appendInt(bodyPart);    // left_arm, right_arm, ...
    connection.appendInt(linkNumber);
    // list of 3 double, i.e. the CoP
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
    connection.appendInt(3);
    for(int i=0;i<3;i++) connection.appendDouble(CoP[i]);
    // list of 3 double, i.e. the force
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
    connection.appendInt(3);
    for(int i=0;i<3;i++) connection.appendDouble(F[i]);
    // list of 3 double, i.e. the moment
    connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
    connection.appendInt(3);
    for(int i=0;i<3;i++) connection.appendDouble(Mu[i]);  

    // if someone is foolish enough to connect in text mode,
    // let them see something readable.
    connection.convertTextMode();  
    
    return !connection.isError();
}
コード例 #5
0
ファイル: BottleImpl.cpp プロジェクト: holgerfriedrich/yarp
bool StoreBlob::writeRaw(ConnectionWriter& writer) {
    writer.appendInt((int)x.length());
    writer.appendBlock(x.c_str(),x.length());
    return true;
}
コード例 #6
0
ファイル: BottleImpl.cpp プロジェクト: holgerfriedrich/yarp
bool StoreString::writeRaw(ConnectionWriter& writer) {
    writer.appendInt((int)x.length()+1);
    writer.appendBlock(x.c_str(),x.length()+1); // need \0
    return true;
}
コード例 #7
0
ファイル: BottleImpl.cpp プロジェクト: holgerfriedrich/yarp
bool StoreVocab::writeRaw(ConnectionWriter& writer) {
    writer.appendInt(x);
    return true;
}
コード例 #8
0
ファイル: BottleImpl.cpp プロジェクト: holgerfriedrich/yarp
bool Storable::write(ConnectionWriter& connection) {
    connection.appendInt(getCode());
    return writeRaw(connection);
}
コード例 #9
0
ファイル: yarpcxx_test2.cpp プロジェクト: Tiger66639/yarp
 virtual bool write(ConnectionWriter& connection) {
     printf("Writing an integer\n");
     connection.appendInt(val);
     return true;
 }