IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8368 for trunk/ippdb/src


Ignore:
Timestamp:
Aug 15, 2006, 4:31:35 PM (20 years ago)
Author:
jhoblitt
Message:

VERSION 0.0.29

Location:
trunk/ippdb/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippdb/src/ippdb.c

    r8325 r8368  
    5656#define DETSTACKEDIMFILE_TABLE_NAME "detStackedImfile"
    5757#define DETSTACKEDIMFILE_INDEX_NAME IPPDB_DEFAULT_INDEX_NAME
     58#define DETNORMALIZEDSTATIMFILE_TABLE_NAME "detNormalizedStatImfile"
     59#define DETNORMALIZEDSTATIMFILE_INDEX_NAME IPPDB_DEFAULT_INDEX_NAME
    5860#define DETNORMALIZEDIMFILE_TABLE_NAME "detNormalizedImfile"
    5961#define DETNORMALIZEDIMFILE_INDEX_NAME IPPDB_DEFAULT_INDEX_NAME
     
    1458314585    return true;
    1458414586}
     14587static void detNormalizedStatImfileRowFree(detNormalizedStatImfileRow *object);
     14588
     14589detNormalizedStatImfileRow *detNormalizedStatImfileRowAlloc(psS32 det_id, psS32 iteration, const char *class_id, psF32 norm)
     14590{
     14591    detNormalizedStatImfileRow *object;
     14592
     14593    object = psAlloc(sizeof(detNormalizedStatImfileRow));
     14594    psMemSetDeallocator(object, (psFreeFunc)detNormalizedStatImfileRowFree);
     14595
     14596    object->det_id = det_id;
     14597    object->iteration = iteration;
     14598    object->class_id = psStringCopy(class_id);
     14599    object->norm = norm;
     14600
     14601    return object;
     14602}
     14603
     14604static void detNormalizedStatImfileRowFree(detNormalizedStatImfileRow *object)
     14605{
     14606    psFree(object->class_id);
     14607}
     14608
     14609bool detNormalizedStatImfileCreateTable(psDB *dbh)
     14610{
     14611    psMetadata      *md;
     14612    bool            status;
     14613
     14614    md = psMetadataAlloc();
     14615    if (!psMetadataAdd(md, PS_LIST_TAIL, DETNORMALIZEDSTATIMFILE_INDEX_NAME, PS_DATA_S32, "AUTO_INCREMENT", 0.0)) {
     14616        psError(PS_ERR_UNKNOWN, false, "failed to add item %s", DETNORMALIZEDSTATIMFILE_INDEX_NAME);
     14617        psFree(md);
     14618        return false;
     14619    }
     14620    if (!psMetadataAddS32(md, PS_LIST_TAIL, "det_id", 0, "Primary Key", 0)) {
     14621        psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
     14622        psFree(md);
     14623        return false;
     14624    }
     14625    if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, "Primary Key", 0)) {
     14626        psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     14627        psFree(md);
     14628        return false;
     14629    }
     14630    if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, "Primary Key", "64")) {
     14631        psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     14632        psFree(md);
     14633        return false;
     14634    }
     14635    if (!psMetadataAddF32(md, PS_LIST_TAIL, "norm", 0, NULL, 0.0)) {
     14636        psError(PS_ERR_UNKNOWN, false, "failed to add item norm");
     14637        psFree(md);
     14638        return false;
     14639    }
     14640
     14641    status = psDBCreateTable(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, md);
     14642
     14643    psFree(md);
     14644
     14645    return status;
     14646}
     14647
     14648bool detNormalizedStatImfileDropTable(psDB *dbh)
     14649{
     14650    return psDBDropTable(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME);
     14651}
     14652
     14653bool detNormalizedStatImfileInsert(psDB * dbh, psS32 det_id, psS32 iteration, const char *class_id, psF32 norm)
     14654{
     14655    psMetadata      *md;
     14656    bool            status;
     14657
     14658    md = psMetadataAlloc();
     14659    if (!psMetadataAddS32(md, PS_LIST_TAIL, "det_id", 0, NULL, det_id)) {
     14660        psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
     14661        psFree(md);
     14662        return false;
     14663    }
     14664    if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, iteration)) {
     14665        psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     14666        psFree(md);
     14667        return false;
     14668    }
     14669    if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, class_id)) {
     14670        psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     14671        psFree(md);
     14672        return false;
     14673    }
     14674    if (!psMetadataAddF32(md, PS_LIST_TAIL, "norm", 0, NULL, norm)) {
     14675        psError(PS_ERR_UNKNOWN, false, "failed to add item norm");
     14676        psFree(md);
     14677        return false;
     14678    }
     14679
     14680    status = psDBInsertOneRow(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, md);
     14681    psFree(md);
     14682
     14683    return status;
     14684}
     14685
     14686long long detNormalizedStatImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)
     14687{
     14688    long long       deleted = 0;
     14689
     14690    long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, limit);
     14691    if (count < 0) {
     14692        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile");
     14693        return count;
     14694
     14695        deleted += count;
     14696    }
     14697
     14698    return deleted;
     14699}
     14700bool detNormalizedStatImfilePop(psDB *dbh, psS32 *det_id, psS32 *iteration, char **class_id, psF32 *norm)
     14701{
     14702    psArray         *rowSet;
     14703    psMetadata      *row;
     14704    psMetadata      *popped;
     14705    long            deleted;
     14706    bool            status;
     14707    int             rowID;
     14708
     14709    rowSet = psDBSelectRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, NULL, 1);
     14710    if (!rowSet) {
     14711        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item %s", DETNORMALIZEDSTATIMFILE_INDEX_NAME);
     14712        psFree(rowSet);
     14713        return NULL;
     14714    }
     14715
     14716    row = psArrayGet(rowSet, 0);
     14717    psMemIncrRefCounter(row);
     14718    if (!row) {
     14719        psError(PS_ERR_UNKNOWN, true, "database error or table is empty");
     14720        return NULL;
     14721    }
     14722    psFree(rowSet);
     14723
     14724    rowID = psMetadataLookupS32(&status, row, DETNORMALIZEDSTATIMFILE_INDEX_NAME);
     14725    if (!status) {
     14726        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item %s", DETNORMALIZEDSTATIMFILE_INDEX_NAME);
     14727        psFree(row);
     14728        return NULL;
     14729    }
     14730
     14731    popped = psMetadataAlloc();
     14732    psMetadataAddS32(popped, PS_LIST_TAIL, DETNORMALIZEDSTATIMFILE_INDEX_NAME, 0, NULL, rowID);
     14733
     14734    deleted = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, popped, 0);
     14735    if (deleted != 1) {
     14736        psError(PS_ERR_UNKNOWN, false, "database failed to delete row");
     14737        psFree(popped);
     14738        psFree(row);
     14739        return NULL;
     14740    }
     14741
     14742    psFree(popped);
     14743
     14744    *det_id = psMetadataLookupS32(&status, row, "det_id");
     14745    if (!status) {
     14746        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item det_id");
     14747        psFree(row);
     14748        return false;
     14749    }
     14750    *iteration = psMetadataLookupS32(&status, row, "iteration");
     14751    if (!status) {
     14752        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item iteration");
     14753        psFree(row);
     14754        return false;
     14755    }
     14756    *class_id = psMetadataLookupPtr(&status, row, "class_id");
     14757    if (!status) {
     14758        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id");
     14759        psFree(row);
     14760        return false;
     14761    }
     14762    *norm = psMetadataLookupF32(&status, row, "norm");
     14763    if (!status) {
     14764        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item norm");
     14765        psFree(row);
     14766        return false;
     14767    }
     14768
     14769    psFree(row);
     14770
     14771    return true;
     14772}
     14773
     14774bool detNormalizedStatImfileInsertObject(psDB *dbh, detNormalizedStatImfileRow *object)
     14775{
     14776    return detNormalizedStatImfileInsert(dbh, object->det_id, object->iteration, object->class_id, object->norm);
     14777}
     14778
     14779bool detNormalizedStatImfileInsertObjects(psDB *dbh, psArray *objects)
     14780{
     14781    for (long i = 0; i < psArrayLength(objects); i++) {
     14782        if (!detNormalizedStatImfileInsertObject(dbh, objects->data[i])) {
     14783            return false;
     14784        }
     14785    }
     14786
     14787    return true;
     14788}
     14789
     14790detNormalizedStatImfileRow *detNormalizedStatImfilePopObject(psDB *dbh)
     14791{
     14792    psS32           det_id;
     14793    psS32           iteration;
     14794    char            class_id[256];
     14795    psF32           norm;
     14796
     14797    if (!detNormalizedStatImfilePop(dbh, &det_id, &iteration, (char **)&class_id, &norm)) {
     14798        psError(PS_ERR_UNKNOWN, false, "failed to pop a database row");
     14799        return NULL;
     14800    }
     14801
     14802    return detNormalizedStatImfileRowAlloc(det_id, iteration, class_id, norm);
     14803}
     14804
     14805bool detNormalizedStatImfileInsertFits(psDB *dbh, const psFits *fits)
     14806{
     14807    psArray         *rowSet;
     14808
     14809    // move to (the first?) extension named  DETNORMALIZEDSTATIMFILE_TABLE_NAME
     14810    if (!psFitsMoveExtName(fits, DETNORMALIZEDSTATIMFILE_TABLE_NAME)) {
     14811        psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", DETNORMALIZEDSTATIMFILE_TABLE_NAME);
     14812        return false;
     14813    }
     14814
     14815    // check HDU type
     14816    if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE)  {
     14817        psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE");
     14818        return false;
     14819    }
     14820
     14821    // read fits table
     14822    rowSet = psFitsReadTable(fits);
     14823    if (!rowSet) {
     14824        psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty");
     14825        psFree(rowSet);
     14826        return false;
     14827    }
     14828
     14829    if (!psDBInsertRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, rowSet)) {
     14830        psError(PS_ERR_UNKNOWN, false, "databse insert failed");
     14831        psFree(rowSet);
     14832        return false;
     14833    }
     14834
     14835    psFree(rowSet);
     14836
     14837    return true;
     14838}
     14839
     14840bool detNormalizedStatImfilePopFits(psDB *dbh, psFits *fits, unsigned long long limit)
     14841{
     14842    char            query[MAX_STRING_LENGTH];
     14843
     14844    if (!detNormalizedStatImfileSelectRowsFits(dbh, fits, NULL, limit)) {
     14845        psError(PS_ERR_UNKNOWN, true, "database error or table is empty");
     14846        return false;
     14847    }
     14848
     14849    // remove limit rows from the end of the database
     14850    if (snprintf(query, MAX_STRING_LENGTH,
     14851                "DELETE FROM %s ORDER BY %s DESC LIMIT %lld",
     14852                DETNORMALIZEDSTATIMFILE_TABLE_NAME, DETNORMALIZEDSTATIMFILE_INDEX_NAME, limit) < 0) {
     14853        psError(PS_ERR_UNKNOWN, true, "query value attempted to exceed %s bytes", MAX_STRING_LENGTH);
     14854        return false;
     14855    }
     14856           
     14857    if (!p_psDBRunQuery(dbh, query)) {
     14858        psError(PS_ERR_UNKNOWN, false, "database query failed");
     14859        return false;
     14860    }
     14861
     14862    return true;
     14863}
     14864
     14865bool detNormalizedStatImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)
     14866{
     14867    psArray         *rowSet;
     14868    psU64           i;
     14869
     14870    rowSet = psDBSelectRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, limit);
     14871    if (!rowSet) {
     14872        return false;
     14873    }
     14874
     14875    // strip index column
     14876    for (i = 0; i < rowSet->n; i++) {
     14877        if (!psMetadataRemove((psMetadata *)rowSet->data[i], 0, DETNORMALIZEDSTATIMFILE_INDEX_NAME)) {
     14878            psError(PS_ERR_UNKNOWN, true, "failed to remove item %s", DETNORMALIZEDSTATIMFILE_INDEX_NAME);
     14879            psFree(rowSet);
     14880            return false;
     14881        }
     14882    }
     14883
     14884    // output to fits
     14885    if (!psFitsWriteTable(fits, NULL, rowSet, DETNORMALIZEDSTATIMFILE_TABLE_NAME)) {
     14886        psError(PS_ERR_UNKNOWN, false, "FITS table write failed");
     14887        psFree(rowSet);
     14888        return false;
     14889    }
     14890
     14891    psFree(rowSet);
     14892
     14893    return true;
     14894}
     14895
     14896psMetadata *detNormalizedStatImfileMetadataFromObject(const detNormalizedStatImfileRow *object)
     14897{
     14898    psMetadata      *md;
     14899
     14900    md = psMetadataAlloc();
     14901    if (!psMetadataAddS32(md, PS_LIST_TAIL, "det_id", 0, NULL, object->det_id)) {
     14902        psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
     14903        psFree(md);
     14904        return NULL;
     14905    }
     14906    if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, object->iteration)) {
     14907        psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     14908        psFree(md);
     14909        return NULL;
     14910    }
     14911    if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, object->class_id)) {
     14912        psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     14913        psFree(md);
     14914        return NULL;
     14915    }
     14916    if (!psMetadataAddF32(md, PS_LIST_TAIL, "norm", 0, NULL, object->norm)) {
     14917        psError(PS_ERR_UNKNOWN, false, "failed to add item norm");
     14918        psFree(md);
     14919        return NULL;
     14920    }
     14921
     14922    return md;
     14923}
     14924
     14925detNormalizedStatImfileRow *detNormalizedStatImfileObjectFromMetadata(psMetadata *md)
     14926{
     14927    bool            status;
     14928    psS32           det_id;
     14929    psS32           iteration;
     14930    char            *class_id;
     14931    psF32           norm;
     14932
     14933    det_id = psMetadataLookupS32(&status, md, "det_id");
     14934    if (!status) {
     14935        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item det_id");
     14936        return false;
     14937    }
     14938    iteration = psMetadataLookupS32(&status, md, "iteration");
     14939    if (!status) {
     14940        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item iteration");
     14941        return false;
     14942    }
     14943    class_id = psMetadataLookupPtr(&status, md, "class_id");
     14944    if (!status) {
     14945        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id");
     14946        return false;
     14947    }
     14948    norm = psMetadataLookupF32(&status, md, "norm");
     14949    if (!status) {
     14950        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item norm");
     14951        return false;
     14952    }
     14953
     14954    return detNormalizedStatImfileRowAlloc(det_id, iteration, class_id, norm);
     14955}
     14956psArray *detNormalizedStatImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
     14957{
     14958    psArray         *rowSet;
     14959    psArray         *returnSet;
     14960    psU64           i;
     14961
     14962    rowSet = psDBSelectRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, limit);
     14963    if (!rowSet) {
     14964        return NULL;
     14965    }
     14966
     14967    // strip index column
     14968    for (i = 0; i < rowSet->n; i++) {
     14969        if (!psMetadataRemove((psMetadata *)(rowSet->data[i]), 0, DETNORMALIZEDSTATIMFILE_INDEX_NAME)) {
     14970            psError(PS_ERR_UNKNOWN, true, "failed to remove item %s", DETNORMALIZEDSTATIMFILE_INDEX_NAME);
     14971            psFree(rowSet);
     14972            return false;
     14973        }
     14974    }
     14975
     14976    // convert psMetadata rows to row objects
     14977
     14978    returnSet = psArrayAlloc(rowSet->n);
     14979    returnSet->n = 0;
     14980
     14981    for (i = 0; i < rowSet->n; i++) {
     14982        detNormalizedStatImfileRow *object = detNormalizedStatImfileObjectFromMetadata(rowSet->data[i]);
     14983        psArrayAdd(returnSet, 0, object);
     14984        psFree(object);
     14985    }
     14986
     14987    psFree(rowSet);
     14988
     14989    return returnSet;
     14990}
     14991bool detNormalizedStatImfileDeleteObject(psDB *dbh, const detNormalizedStatImfileRow *object)
     14992{
     14993    psMetadata *where = detNormalizedStatImfileMetadataFromObject(object);
     14994    long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, 0);
     14995    psFree(where)
     14996    if (count < 0) {
     14997        psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile");
     14998        return false;
     14999    }
     15000    if (count > 1) {
     15001        // XXX should this be a psAbort() instead?  It is possible that
     15002        // having an object match multiple rows was by design.
     15003        psError(PS_ERR_UNKNOWN, true, "detNormalizedStatImfileRow object matched more then one row.  Check your database schema");
     15004        return false;
     15005    }
     15006
     15007    return true;
     15008}
     15009long long detNormalizedStatImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
     15010{
     15011    long long       deleted = 0;
     15012
     15013    for (long long i = 0; i < objects->n; i++) {
     15014        detNormalizedStatImfileRow *object = objects->data[i];
     15015        psMetadata *where = detNormalizedStatImfileMetadataFromObject(object);
     15016        long long count = psDBDeleteRows(dbh, DETNORMALIZEDSTATIMFILE_TABLE_NAME, where, limit);
     15017        psFree(where)
     15018        if (count < 0) {
     15019            psError(PS_ERR_UNKNOWN, true, "failed to delete row from detNormalizedStatImfile");
     15020            return count;
     15021        }
     15022
     15023        deleted += count;
     15024    }
     15025
     15026    return deleted;
     15027}
     15028bool detNormalizedStatImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)
     15029{
     15030    PS_ASSERT_PTR_NON_NULL(objects, false);
     15031
     15032    psMetadata *output = psMetadataAlloc();
     15033    for (long i = 0; i < psArrayLength(objects); i++) {
     15034        psMetadata *md = detNormalizedStatImfileMetadataFromObject(objects->data[i]);
     15035        if (!psMetadataAddMetadata(
     15036            output,
     15037            PS_LIST_TAIL,
     15038            DETNORMALIZEDSTATIMFILE_TABLE_NAME,
     15039            PS_META_DUPLICATE_OK,
     15040            NULL,
     15041            md
     15042        )) {
     15043            psError(PS_ERR_UNKNOWN, false, "failed to add metadata");
     15044            psFree(md);
     15045            psFree(output);
     15046            return false;
     15047        }
     15048        psFree(md);
     15049    }
     15050
     15051    if (!ippdbPrintMetadataRaw(stream, output, mdcf)) {
     15052        psError(PS_ERR_UNKNOWN, false, "failed to print metadata");
     15053        psFree(output);
     15054    }
     15055    psFree(output);
     15056
     15057    return true;
     15058}
    1458515059static void detNormalizedImfileRowFree(detNormalizedImfileRow *object);
    1458615060
  • trunk/ippdb/src/ippdb.h

    r8325 r8368  
    62796279    bool            mdcf                ///< format as mdconfig or simple
    62806280);
     6281/** detNormalizedStatImfileRow data structure
     6282 *
     6283 * Structure for representing a single row of detNormalizedStatImfile table data.
     6284 */
     6285
     6286typedef struct {
     6287    psS32           det_id;
     6288    psS32           iteration;
     6289    char            *class_id;
     6290    psF32           norm;
     6291} detNormalizedStatImfileRow;
     6292
     6293/** Creates a new detNormalizedStatImfileRow object
     6294 *
     6295 *  @return A new detNormalizedStatImfileRow object or NULL on failure.
     6296 */
     6297
     6298detNormalizedStatImfileRow *detNormalizedStatImfileRowAlloc(
     6299    psS32           det_id,
     6300    psS32           iteration,
     6301    const char      *class_id,
     6302    psF32           norm
     6303);
     6304
     6305/** Creates a new detNormalizedStatImfile table
     6306 *
     6307 * @return true on success
     6308 */
     6309
     6310bool detNormalizedStatImfileCreateTable(
     6311    psDB            *dbh                ///< Database handle
     6312);
     6313
     6314/** Deletes a detNormalizedStatImfile table
     6315 *
     6316 * @return true on success
     6317 */
     6318
     6319bool detNormalizedStatImfileDropTable(
     6320    psDB            *dbh                ///< Database handle
     6321);
     6322
     6323/** Insert a single row into a table
     6324 *
     6325 * This function constructs and inserts a single row based on it's parameters.
     6326 *
     6327 * @return true on success
     6328 */
     6329
     6330bool detNormalizedStatImfileInsert(
     6331    psDB            *dbh,               ///< Database handle
     6332    psS32           det_id,
     6333    psS32           iteration,
     6334    const char      *class_id,
     6335    psF32           norm
     6336);
     6337
     6338/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     6339 *
     6340 * @return A The number of rows removed or a negative value on error
     6341 */
     6342
     6343long long detNormalizedStatImfileDelete(
     6344    psDB            *dbh,               ///< Database handle
     6345    const psMetadata *where,            ///< Row match criteria
     6346    unsigned long long limit            ///< Maximum number of elements to delete
     6347);
     6348
     6349/** Removes the last row from the database and returns it
     6350 *
     6351 * @return true on success
     6352 */
     6353
     6354bool detNormalizedStatImfilePop(
     6355    psDB            *dbh,               ///< Database handle
     6356    psS32           *det_id,
     6357    psS32           *iteration,
     6358    char            **class_id,
     6359    psF32           *norm
     6360);
     6361
     6362/** Insert a single detNormalizedStatImfileRow object into a table
     6363 *
     6364 * This function constructs and inserts a single row based on it's parameters.
     6365 *
     6366 * @return true on success
     6367 */
     6368
     6369bool detNormalizedStatImfileInsertObject(
     6370    psDB            *dbh,               ///< Database handle
     6371    detNormalizedStatImfileRow *object             ///< detNormalizedStatImfileRow object
     6372);
     6373
     6374/** Insert an array of detNormalizedStatImfileRow object into a table
     6375 *
     6376 * This function constructs and inserts multiple rows based on it's parameters.
     6377 *
     6378 * @return true on success
     6379 */
     6380
     6381bool detNormalizedStatImfileInsertObjects(
     6382    psDB            *dbh,               ///< Database handle
     6383    psArray         *objects            ///< array of detNormalizedStatImfileRow objects
     6384);
     6385
     6386/** Removes the last row from the database and returns it
     6387 *
     6388 * @return A new detNormalizedStatImfileRow on success or NULL on failure.
     6389 */
     6390
     6391detNormalizedStatImfileRow *detNormalizedStatImfilePopObject(
     6392    psDB            *dbh                ///< Database handle
     6393);
     6394
     6395/** Insert data from a binary FITS table detNormalizedStatImfileRow into the database
     6396 *
     6397 * This function expects a psFits object with a FITS table as the first
     6398 * extension.  The table must have at least one row of data in it, that is of
     6399 * the appropriate format (number of columns and their type).  All other
     6400 * extensions are ignored.
     6401 *
     6402 * @return true on success
     6403 */
     6404
     6405bool detNormalizedStatImfileInsertFits(
     6406    psDB            *dbh,               ///< Database handle
     6407    const psFits    *fits               ///< psFits object
     6408);
     6409
     6410/** Removes the last limit row from the database and returns them in a binary FITS table.
     6411 *
     6412 * This function assumes an empty psFits object and will create a FITS table as
     6413 * the first extension.
     6414 *
     6415 * @return true on success
     6416 */
     6417
     6418bool detNormalizedStatImfilePopFits(
     6419    psDB            *dbh,               ///< Database handle
     6420    psFits          *fits,              ///< psFits object
     6421    unsigned long long limit            ///< Maximum number of elements to return
     6422);
     6423
     6424/** Selects up to limit from the database and returns them in a binary FITS table
     6425 *
     6426 * This function assumes an empty psFits object and will create a FITS table
     6427 * as the first extension.
     6428 *
     6429 *  See psDBSelectRows() for documentation on the format of where.
     6430 *
     6431 * @return true on success
     6432 */
     6433
     6434bool detNormalizedStatImfileSelectRowsFits(
     6435    psDB            *dbh,               ///< Database handle
     6436    psFits          *fits,              ///< psFits object
     6437    const psMetadata *where,            ///< Row match criteria
     6438    unsigned long long limit            ///< Maximum number of elements to return
     6439);
     6440
     6441/** Convert a detNormalizedStatImfileRow into an equivalent psMetadata
     6442 *
     6443 * @return A psMetadata pointer or NULL on error
     6444 */
     6445
     6446psMetadata *detNormalizedStatImfileMetadataFromObject(
     6447    const detNormalizedStatImfileRow *object             ///< fooRow to convert into a psMetadata
     6448);
     6449
     6450/** Convert a psMetadata into an equivalent fooRow
     6451 *
     6452 * @return A detNormalizedStatImfileRow pointer or NULL on error
     6453 */
     6454
     6455detNormalizedStatImfileRow *detNormalizedStatImfileObjectFromMetadata(
     6456    psMetadata      *md                 ///< psMetadata to convert into a fooRow
     6457);
     6458/** Selects up to limit rows from the database and returns as detNormalizedStatImfileRow objects in a psArray
     6459 *
     6460 *  See psDBSelectRows() for documentation on the format of where.
     6461 *
     6462 * @return A psArray pointer or NULL on error
     6463 */
     6464
     6465psArray *detNormalizedStatImfileSelectRowObjects(
     6466    psDB            *dbh,               ///< Database handle
     6467    const psMetadata *where,            ///< Row match criteria
     6468    unsigned long long limit            ///< Maximum number of elements to return
     6469);
     6470/** Deletes a row from the database coresponding to an detNormalizedStatImfile
     6471 *
     6472 *  Note that a 'where' search psMetadata is constructed from each object and
     6473 *  used to find rows to delete.
     6474 *
     6475 * @return A The number of rows removed or a negative value on error
     6476 */
     6477
     6478bool detNormalizedStatImfileDeleteObject(
     6479    psDB            *dbh,               ///< Database handle
     6480    const detNormalizedStatImfileRow *object    ///< Object to delete
     6481);
     6482/** Deletes up to limit rows from the database and returns the number of rows actually deleted.
     6483 *
     6484 *  Note that a 'where' search psMetadata is constructed from each object and
     6485 *  used to find rows to delete.
     6486 *
     6487 * @return A The number of rows removed or a negative value on error
     6488 */
     6489
     6490long long detNormalizedStatImfileDeleteRowObjects(
     6491    psDB            *dbh,               ///< Database handle
     6492    const psArray   *objects,           ///< Array of objects to delete
     6493    unsigned long long limit            ///< Maximum number of elements to delete
     6494);
     6495/** Formats and prints an array of detNormalizedStatImfileRow objects
     6496 *
     6497 * When mdcf is set the formated output is in psMetadataConfig
     6498 * format, otherwise it is in a simple tabular format.
     6499 *
     6500 * @return true on success
     6501 */
     6502
     6503bool detNormalizedStatImfilePrintObjects(
     6504    FILE            *stream,            ///< a stream
     6505    psArray         *objects,           ///< An array of detNormalizedStatImfileRow objects
     6506    bool            mdcf                ///< format as mdconfig or simple
     6507);
    62816508/** detNormalizedImfileRow data structure
    62826509 *
Note: See TracChangeset for help on using the changeset viewer.