Esempio n. 1
0
static bool read_string(int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iRet = 0;
    int iSize = 0;
    int iComplex = 0;
    char** pstData = NULL;

    iSize = getDatasetInfo(_iDatasetId, &iComplex, &_pInfo->iDims, _pInfo->piDims);

    pstData = (char **)MALLOC(iSize * sizeof(char *));
    iRet = readStringMatrix(_iDatasetId, pstData);


    for (int i = 0 ; i < _pInfo->piDims[0] * _pInfo->piDims[1] ; i++)
    {
        _pInfo->iSize += (int)strlen(pstData[i]) * 4;
    }


    freeStringMatrix(_iDatasetId, pstData);
    FREE(pstData);
    //always full double size
    _pInfo->iSize += (8 - (_pInfo->iSize % 8));
    //header + offset
    _pInfo->iSize += 16 + (1 + iSize) * 4;

    generateInfo(_pInfo, "string");
    return true;
}
Esempio n. 2
0
static bool read_poly(int dataset, VarInfo6& info)
{
    int complex = 0;
    int size = getDimsNode(dataset, &complex, info.pdims);
    info.size = 0;

    //open __refs__ node
    int refs = getDataSetIdFromName(dataset, "__refs__");

    for (int i = 0; i < size; ++i)
    {
        std::string polyname(std::to_string(i));
        int poly = getDataSetIdFromName(refs, polyname.data());

        //get dims
        complex = 0;
        int dims = 0;
        int ret = getDatasetInfo(poly, &complex, &dims, NULL);
        if (ret < 0)
        {
            return false;
        }

        std::vector<int> d(dims);
        int datasize = getDatasetInfo(poly, &complex, &dims, d.data());
        info.size += datasize * sizeof(double) * (complex + 1);
    }

    closeList6(refs);
    closeList6(dataset);

    generateInfo(info);
    return true;
}
Esempio n. 3
0
static bool read_string(int dataset, VarInfo6& info)
{
    int complex = 0;
    int ret = getDatasetInfo(dataset, &complex, &info.dims, NULL);
    if (ret < 0)
    {
        closeDataSet(dataset);
        return false;
    }

    info.pdims.resize(info.dims);
    int size = getDatasetInfo(dataset, &complex, &info.dims, info.pdims.data());

    std::vector<char*> str(size);
    ret = readStringMatrix(dataset, str.data());

    for (int i = 0; i < size; i++)
    {
        info.size += (int)strlen(str[i]) * sizeof(wchar_t);
    }

    freeStringMatrix(dataset, str.data());

    generateInfo(info);
    return true;
}
Esempio n. 4
0
void uploadInstance::run()
{
    int x = 0;
    Instance = new CLibMoor();
    Instance -> splitFile(file.toStdString(), msize);
    while(x < 3)
    {
        if(Instance->downloadDone) break;
        for (int i = 0; i < uploadMailboxes.size(); ++i)
        {
            user = uploadMailboxes.at(i)->username;
            pass = uploadMailboxes.at(i)->password;

            if(!Instance -> selectUploadMailBox(user.toStdString(), pass.toStdString(), getToUsernames().toStdString(), dpass.toStdString(), epass.toStdString()))
            {
                totalSegments = Instance->getMyUploadNumOfSeg();
                fileCRC = QString::fromStdString(Instance->getMyUploadFileCRC());
                infoString = generateInfo();
                Instance->generateCleanHashcode();
                Instance->startUpload(fromseg);
            }
        }
        x++;
    }
}
Esempio n. 5
0
static bool read_sparse(int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iNbItem = 0;
    int iComplex = 0;

    iRet = getSparseDimension(_iDatasetId, &iRows, &iCols, &iNbItem);
    if (iRet)
    {
        return false;
    }

    iComplex = isComplexData(_iDatasetId);

    _pInfo->iDims = 2;
    _pInfo->piDims[0] = iRows;
    _pInfo->piDims[1] = iCols;
    _pInfo->iSize = 20 + iRows * 4 + iNbItem * 4 + (iNbItem * (iComplex + 1) * 8);

    generateInfo(_pInfo, "sparse");
    closeDataSet(_iDatasetId);
    return true;
}
Esempio n. 6
0
static bool read_macro(int dataset, VarInfo6& info)
{
    info.size = 0;
    info.dims = 2;
    info.pdims = {1, 1};
    closeList6(dataset);
    generateInfo(info);
    return true;
}
Esempio n. 7
0
static bool read_handles(int dataset, VarInfo6& info)
{
    //get cell dimensions
    int complex = 0;
    int size = getDimsNode(dataset, &complex, info.pdims);
    info.dims = static_cast<int>(info.pdims.size());

    if (size == 0)
    {
        info.size = 0;
        generateInfo(info);
        closeList6(dataset);
        return true;
    }

    closeList6(dataset);

    generateInfo(info);
    return true;
}
Esempio n. 8
0
static bool read_double(int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iSize = 0;
    int iComplex = 0;

    iSize = getDatasetInfo(_iDatasetId, &iComplex, &_pInfo->iDims, _pInfo->piDims);
    _pInfo->iSize = (2 + (iSize * (iComplex + 1))) * 8;

    generateInfo(_pInfo, "constant");
    closeDataSet(_iDatasetId);
    return true;
}
Esempio n. 9
0
static bool read_boolean(int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iSize = 0;
    int iComplex = 0;

    iSize = getDatasetInfo(_iDatasetId, &iComplex, &_pInfo->iDims, _pInfo->piDims);
    _pInfo->iSize = (3 + iSize) * 4;

    generateInfo(_pInfo, "boolean");
    closeDataSet(_iDatasetId);
    return true;
}
Esempio n. 10
0
static bool read_cell(int dataset, VarInfo6& info)
{
    //get cell dimensions
    int complex = 0;
    int size = getDimsNode(dataset, &complex, info.pdims);
    info.dims = static_cast<int>(info.pdims.size());

    if (size == 0)
    {
        info.size = 0;
        generateInfo(info);
        closeList6(dataset);
        return true;
    }

    //open __refs__ node
    int refs = getDataSetIdFromName(dataset, "__refs__");
    for (int i = 0; i < size; ++i)
    {
        int ref = getDataSetIdFromName(refs, std::to_string(i).data());
        VarInfo6 info2;
        if (read_data(ref, info2) == false)
        {
            closeList6(refs);
            closeList6(dataset);
            return false;
        }

        info.size += info2.size;
    }

    closeList6(refs);
    closeList6(dataset);

    generateInfo(info);
    return true;
}
Esempio n. 11
0
static bool read_integer(int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iRet = 0;
    int iPrec = 0;
    int iSize = 0;
    int iComplex = 0;

    iSize = getDatasetInfo(_iDatasetId, &iComplex, &_pInfo->iDims, _pInfo->piDims);
    getDatasetPrecision(_iDatasetId, &iPrec);

    _pInfo->iSize = 16 + iSize * (iPrec % 10);

    generateInfo(_pInfo, "integer");
    closeDataSet(_iDatasetId);
    return true;
}
Esempio n. 12
0
static bool read_poly(int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iRet = 0;
    int iComplex = 0;
    char pstVarName[64] = { 0 };
    double **pdblReal = NULL;
    double **pdblImg = NULL;
    int *piNbCoef = NULL;
    int iSize = 0;

    iSize = getDatasetInfo(_iDatasetId, &iComplex, &_pInfo->iDims, _pInfo->piDims);
    _pInfo->iSize = 8 * 4 + (iSize + 1) * 4;

    if (iComplex)
    {
        piNbCoef = (int *)MALLOC(iSize * sizeof(int));
        pdblReal = (double **)MALLOC(iSize * sizeof(double *));
        pdblImg = (double **)MALLOC(iSize * sizeof(double *));
        iRet = readPolyComplexMatrix(_iDatasetId, pstVarName, 2, _pInfo->piDims, piNbCoef, pdblReal, pdblImg);
    }
    else
    {
        piNbCoef = (int *)MALLOC(iSize * sizeof(int));
        pdblReal = (double **)MALLOC(iSize * sizeof(double *));
        iRet = readPolyMatrix(_iDatasetId, pstVarName, 2, _pInfo->piDims, piNbCoef, pdblReal);
    }

    for (int i = 0 ; i < iSize ; i++)
    {
        _pInfo->iSize += piNbCoef[i] * 8 * (iComplex + 1);
        FREE(pdblReal[i]);
        if (iComplex)
        {
            FREE(pdblImg[i]);
        }
    }

    FREE(piNbCoef);
    FREE(pdblReal);
    if (iComplex)
    {
        FREE(pdblImg);
    }

    generateInfo(_pInfo, "polynomial");
    return true;
}
Esempio n. 13
0
static bool read_boolean(int dataset, VarInfo6& info)
{
    int complex = 0;
    int ret = getDatasetInfo(dataset, &complex, &info.dims, NULL);
    if (ret < 0)
    {
        closeDataSet(dataset);
        return false;
    }

    info.pdims.resize(info.dims);
    int size = getDatasetInfo(dataset, &complex, &info.dims, info.pdims.data());
    info.size = size * sizeof(int);

    generateInfo(info);
    closeDataSet(dataset);
    return true;
}
Esempio n. 14
0
static bool read_boolean_sparse(int dataset, VarInfo6& info)
{
    int complex = 0;
    std::vector<int> pdims;
    int size = getDimsNode(dataset, &complex, pdims);

    //get non zeros count
    int nnz = 0;
    int datannz = getDataSetIdFromName(dataset, "__nnz__");
    readInteger32Matrix(datannz, &nnz);

    info.dims = 2;
    info.pdims[0] = pdims[0];
    info.pdims[1] = pdims[1];
    //rows(int) + nnz(int)
    info.size = info.pdims[0] * sizeof(int) + nnz * sizeof(int);

    generateInfo(info);
    closeList6(dataset);
    return true;
}
Esempio n. 15
0
static bool read_list(int dataset, VarInfo6& info, std::string type)
{
    int ret = 0;
    int items = 0;

    ret = getListDims6(dataset, &items);
    if (ret)
    {
        return false;
    }

    info.dims = 1;
    info.pdims.resize(1);
    info.pdims[0] = items;
    info.size = 0;

    for (int i = 0; i < items; i++)
    {
        int data = getDataSetIdFromName(dataset, std::to_string(i).data());
        if (data <= 0)
        {
            closeList6(dataset);
            return false;
        }


        VarInfo6 info2;
        bool bRet = read_data(data, info2);
        if (bRet == false)
        {
            return false;
        }

        info.size += info2.size;
    }

    closeList6(dataset);
    generateInfo(info);
    return true;
}
Esempio n. 16
0
static bool read_integer(int dataset, VarInfo6& info)
{
    int complex = 0;
    int ret = getDatasetInfo(dataset, &complex, &info.dims, NULL);
    if (ret < 0)
    {
        closeDataSet(dataset);
        return false;
    }

    info.pdims.resize(info.dims);
    int size = getDatasetInfo(dataset, &complex, &info.dims, info.pdims.data());

    int prec = 0;
    getDatasetPrecision(dataset, &prec);

    info.size = size * (prec % 10);

    generateInfo(info);
    closeDataSet(dataset);
    return true;
}
Esempio n. 17
0
static bool read_struct(int dataset, VarInfo6& info)
{
    int complex = 0;
    int size = getDimsNode(dataset, &complex, info.pdims);
    info.dims = static_cast<int>(info.pdims.size());
    info.size = 0;

    if (size == 0)
    {
        generateInfo(info);
        closeList6(dataset);
        return true;
    }
    int fieldCount = 0;
    int ret = getListDims6(dataset, &fieldCount);
    if (ret < 0)
    {
        closeList6(dataset);
        return false;
    }

    //open __refs__ node
    int refs = getDataSetIdFromName(dataset, "__refs__");
    H5O_info_t oinfo;
    for (int i = 0; i < fieldCount; ++i)
    {
        H5Oget_info_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_NATIVE, i, &oinfo, H5P_DEFAULT);
        ssize_t len = H5Lget_name_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, i, 0, 0, H5P_DEFAULT) + 1;
        char* name = (char*)MALLOC(sizeof(char) * len);
        H5Lget_name_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, i, name, len, H5P_DEFAULT);
        std::string cname(name);
        FREE(name);

        if (cname != "__dims__" && cname != "__refs__")
        {
            int dataref = getDataSetIdFromName(dataset, cname.data());
            if (dataref < 0)
            {
                closeList6(dataset);
                return false;
            }

            int refdim = 0;
            getDatasetInfo(dataref, &complex, &refdim, NULL);
            std::vector<int> refdims(refdim);
            int refcount = getDatasetInfo(dataref, &complex, &refdim, refdims.data());
            std::vector<hobj_ref_t> vrefs(refcount);
            ret = H5Dread(dataref, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, vrefs.data());
            if (ret < 0)
            {
                return false;
            }


            //import field
            for (int j = 0; j < refcount; ++j)
            {
                int data = H5Rdereference(refs, H5R_OBJECT, &vrefs[j]);
                if (data < 0)
                {
                    return false;
                }

                VarInfo6 info2;
                ret = read_data(data, info2);
                if (ret == false)
                {
                    return false;
                }

                info.size += info2.size;

            }

            closeDataSet(dataref);
        }
    }

    generateInfo(info);
    closeList6(refs);
    closeList6(dataset);
    return true;
}
Esempio n. 18
0
static bool read_list(int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, VarInfo* _pInfo)
{
    int iRet = 0;
    int iItems = 0;
    int *piListAddr = NULL;
    hobj_ref_t *piItemRef = NULL;

    iRet = getListDims(_iDatasetId, &iItems);
    if (iRet)
    {
        return false;
    }

    if (iItems == 0)
    {
        //special case for empty list
    }
    else
    {
        iRet = getListItemReferences(_iDatasetId, &piItemRef);
        if (iRet)
        {
            return false;
        }
    }
    //_pInfo = (VarInfo*)MALLOC(sizeof(VarInfo));
    _pInfo->iDims = 1;
    _pInfo->piDims[0] = iItems;
    _pInfo->iSize = (2 + iItems + 1) * 4;

    for (int i = 0; i < iItems; i++)
    {
        int iItemDataset = 0;

        iRet = getListItemDataset(_iDatasetId, piItemRef, i, &iItemDataset);
        if (iRet || iItemDataset == 0)
        {
            return false;
        }
        VarInfo info;
        bool bRet = read_data(iItemDataset, i + 1, piListAddr, &info);
        if (bRet == false)
        {
            return false;
        }

        _pInfo->iSize += info.iSize;
    }

    if (_iVarType == sci_list)
    {
        generateInfo(_pInfo, "list");
    }
    else if (_iVarType == sci_tlist)
    {
        generateInfo(_pInfo, "tlist");
    }
    else if (_iVarType == sci_mlist)
    {
        generateInfo(_pInfo, "mlist");
    }

    iRet = deleteListItemReferences(_iDatasetId, piItemRef);
    if (iRet)
    {
        return false;
    }


    return true;
}
Esempio n. 19
0
void drowGame(Board board) {
	int x = 200;
	int y = 100;
	int moveY = 0;
	int temp = 0;

    SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
    SDL_RenderClear(gRenderer);
    gSceneTexture.render(0, 0);

    if (gPtrHelp == NULL)
    {

        for (int i = 0; i < NUMBER_OF_BUTTON; ++i) {
            if(i == 3)
            {
                gButton[i].setPosition(760, 5);
            }
            else
            {
                gButton[i].setPosition(650, 50 + 40 * i);
            }
            gButton[i].renderButton();
        }

        if (board.isStarted())
        {
            for (int i = 0; i < 5; ++i) {
                for (int j = 0; j < 6; ++j) {
                    if (!board.pile[i][j].empty()) {
                        temp = takeID(board.pile[i][j].top().getFace());
                        gTile[temp].setFace(board.pile[i][j].top().getFace());
                        gTile[temp].setBlocked(!board.pile[i][j].top().getBlocked());
                        gTile[temp].coordinates.i = i;
                        gTile[temp].coordinates.j = j;
                        moveY = 0;
                        for (size_t z = 0; z < board.pile[i][j].size(); z++){
                            gTile[temp].setPosition(x, y + moveY);
                            gTile[temp].renderButton();
                            moveY -= 3;
                        }
                    }
                    x += gTile[temp].getWidth();
                }
                y += (gTile[temp].getHeight()+4);
                x = 200;
            }
        }
        if(gameOver)
        {
            gGameOver.render((SCREEN_WIDTH - gGameOver.getWidth())/2, (SCREEN_HEIGHT - gGameOver.getHeight())/2);
        }
        if(youWin)
        {
            gYouWin.render((SCREEN_WIDTH - gGameOver.getWidth())/2, (SCREEN_HEIGHT - gGameOver.getHeight())/2);
        }
        if(youLose)
        {
            gYouLose.render((SCREEN_WIDTH - gGameOver.getWidth())/2, (SCREEN_HEIGHT - gGameOver.getHeight())/2);
        }
    }
    else
    {
        gPtrHelp->render(25, 50);
        gButton[2].setPosition(25 + gPtrHelp->getWidth() / 2 - gButton[2].getWidth() / 2, gPtrHelp->getHeight());
        gButton[2].renderButton();
        gButton[3].setPosition(760, 5);
        gButton[3].renderButton();
    }

    markSelectedTile();

    generateTime();
    wordTime.render(20, 550);

    generateMoves();
    wordMoves.render(20, 530);

    generateMatches();
    wordMatches.render(20, 510);

    generateCredits();
    wordCredits.render(630, 470);

    generateInfo();
    wordAllGame.render(630, 490);
    wordWinGame.render(630, 510);
    wordLoseGame.render(630, 530);
    wordWinRateGame.render(630, 550);

    firstAnimation_1.renderAnimation();
    secondAnimation_1.renderAnimation();
    firstAnimation_2.renderAnimation();
    secondAnimation_2.renderAnimation();
    firstAnimation_3.renderAnimation();
    secondAnimation_3.renderAnimation();
    winAnimation.renderAnimation();

    SDL_RenderPresent(gRenderer);
}