IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6257


Ignore:
Timestamp:
Jan 30, 2006, 5:19:13 PM (20 years ago)
Author:
jhoblitt
Message:

merge pxalloc.c into pxframes.c
add PX_FRAME_ALLOC macro
add PX_FRAME_SEARCH macro

Location:
trunk/ippTools/src
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/Makefile.am

    r6225 r6257  
    1 bin_PROGRAMS = p2search pxadmin
     1bin_PROGRAMS = pxadmin p0search p2search
    22
    33include_HEADERS = pxtools.h
     
    88libpxtools_la_SOURCES   = \
    99    p2searchDoneFrames.c \
    10     pxalloc.c \
    1110    p2insertPendingFrames.c \
    1211    p2pendingToDone.c \
     
    2221AM_CPPFLAGS = -I$(top_srcdir)/src$
    2322
     23p0search_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(METADATADB_CFLAGS) $(pxtools_CFLAGS)
     24p0search_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(METADATADB_LIBS) $(top_builddir)/src/libpxtools.la
     25p0search_SOURCES = \
     26    p0search.c \
     27    p0searchConfig.c
     28
    2429p2search_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(METADATADB_CFLAGS) $(pxtools_CFLAGS)
    2530p2search_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(METADATADB_LIBS) $(top_builddir)/src/libpxtools.la
     
    2732    p2search.c \
    2833    p2searchConfig.c
     34
    2935pxadmin_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(METADATADB_CFLAGS) $(pxtools_CFLAGS)
    3036pxadmin_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(METADATADB_LIBS) $(top_builddir)/src/libpxtools.la
  • trunk/ippTools/src/pxframes.c

    r6224 r6257  
    22
    33#include "pxtools.h"
     4
     5#define PX_FRAME_ALLOC(frametype, exptype) \
     6 \
     7static void frametype##Free(frametype *ptr);\
     8 \
     9frametype *frametype##Alloc( \
     10    exptype##Row *exposure, \
     11    psArray *images \
     12) \
     13{ \
     14    frametype *frame; \
     15 \
     16    PS_ASSERT_PTR_NON_NULL(exposure, NULL); \
     17    PS_ASSERT_PTR_NON_NULL(images, NULL); \
     18 \
     19    frame = psAlloc(sizeof(frametype)); \
     20    psMemSetDeallocator(frame, (psFreeFunc)frametype##Free); \
     21 \
     22    frame->exposure = exposure; \
     23    frame->images   = images; \
     24 \
     25    return frame; \
     26} \
     27 \
     28static void frametype##Free(frametype *ptr) \
     29{ \
     30    psFree(ptr->exposure); \
     31    psFree(ptr->images); \
     32}
     33
     34PX_FRAME_ALLOC(newFrame, newExp);
     35PX_FRAME_ALLOC(rawScienceFrame, rawScienceExp);
     36PX_FRAME_ALLOC(p2PendingFrame, p2PendingExp);
     37PX_FRAME_ALLOC(p2DoneFrame, p2DoneExp);
    438
    539#define PX_FRAME_PRINT(frametype, imfiletype) \
     
    3569PX_FRAME_PRINT(rawScienceFrame, rawImfile);
    3670PX_FRAME_PRINT(p2PendingFrame, p2PendingImfile);
     71
     72
     73#define PX_FRAME_SEARCH(frametype, exptype, imfiletype) \
     74psArray *frametype##Search(pxConfig *config) \
     75{ \
     76    PS_ASSERT_PTR_NON_NULL(config, NULL); \
     77 \
     78    psArray *exposures = exptype##SelectRowObjects(config->database, \
     79        config->where, MAX_ROWS); \
     80    if (!exposures) { \
     81        psError(PS_ERR_UNKNOWN, false, "no exptype rows found"); \
     82 \
     83        return NULL; \
     84    } \
     85 \
     86    psArray *allFrames = psArrayAlloc(exposures->n); \
     87    allFrames->n = 0; \
     88 \
     89    psMetadata *where = psMetadataAlloc (); \
     90    for (int i = 0; i < exposures->n; i++) { \
     91        exptype##Row *exposure = exposures->data[i]; \
     92\
     93        psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", PS_META_REPLACE, "==", \
     94            exposure->exp_id); \
     95 \
     96        psArray *images = imfiletype##SelectRowObjects(config->database, where, \
     97            MAX_ROWS); \
     98        if (!images) { \
     99            psError(PS_ERR_UNKNOWN, false, "database access failed"); \
     100 \
     101            return NULL; \
     102        } \
     103 \
     104        frametype *frame = frametype##Alloc(exposure, images); \
     105        psArrayAdd(allFrames, 100, frame); \
     106    } \
     107 \
     108    return allFrames; \
     109}
     110
     111PX_FRAME_SEARCH(newFrame, newExp, newImfile);
Note: See TracChangeset for help on using the changeset viewer.