IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 26, 2009, 1:59:32 PM (17 years ago)
Author:
beaumont
Message:

merged with trunk

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ippTools/src

    • Property svn:ignore
      •  

        old new  
        3333pstamptool
        3434disttool
         35receivetool
  • branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxtools.h

    r23594 r24244  
    5050
    5151bool pxIsValidState(const char *state);
     52bool pxSetStateCleaned(const psString tableName, const psString columnName, psArray *rows);
     53bool pxAddLabelSearchArgs (pxConfig *config, psMetadata *where, char *field, char *name, char *op);
    5254
    5355bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code);
     
    478480}
    479481
     482
     483/// Add a primary item to the mirror database
     484///
     485/// ITEM: Item to add (if it is of the correct type)
     486/// NAME: Name for table, to match item name
     487/// ROWTYPE: Type of the row (type returned by PARSEFUNC)
     488/// PARSEFUNC: Function to parse ITEM and return a ROWTYPE
     489/// IDENTIFIERS: Vector (of type U64) to store identifiers
     490/// IDNAME: Element of the row with U64 identifier
     491/// INSERTFUNC: Function to insert a row into the database
     492/// DATABASE: Database handle
     493/// CLEANUP: Operation(s) to perform to cleanup in case of an error
     494#define PXMIRROR_PRIMARY(ITEM, NAME, ROWTYPE, PARSEFUNC, IDENTIFIERS, IDNAME, INSERTFUNC, DATABASE, CLEANUP) \
     495    if (strcmp((ITEM)->name, NAME) == 0) { \
     496        if ((ITEM)->type != PS_DATA_METADATA) { \
     497            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Entry %s is not of type METADATA", (ITEM)->name); \
     498            CLEANUP; \
     499            return false; \
     500        } \
     501        ROWTYPE *row = PARSEFUNC((ITEM)->data.md); /* Row to insert */ \
     502        if (!row) { \
     503            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate %s row from metadata", (ITEM)->name); \
     504            CLEANUP; \
     505            return false; \
     506        } \
     507        if (!INSERTFUNC(DATABASE, row)) { \
     508            psError(PS_ERR_UNKNOWN, false, "Unable to add %s %" PRIu64, (ITEM)->name, row->IDNAME); \
     509            psFree(row); \
     510            CLEANUP; \
     511            return false; \
     512        } \
     513        psVectorAppend((IDENTIFIERS), row->IDNAME); \
     514        psFree(row); \
     515    }
     516
     517/// Add a dependent item to the mirror database
     518///
     519/// ITEM: Item to add (if it is of the correct type)
     520/// NAME: Name for table, to match item name
     521/// ROWTYPE: Type of the row (type returned by PARSEFUNC)
     522/// PARSEFUNC: Function to parse ITEM and return a ROWTYPE
     523/// IDENTIFIERS: Vector (of type U64) to check identifiers
     524/// IDNAME: Element of the row with U64 identifier
     525/// INSERTFUNC: Function to insert a row into the database
     526/// DATABASE: Database handle
     527/// CLEANUP: Operation(s) to perform to cleanup in case of an error
     528#define PXMIRROR_OTHER(ITEM, NAME, ROWTYPE, PARSEFUNC, IDENTIFIERS, IDNAME, INSERTFUNC, DATABASE, CLEANUP) \
     529    if (strcmp((ITEM)->name, NAME) == 0) { \
     530        if ((ITEM)->type != PS_DATA_METADATA) { \
     531            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Entry %s is not of type METADATA", (ITEM)->name); \
     532            CLEANUP; \
     533            return false; \
     534        } \
     535        ROWTYPE *row = PARSEFUNC(item->data.md); /* Row to insert */ \
     536        if (!row) { \
     537            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate %s row from metadata", (ITEM)->name); \
     538            CLEANUP; \
     539            return false; \
     540        } \
     541        bool found = false;         /* Found the identifier? */ \
     542        for (int i = 0; i < (IDENTIFIERS)->n && !found; i++) { \
     543            if (row->IDNAME == (IDENTIFIERS)->data.U64[i]) { \
     544                found = true; \
     545                break; \
     546            } \
     547        } \
     548        if (!found) { \
     549            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Identifier not found for %s %" PRIu64, \
     550                    (ITEM)->name, row->IDNAME); \
     551            psFree(row); \
     552            CLEANUP; \
     553            return false; \
     554        } \
     555        if (!INSERTFUNC(DATABASE, row)) { \
     556            psError(PS_ERR_UNKNOWN, false, "Unable to add %s %" PRIu64, (ITEM)->name, row->IDNAME); \
     557            psFree(row); \
     558            CLEANUP; \
     559            return false; \
     560        } \
     561        psFree(row); \
     562    }
     563
    480564#endif // PXTOOLS_H
Note: See TracChangeset for help on using the changeset viewer.