예제 #1
0
void Node::write2Blk(Block &blk, int typeId, int strLen, BufferManager* bufferManager) {
    char* mem = blk.data;
    
    mem[0] = isleaf; mem[1] = isroot;
    mem += 2*sizeof(char);
    writei(getPSize(), mem), writei(getKSize(), mem), writei(typeId, mem), writei(strLen, mem);
    
    std::cout << "getPSize()" << getPSize() <<std::endl;
    std::cout << "getKSize()" << getKSize() <<std::endl;
    
    for( int i = 0; i < getPSize(); i++ ) {
        std::cout << "P[i]" << P[i] << std::endl;
        writei(P[i], mem);
    }
    
    for( int i = 0; i < getKSize(); i++ ) {
        std::cout << "K[i]" << K[i].datai << std::endl;
        if( typeId == 0 ) {
            writei(K[i].datai, mem);
        }
        else if( typeId == 1 ) {
            writef(K[i].dataf, mem);
        }
        else if( typeId == 2 ) {
            writes(K[i].datas, strLen, mem);
        }
    }
    
    std::cout << "Node::write2Blk " << blk.pos/BLOCK_SIZE << std::endl;
    
    //BufferManager bufferManager;
    bufferManager->writeBlock(blk);
}
JsonObject*
SamiShipment::asJsonObject() {
    JsonObject *pJsonObject = new JsonObject();
    pJsonObject->Construct();

    JsonString *pIdKey = new JsonString(L"id");
    pJsonObject->Add(pIdKey, toJson(getPId(), "String", ""));

    JsonString *pNameKey = new JsonString(L"name");
    pJsonObject->Add(pNameKey, toJson(getPName(), "String", ""));

    JsonString *pPriorityKey = new JsonString(L"priority");
    pJsonObject->Add(pPriorityKey, toJson(getPPriority(), "Integer", ""));

    JsonString *pPickupKey = new JsonString(L"pickup");
    pJsonObject->Add(pPickupKey, toJson(getPPickup(), "SamiStop", ""));

    JsonString *pDeliveryKey = new JsonString(L"delivery");
    pJsonObject->Add(pDeliveryKey, toJson(getPDelivery(), "SamiStop", ""));

    JsonString *pSizeKey = new JsonString(L"size");
    pJsonObject->Add(pSizeKey, toJson(getPSize(), "Integer", "array"));

    JsonString *pRequired_skillsKey = new JsonString(L"required_skills");
    pJsonObject->Add(pRequired_skillsKey, toJson(getPRequiredSkills(), "String", "array"));

    JsonString *pAllowed_vehiclesKey = new JsonString(L"allowed_vehicles");
    pJsonObject->Add(pAllowed_vehiclesKey, toJson(getPAllowedVehicles(), "String", "array"));

    return pJsonObject;
}