Changeset 3155 for trunk/doc/pslib/psLibSDRS.tex
- Timestamp:
- Feb 7, 2005, 6:56:24 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r3106 r3155 1 %%% $Id: psLibSDRS.tex,v 1.17 3 2005-01-28 21:37:57 price Exp $1 %%% $Id: psLibSDRS.tex,v 1.174 2005-02-08 04:56:24 eugene Exp $ 2 2 \documentclass[panstarrs,spec]{panstarrs} 3 3 … … 3901 3901 \code{psMetadataItem} ready for insertion into the \code{psMetadata}. 3902 3902 The \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 3903 item, and may include \code{sprintf}-type formating codes. The 3904 \code{comment} entry is a fixed string which is used for the comment 3905 associated with this metadata item. The metadata data and the 3906 arguments to the \code{name} formatting codes are passed, in that 3907 order (metadata pointer first), to \code{psMetadataItemAlloc} as 3910 3908 arguments following the comment string. The data must be a pointer 3911 3909 for any data types which are stored in the element \code{data.void}, … … 3915 3913 \begin{verbatim} 3916 3914 psMetadataItem *psMetadataItemAlloc(const char *name, psMetadataType type, const char *comment, ...); 3917 psMetadataItem *psMetadataItemAllocV(const char *name, psMetadataType type, 3918 const char *comment, va_list list); 3915 psMetadataItem *psMetadataItemAllocV(const char *name, psMetadataType type, const char *comment, va_list list); 3919 3916 \end{verbatim} 3920 3917 … … 3933 3930 (\code{true}) or failure of the operation. The second function, 3934 3931 \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); 3932 the function using variadic argument interpretation. The third 3933 version is the \code{va_list} version of the second function. All 3934 three functions take a parameter, \code{location}, which specifies 3935 where in the list to place the element, following the conventions for 3936 the \code{psList}. The entry \code{mode} for \code{psMetadataAddItem} 3937 is a bit mask constructed by OR-ing the allowed option flags (eg, 3938 PS_META_REPLACE) which specifies minor variations on the behavior. 3939 The \code{format} entry, which specifies both the metadata type and 3940 the optional flags, is constructed by bit-wise OR-ing the appropriate 3941 \code{psMetadataType} and allowed option option flags. Care should be 3942 taken not to leak memory when appending an item for which the key 3943 already exists in the metadata (and is not \code{PS_META_LIST}). 3944 % 3945 \begin{verbatim} 3946 bool psMetadataAddItem(psMetadata *md, psMetadataItem *item, int location, int mode); 3944 3947 bool psMetadataAdd(psMetadata *md, int location, const char *name, int format, const char *comment, ...); 3948 bool psMetadataAddV(psMetadata *md, int location, const char *name, int format, const char *comment, ...); 3949 \end{verbatim} 3950 3951 The functions above take option flags which modify the behavior when 3952 metadata items are added to the metadata list. These flags must be 3953 bit-exclusive of those used above for the \code{psMetadataTypes}. The 3954 flags have the following meanings: 3955 3956 \code{PS_META_DEFAULT}: This is the zero bit mask, to allow the 3957 default behavior for \code{psMetadataAddItem} above. If this is OR-ed 3958 with a \code{psMetadataType}, the result is as if no OR-ing took 3959 place. 3960 3961 \code{PS_META_REPLACE}: If the given metadata item exists in the 3962 metadata 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 3964 allowed to replace the existing entry. If this mode bit is not set, a 3965 duplicate (non-container-type) entry is an error. 3966 3967 \begin{verbatim} 3968 typedef 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 3974 An example of code to use these metadata APIs to generate the 3975 structure seen in Figure~\ref{fig:metadata} is given below. 3976 3977 \begin{verbatim} 3978 md = psMetadataAlloc(); 3979 3980 psMetadataAdd(md, PS_LIST_TAIL, "SIMPLE", PS_META_BOOL, "basic fits", TRUE); 3981 psMetadataAdd(md, PS_LIST_TAIL, "BLANK", PS_META_S32, "invalid pixel data", -32768); 3982 psMetadataAdd(md, PS_LIST_TAIL, "DATE-OBS", PS_META_STR, "observing date UT", " 2004-6-16"); 3983 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_META_LIST, "head of comment block", NULL); 3984 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_META_STR, "", "DATA"); 3985 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_META_STR, "", "PARAMS"); 3986 psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME", PS_META_F32, "exposure time (sec)", 1.05); 3987 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_META_STR, "", "FOO"); 3988 3989 cell = psMetadataAlloc(); 3990 psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME", PS_META_STR, "", "CCD00"); 3991 psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_META_STR, "", "BSEC-00"); 3992 psMetadataAdd(cell, PS_LIST_TAIL, "CHIP", PS_META_STR, "", "CHIP.00"); 3993 psMetadataAdd(md, PS_LIST_TAIL, "CELL.00", PS_META_META, "", cell); 3994 3995 cell = psMetadataAlloc(); 3996 psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME", PS_META_STR, "", "CCD01"); 3997 psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_META_STR, "", "BSEC-01"); 3998 psMetadataAdd(cell, PS_LIST_TAIL, "CHIP", PS_META_STR, "", "CHIP.01"); 3999 psMetadataAdd(md, PS_LIST_TAIL, "CELL.01", PS_META_META, "", cell); 4000 \end{verbatim} 4001 4002 The following code shows how to use the APIs to replace one of these values: 4003 \begin{verbatim} 4004 psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME", PS_META_F32 | PS_REPLACE, "new exposure time (sec)", 2.05); 3945 4005 \end{verbatim} 3946 4006 … … 3983 4043 \end{verbatim} 3984 4044 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); 4045 The 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 4049 in the list relative to that location. \code{psMetadataGetNext} has 4050 the ability to match the key using a POSIX regex, e.g., if the user 4051 only wants to iterate through \code{IPP.machines.sky} and doesn't want 4052 to bother with \code{IPP.machines.detector}. The iterator should 4053 iterate over every item in the metadata list, even those that are 4054 contained in a \code{PS_META_LIST}. The value \code{iterator} 4055 specifies the iterator to be used. In setting the iterator, the 4056 position of the iterator is defined by \code{location}, which follows 4057 the conventions of the \code{psList} iterators. 4058 \begin{verbatim} 4059 psListIterator *psMetadataIteratorAlloc(psMetadata *md, int location, bool mutable); 4060 bool psMetadataIteratorSet(psListIterator *iterator, int location); 4061 psMetadataItem *psMetadataGetAndIncrement(psListIterator *iterator, const char *regex); 4062 psMetadataItem *psMetadataGetAndDecrement(psListIterator *iterator, const char *regex); 3999 4063 \end{verbatim} 4000 4064
Note:
See TracChangeset
for help on using the changeset viewer.
