IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3155 for trunk/doc/pslib


Ignore:
Timestamp:
Feb 7, 2005, 6:56:24 PM (21 years ago)
Author:
eugene
Message:

bugzilla changes (psMetadata iterators, pmObject stuff)

Location:
trunk/doc/pslib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/ChangeLogSDRS.tex

    r3093 r3155  
    1 %%% $Id: ChangeLogSDRS.tex,v 1.61 2005-01-26 00:04:52 price Exp $
     1%%% $Id: ChangeLogSDRS.tex,v 1.62 2005-02-08 04:56:24 eugene Exp $
    22
    33\subsection{Changes from version 00 to version 01}
     
    446446\item Added \code{region} and \code{nSamples} to
    447447  \code{psPlaneTransformCombine} and specified the algorithm.
    448 \end{itemize}
     448\item re-added psMetadata iterators, modified the APIs somewhat
     449\item added the mode entry to psMetadataAddItem
     450\item clarified the 'format' entry in psMetadataAdd
     451\item added the function psMetadataAddV
     452\item added the option flags \code{psMetadataFlags}
     453\end{itemize}
  • trunk/doc/pslib/psLibSDRS.tex

    r3106 r3155  
    1 %%% $Id: psLibSDRS.tex,v 1.173 2005-01-28 21:37:57 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.174 2005-02-08 04:56:24 eugene Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    39013901\code{psMetadataItem} ready for insertion into the \code{psMetadata}.
    39023902The \code{name} entry specifies the name to use for this metadata
    3903 item, and may include \code{sprintf}-stype formating codes.  The
    3904 \code{format} entry, which specifies both the metadata type and the
    3905 optional flags, is constructed by bit-wise or'ing the appropriate type
    3906 and flag.  The \code{comment} entry is a fixed string which is used
    3907 for the comment associated with this metadata item.  The metadata data
    3908 and the arguments to the \code{name} formatting codes are passed, in
    3909 that order (metadata pointer first), to \code{psMetadataItemAlloc} as
     3903item, and may include \code{sprintf}-type formating codes.  The
     3904\code{comment} entry is a fixed string which is used for the comment
     3905associated with this metadata item.  The metadata data and the
     3906arguments to the \code{name} formatting codes are passed, in that
     3907order (metadata pointer first), to \code{psMetadataItemAlloc} as
    39103908arguments following the comment string.  The data must be a pointer
    39113909for any data types which are stored in the element \code{data.void},
     
    39153913\begin{verbatim}
    39163914psMetadataItem *psMetadataItemAlloc(const char *name, psMetadataType type, const char *comment, ...);
    3917 psMetadataItem *psMetadataItemAllocV(const char *name, psMetadataType type,
    3918                                      const char *comment, va_list list);
     3915psMetadataItem *psMetadataItemAllocV(const char *name, psMetadataType type, const char *comment, va_list list);
    39193916\end{verbatim}
    39203917
     
    39333930(\code{true}) or failure of the operation.  The second function,
    39343931\code{psMetadataAdd} takes a pointer or value which is interpreted by
    3935 the function using variadic argument interpretation.  Both functions
    3936 take an parameter \code{location} which specifies where in the list to
    3937 place the element, following the conventions for the \code{psList}.
    3938 Care should be taken not to leak memory when appending an item for
    3939 which the key already exists in the metadata (and is not
    3940 \code{PS_META_LIST}).
    3941 %
    3942 \begin{verbatim}
    3943 bool psMetadataAddItem(psMetadata *md, psMetadataItem *item, int location);
     3932the function using variadic argument interpretation.  The third
     3933version is the \code{va_list} version of the second function.  All
     3934three functions take a parameter, \code{location}, which specifies
     3935where in the list to place the element, following the conventions for
     3936the \code{psList}.  The entry \code{mode} for \code{psMetadataAddItem}
     3937is a bit mask constructed by OR-ing the allowed option flags (eg,
     3938PS_META_REPLACE) which specifies minor variations on the behavior.
     3939The \code{format} entry, which specifies both the metadata type and
     3940the optional flags, is constructed by bit-wise OR-ing the appropriate
     3941\code{psMetadataType} and allowed option option flags.  Care should be
     3942taken not to leak memory when appending an item for which the key
     3943already exists in the metadata (and is not \code{PS_META_LIST}).
     3944%
     3945\begin{verbatim}
     3946bool psMetadataAddItem(psMetadata *md, psMetadataItem *item, int location, int mode);
    39443947bool psMetadataAdd(psMetadata *md, int location, const char *name, int format, const char *comment, ...);
     3948bool psMetadataAddV(psMetadata *md, int location, const char *name, int format, const char *comment, ...);
     3949\end{verbatim}
     3950
     3951The functions above take option flags which modify the behavior when
     3952metadata items are added to the metadata list.  These flags must be
     3953bit-exclusive of those used above for the \code{psMetadataTypes}.  The
     3954flags have the following meanings:
     3955
     3956\code{PS_META_DEFAULT}: This is the zero bit mask, to allow the
     3957default behavior for \code{psMetadataAddItem} above.  If this is OR-ed
     3958with a \code{psMetadataType}, the result is as if no OR-ing took
     3959place.
     3960
     3961\code{PS_META_REPLACE}: If the given metadata item exists in the
     3962metadata list, and is not of type \code{PS_META_LIST} or
     3963\code{PS_META_META} (ie, not a container type), then this entry is
     3964allowed to replace the existing entry.  If this mode bit is not set, a
     3965duplicate (non-container-type) entry is an error.
     3966
     3967\begin{verbatim}
     3968typedef enum {                          ///< option flags for psMetadata functions
     3969    PS_META_DEFAULT,                    ///< default behavior (0x0000) for use in mode above
     3970    PS_META_REPLACE,                    ///< allow entry to be replaced
     3971} psMetadataFlags;
     3972\end{verbatim}
     3973
     3974An example of code to use these metadata APIs to generate the
     3975structure seen in Figure~\ref{fig:metadata} is given below.
     3976
     3977\begin{verbatim}
     3978md = psMetadataAlloc();
     3979
     3980psMetadataAdd(md, PS_LIST_TAIL, "SIMPLE",   PS_META_BOOL, "basic fits",            TRUE);
     3981psMetadataAdd(md, PS_LIST_TAIL, "BLANK",    PS_META_S32,  "invalid pixel data",    -32768);
     3982psMetadataAdd(md, PS_LIST_TAIL, "DATE-OBS", PS_META_STR,  "observing date UT", "   2004-6-16");
     3983psMetadataAdd(md, PS_LIST_TAIL, "COMMENT",  PS_META_LIST, "head of comment block", NULL);
     3984psMetadataAdd(md, PS_LIST_TAIL, "COMMENT",  PS_META_STR,  "",                      "DATA");
     3985psMetadataAdd(md, PS_LIST_TAIL, "COMMENT",  PS_META_STR,  "",                      "PARAMS");
     3986psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME",  PS_META_F32,  "exposure time (sec)",   1.05);
     3987psMetadataAdd(md, PS_LIST_TAIL, "COMMENT",  PS_META_STR,  "",                      "FOO");
     3988
     3989cell = psMetadataAlloc();
     3990psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME",  PS_META_STR,  "",                    "CCD00");
     3991psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_META_STR,  "",                    "BSEC-00");
     3992psMetadataAdd(cell, PS_LIST_TAIL, "CHIP",     PS_META_STR,  "",                    "CHIP.00");
     3993psMetadataAdd(md,   PS_LIST_TAIL, "CELL.00",  PS_META_META, "",                    cell);
     3994
     3995cell = psMetadataAlloc();
     3996psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME",  PS_META_STR,  "",                    "CCD01");
     3997psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_META_STR,  "",                    "BSEC-01");
     3998psMetadataAdd(cell, PS_LIST_TAIL, "CHIP",     PS_META_STR,  "",                    "CHIP.01");
     3999psMetadataAdd(md,   PS_LIST_TAIL, "CELL.01",  PS_META_META, "",                    cell);
     4000\end{verbatim}
     4001
     4002The following code shows how to use the APIs to replace one of these values:
     4003\begin{verbatim}
     4004psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME",  PS_META_F32 | PS_REPLACE,  "new exposure time (sec)",   2.05);
    39454005\end{verbatim}
    39464006
     
    39834043\end{verbatim}
    39844044
    3985 The metadata may be iterated over by (re-)setting a particular
    3986 \code{iterator}, to a location in the \code{psMetadata} list, and
    3987 getting the previous or next item.  \code{psMetadataGetNext} has the
    3988 ability to match the beginning of a key, e.g., if the user only wants
    3989 to iterate through \code{IPP.machines.sky} and doesn't want to bother
    3990 with \code{IPP.machines.detector}.  The iterator should iterate over
    3991 every item of metadata --- even those that are non-unique.  The value
    3992 \code{iterator} specifies the iterator to be used.  In setting the
    3993 iterator, the position of the iterator is defined by \code{location},
    3994 which follows the conventions of the \code{psList} iterators.
    3995 \begin{verbatim}
    3996 bool psMetadataSetIterator(psMetadata *md, int iterator, int location);
    3997 psMetadataItem *psMetadataGetNext(psMetadata *md, const char *match, int iterator);
    3998 psMetadataItem *psMetadataGetPrevious(psMetadata *md, const char *match, int iterator);
     4045The metadata list component may be iterated over by using a
     4046\code{psListIterator} in a fashion equivalent to the usage for
     4047\code{psList}.  The iterator may be set to a location in the
     4048\code{psMetadata} list, and the user may get the previous or next item
     4049in the list relative to that location.  \code{psMetadataGetNext} has
     4050the ability to match the key using a POSIX regex, e.g., if the user
     4051only wants to iterate through \code{IPP.machines.sky} and doesn't want
     4052to bother with \code{IPP.machines.detector}.  The iterator should
     4053iterate over every item in the metadata list, even those that are
     4054contained in a \code{PS_META_LIST}.  The value \code{iterator}
     4055specifies the iterator to be used.  In setting the iterator, the
     4056position of the iterator is defined by \code{location}, which follows
     4057the conventions of the \code{psList} iterators.
     4058\begin{verbatim}
     4059psListIterator *psMetadataIteratorAlloc(psMetadata *md, int location, bool mutable);
     4060bool psMetadataIteratorSet(psListIterator *iterator, int location);
     4061psMetadataItem *psMetadataGetAndIncrement(psListIterator *iterator, const char *regex);
     4062psMetadataItem *psMetadataGetAndDecrement(psListIterator *iterator, const char *regex);
    39994063\end{verbatim}
    40004064
Note: See TracChangeset for help on using the changeset viewer.