示例#1
0
MERROR
UsersManager::
MyUserGraph::
getInUsers(size_t userId, android::Vector<android::sp<MyUser> >& result) const
{
    result.clear();
    UserNode const& usr = mUserVector.valueFor(userId);
    for (size_t i = 0; i < usr.mIn.size(); i++)
    {
        result.add(mUserVector.valueFor(usr.mIn.itemAt(i)).mMyUser);
    }
    return OK;
}
示例#2
0
MERROR
UsersManager::
MyUserGraph::
DFS(size_t userId, android::Vector<android::sp<MyUser> >& result) const
{
    ssize_t const idx = mUserVector.indexOfKey(userId);
    for (size_t i = 0; i < mUserVector.valueAt(idx).mIn.size(); i++)
    {
        if  ( 0 > DFS(mUserVector.valueAt(idx).mIn.itemAt(i), result) )
        {
            return UNKNOWN_ERROR;
        }
    }
    result.add(mUserVector.valueAt(idx).mMyUser);
    return OK;
}
status_t CameraArea::parseAreas(const char *area,
                                size_t areaLength,
                                android::Vector<android::sp<CameraArea> > &areas)
{
    status_t ret = NO_ERROR;
    char *ctx;
    char *pArea = NULL;
    char *pStart = NULL;
    char *pEnd = NULL;
    const char *startToken = "(";
    const char endToken = ')';
    const char sep = ',';
    ssize_t top, left, bottom, right, weight;
    char *tmpBuffer = NULL;
    android::sp<CameraArea> currentArea;

    LOG_FUNCTION_NAME

    if ( ( NULL == area ) ||
         ( 0 >= areaLength ) )
        {
        return -EINVAL;
        }

    tmpBuffer = ( char * ) malloc(areaLength);
    if ( NULL == tmpBuffer )
        {
        return -ENOMEM;
        }

    memcpy(tmpBuffer, area, areaLength);

    pArea = strtok_r(tmpBuffer, startToken, &ctx);

    do
        {

        pStart = pArea;
        if ( NULL == pStart )
            {
            CAMHAL_LOGEA("Parsing of the left area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            left = static_cast<ssize_t>(strtol(pStart, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the top area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            top = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the right area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            right = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the bottom area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            bottom = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the weight area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            weight = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( endToken != *pEnd )
            {
            CAMHAL_LOGEA("Malformed area!");
            ret = -EINVAL;
            break;
            }

        ret = checkArea(top, left, bottom, right, weight);
        if ( NO_ERROR != ret ) {
            break;
        }

        currentArea = new CameraArea(top, left, bottom, right, weight);
        CAMHAL_LOGDB("Area parsed [%dx%d, %dx%d] %d",
                     ( int ) top,
                     ( int ) left,
                     ( int ) bottom,
                     ( int ) right,
                     ( int ) weight);
        if ( NULL != currentArea.get() )
            {
            areas.add(currentArea);
            }
        else
            {
            ret = -ENOMEM;
            break;
            }

        pArea = strtok_r(NULL, startToken, &ctx);

        }
    while ( NULL != pArea );

    if ( NULL != tmpBuffer )
        {
        free(tmpBuffer);
        }

    LOG_FUNCTION_NAME_EXIT

    return ret;
}