IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7500


Ignore:
Timestamp:
Jun 9, 2006, 6:22:07 PM (20 years ago)
Author:
jhoblitt
Message:

rel-0_0_02

Location:
branches/jhoblitt/ippdb
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/jhoblitt/ippdb/src/ippdb.c

    r7460 r7500  
    1052910529static void detRunRowFree(detRunRow *object);
    1053010530
    10531 detRunRow *detRunRowAlloc(const char *det_type)
     10531detRunRow *detRunRowAlloc(const char *det_type, psS32 iteration)
    1053210532{
    1053310533    detRunRow       *object;
     
    1053710537
    1053810538    object->det_type = psStringCopy(det_type);
     10539    object->iteration = iteration;
    1053910540
    1054010541    return object;
     
    1056210563        return false;
    1056310564    }
     10565    if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, 0)) {
     10566        psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     10567        psFree(md);
     10568        return false;
     10569    }
    1056410570
    1056510571    status = psDBCreateTable(dbh, DETRUN_TABLE_NAME, md);
     
    1057510581}
    1057610582
    10577 bool detRunInsert(psDB * dbh, const char *det_type)
     10583bool detRunInsert(psDB * dbh, const char *det_type, psS32 iteration)
    1057810584{
    1057910585    psMetadata      *md;
     
    1058610592        return false;
    1058710593    }
     10594    if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, iteration)) {
     10595        psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     10596        psFree(md);
     10597        return false;
     10598    }
    1058810599
    1058910600    status = psDBInsertOneRow(dbh, DETRUN_TABLE_NAME, md);
     
    1059310604}
    1059410605
    10595 bool detRunPop(psDB *dbh, char **det_type)
     10606bool detRunPop(psDB *dbh, char **det_type, psS32 *iteration)
    1059610607{
    1059710608    psArray         *rowSet;
     
    1064310654        return false;
    1064410655    }
     10656    *iteration = psMetadataLookupS32(&status, row, "iteration");
     10657    if (!status) {
     10658        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item iteration");
     10659        psFree(row);
     10660        return false;
     10661    }
    1064510662
    1064610663    psFree(row);
     
    1065110668bool detRunInsertObject(psDB *dbh, detRunRow *object)
    1065210669{
    10653     return detRunInsert(dbh, object->det_type);
     10670    return detRunInsert(dbh, object->det_type, object->iteration);
    1065410671}
    1065510672
     
    1065710674{
    1065810675    char            det_type[256];
    10659 
    10660     if (!detRunPop(dbh, (char **)&det_type)) {
     10676    psS32           iteration;
     10677
     10678    if (!detRunPop(dbh, (char **)&det_type, &iteration)) {
    1066110679        psError(PS_ERR_UNKNOWN, false, "failed to pop a database row");
    1066210680        return NULL;
    1066310681    }
    1066410682
    10665     return detRunRowAlloc(det_type);
     10683    return detRunRowAlloc(det_type, iteration);
    1066610684}
    1066710685
     
    1076710785        return NULL;
    1076810786    }
     10787    if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, object->iteration)) {
     10788        psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     10789        psFree(md);
     10790        return NULL;
     10791    }
    1076910792
    1077010793    return md;
     
    1077510798    bool            status;
    1077610799    char            *det_type;
     10800    psS32           iteration;
    1077710801
    1077810802    det_type = psMetadataLookupPtr(&status, md, "det_type");
     
    1078110805        return false;
    1078210806    }
    10783 
    10784     return detRunRowAlloc(det_type);
     10807    iteration = psMetadataLookupS32(&status, md, "iteration");
     10808    if (!status) {
     10809        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item iteration");
     10810        return false;
     10811    }
     10812
     10813    return detRunRowAlloc(det_type, iteration);
    1078510814}
    1078610815psArray *detRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
  • branches/jhoblitt/ippdb/src/ippdb.h

    r7460 r7500  
    42084208typedef struct {
    42094209    char            *det_type;
     4210    psS32           iteration;
    42104211} detRunRow;
    42114212
     
    42164217
    42174218detRunRow *detRunRowAlloc(
    4218     const char      *det_type
     4219    const char      *det_type,
     4220    psS32           iteration
    42194221);
    42204222
     
    42464248bool detRunInsert(
    42474249    psDB            *dbh,               ///< Database handle
    4248     const char      *det_type
     4250    const char      *det_type,
     4251    psS32           iteration
    42494252);
    42504253
     
    42564259bool detRunPop(
    42574260    psDB            *dbh,               ///< Database handle
    4258     char            **det_type
     4261    char            **det_type,
     4262    psS32           *iteration
    42594263);
    42604264
  • branches/jhoblitt/ippdb/tests/alloc.c

    r7460 r7500  
    880880        detRunRow       *object;
    881881
    882         object = detRunRowAlloc("a string"    );
     882        object = detRunRowAlloc("a string", -32    );
    883883
    884884        if (!object) {
     
    887887
    888888        if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) {
     889            psFree(object);
     890            exit(EXIT_FAILURE);
     891        }
     892        if (!object->iteration == -32) {
    889893            psFree(object);
    890894            exit(EXIT_FAILURE);
  • branches/jhoblitt/ippdb/tests/insert.c

    r7460 r7500  
    343343        }
    344344
    345         if (!detRunInsert(dbh, "a string")) {
     345        if (!detRunInsert(dbh, "a string", -32)) {
    346346            exit(EXIT_FAILURE);
    347347        }
  • branches/jhoblitt/ippdb/tests/insertobject.c

    r7460 r7500  
    498498        }
    499499
    500         object = detRunRowAlloc("a string");
     500        object = detRunRowAlloc("a string", -32);
    501501        if (!object) {
    502502            exit(EXIT_FAILURE);
  • branches/jhoblitt/ippdb/tests/metadatafromobject.c

    r7460 r7500  
    10591059        bool            status;
    10601060
    1061         object = detRunRowAlloc("a string");
     1061        object = detRunRowAlloc("a string", -32);
    10621062        if (!object) {
    10631063            exit(EXIT_FAILURE);
     
    10721072
    10731073        if (strncmp(psMetadataLookupPtr(&status, md, "det_type"), "a string", MAX_STRING_LENGTH)) {
     1074            psFree(md);
     1075            exit(EXIT_FAILURE);
     1076        }
     1077        if (!psMetadataLookupS32(&status, md, "iteration") == -32) {
    10741078            psFree(md);
    10751079            exit(EXIT_FAILURE);
  • branches/jhoblitt/ippdb/tests/objectfrommetadata.c

    r7460 r7500  
    15811581            exit(EXIT_FAILURE);
    15821582        }
     1583        if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, -32)) {
     1584            psFree(md);
     1585            exit(EXIT_FAILURE);
     1586        }
    15831587
    15841588        object = detRunObjectFromMetadata(md);
     
    15911595
    15921596        if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) {
     1597            psFree(object);
     1598            exit(EXIT_FAILURE);
     1599        }
     1600        if (!object->iteration == -32) {
    15931601            psFree(object);
    15941602            exit(EXIT_FAILURE);
  • branches/jhoblitt/ippdb/tests/pop.c

    r7460 r7500  
    484484        psDB            *dbh;
    485485        char            det_type[256];
    486 
    487         dbh = psDBInit("localhost", "test", NULL, "test");
    488         if (!dbh) {
    489             exit(EXIT_FAILURE);
    490         }
    491 
    492         if (!detRunPop(dbh, (char **)&det_type)) {
     486        psS32           iteration;
     487
     488        dbh = psDBInit("localhost", "test", NULL, "test");
     489        if (!dbh) {
     490            exit(EXIT_FAILURE);
     491        }
     492
     493        if (!detRunPop(dbh, (char **)&det_type, &iteration)) {
    493494            exit(EXIT_FAILURE);
    494495        }
Note: See TracChangeset for help on using the changeset viewer.